> ## Documentation Index
> Fetch the complete documentation index at: https://docs.weaveos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Management API

> Export router usage and manage spend limits and grants with your Weave API key

The Weave API manages the Weave Router with the same `wv_` key you use for the rest of the [Weave API](https://docs.weaveos.com/api-reference). Send it in the `X-API-Key` header. The organization always comes from the key.

| Task | Endpoint | Scope |
| - | - | - |
| Export daily usage | `GET /router/usage` | `read` |
| Chart cost, spend and usage over time | `GET /metrics` with a `router_*` metric | `read` |
| Read limits and each engineer's headroom | `GET /router/spend-limits` | `read` |
| Set the org limits | `PUT /router/spend-limits` | `budgets` or `write` |
| Set or clear one engineer's limit | `PUT /router/spend-limits/users/{user}` | `budgets` or `write` |
| Add one-off headroom for this month | `POST /router/spend-limits/users/{user}/grants` | `budgets` or `write` |
| Audit every limit change | `GET /router/spend-limits/history` | `read` |

`{user}` is either the engineer's router user ID or their email address. Emails match case-insensitively. If one email belongs to more than one router user in your organization, the API answers `409` and you use the router user ID instead.

A key that only manages spend can hold `read` and `budgets` without `write`. Create keys under **Settings → API keys**.

## Export usage

`GET /router/usage` returns one row per UTC day for each combination of the dimensions you group by: `user`, `api_key`, `served_model` and `requested_model`. A dimension you did not group by is `null`. The range is at most 92 days, `end` inclusive.

```bash theme={null}
curl -sS -H "X-API-Key: $WEAVE_API_KEY" \
  "https://app.workweave.ai/api/v1/router/usage?start=2026-11-01&end=2026-11-30&group_by=user&group_by=served_model"
```

Pass each response's `next_cursor` back as `cursor` until it is `null`, keeping the other filters and groupings unchanged. Pages are not a snapshot; late-arriving usage may cause rows to repeat or be missed while paging. For reconciliation, re-fetch settled date ranges and replace each day's aggregates rather than appending them.

With reporting anonymization on, `user` and `api_key` groupings and the `emails` and `api_key_ids` filters are not available. If you omit `group_by`, usage is grouped by served and requested model only.

Two cost columns come back, and they answer different questions:

* `cost_usd_micros` is the **billed** cost: what the router charged, `0` for turns an engineer's own subscription covered. This is the number that reconciles against your Weave invoice and, for bring-your-own-key traffic, your provider invoices.
* `api_rate_cost_usd_micros` prices every turn at catalog API rates, subscription-covered turns included. It measures consumption, not spend.

Money is in USD micros: \$1.00 is 1,000,000.

The export does not include savings. For the comparison against your comparison model, read `GET /metrics?metric=router_cost&group_by=router_cost_type`, which returns an `actual` and a `comparison` row for each period. See [how savings are calculated](https://docs.weaveos.com/router/reporting.md#how-savings-are-calculated).

## Raise an engineer's limit from Slack

A grant adds headroom on top of an engineer's monthly limit for the current UTC month only. It expires at the month boundary, leaves the engineer's base limit alone, and never lifts the organization-wide cap. A grant has no effect while the engineer is uncapped.

A typical approval flow:

1. Subscribe a webhook to `router_spend_alert`. It fires `router_spend_limit.approaching` and `router_spend_limit.reached` with the engineer's `user_email` and a stable alert `id`.
2. Your Slack bot asks the engineer's manager to approve more headroom.
3. On approval, the bot checks that the alert's `month` is still the current UTC month. After rollover, request a new approval instead of submitting the old grant. Use the alert `id` as the `Idempotency-Key` so a retried request cannot grant twice:

```bash theme={null}
curl -sS -X POST \
  -H "X-API-Key: $WEAVE_API_KEY" \
  -H "Idempotency-Key: 5b0d7a5e-1f7c-4c8e-9a51-0c1d2e3f4a5b" \
  -H "Content-Type: application/json" \
  -d '{"amount_usd_micros": 50000000, "reason": "Release week", "approved_by": "manager@example.com"}' \
  "https://app.workweave.ai/api/v1/router/spend-limits/users/engineer@example.com/grants"
```

A new grant returns `201`. Repeating a key returns the original grant with `200` and adds nothing. The response's `user.remaining_usd_micros` is the engineer's headroom for the rest of the month.

## Audit limit changes

`GET /router/spend-limits/history` lists every change, newest first: org limit changes, engineer limits set or cleared, and grants. Each entry has the old and new values, the reason and approver when given, and the actor's stable ID: `actor_api_key_id` for API writes or `actor_account_id` for changes made in the app. The current key name, when available, is a display label in `actor_api_key_name`. The key ID remains in history after revocation. Filter by `user`, `since` and `until`, and resend those same filters when paging with `cursor`.

> [!NOTE]
>
> The `ra_` analytics keys and the router's `/v1/analytics/*` routes are deprecated. Existing keys keep working for now, but new ones can no longer be issued. Use `GET /router/usage` for usage, or see the [analytics export](https://docs.weaveos.com/router/analytics-export.md) if you still read raw routing decisions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.