Skip to navigation

Update an API key

Changes a key’s name, its limits, its reset period, or switches it off and on. Only the fields you send change. Send null for name, max_requests, max_tokens, max_sandboxes or limit_reset to clear it. OpenRouter’s key update takes the same kind of fields (name, disabled, limit, limit_reset).

Rules:

  • disabled: true switches the key off. Every call made with it, or with a key minted from it at any depth, returns 401 api key is disabled until you send disabled: false. Nothing is deleted and the counters stay. It returns 409 when it would leave the account with no usable admin key.
  • max_requests, max_tokens and max_sandboxes follow the rule for minting. When the key that minted this one has a limit, this key must keep one that is no larger, or the call returns 403. Keys minted from this one keep their own numbers. Their use still counts against this key, so a lowered limit holds for them too.
  • The usage counters do not change. A limit set below what is already used refuses the next call.
  • Scopes, allowed_models, expires_at and the project cannot be changed. Mint a new key for those. Sending one of them returns 400, as any unknown field does.
  • A revoked key cannot be updated. The call returns 409.

Scope: admin.

curl -sS -X PATCH "$MEADOW_BASE_URL/v1/keys/$KEY_ID" \
-H "Authorization: Bearer $MEADOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"max_tokens":500000,"limit_reset":"monthly"}'

Authentication

AuthorizationBearer

A Meadow API key, sent as Authorization: Bearer mdw_.... The header x-api-key: mdw_... is accepted in its place.

Path parameters

key_idstringRequired

The key id (key_...). The secret does not work here.

Request

At most 1 MiB.
namestring or nullOptional
A label for people. Null clears it.
disabledbooleanOptional

True switches the key off: it and every key minted from it return 401 until it is set to false. Cannot be null.

max_requestsinteger or nullOptional>=0
The new request limit. Null removes the limit. It cannot be higher than the limit of the key that minted this key.
max_tokensinteger or nullOptional>=0
The new token limit. Null removes the limit. It cannot be higher than the limit of the key that minted this key.
limitdouble or nullOptional>=0

The new dollar limit, written as on POST /v1/keys. Null removes the limit. It cannot be higher than the limit of the key that minted this key. Dollars already counted in the current period stay counted. A key that had no dollar limit in its chain starts counting at 0.

limit_actionenumOptional

What happens to running sandboxes when the limit is spent. Null leaves them running. See limit_action on POST /v1/keys. Setting stop_sandboxes on a key whose limit is already spent deletes its running sandboxes within about a minute.

Allowed values:
max_sandboxesinteger or nullOptional>=0

The new cap on sandboxes alive at once. Null removes the cap. It cannot be higher than the cap of the key that minted this key. Lowering it below the number alive ends no sandbox: it stops new creates until enough have ended.

limit_resetenumOptional

When the counters reset. Null means no reset. See limit_reset on POST /v1/keys.

Allowed values:
allowed_modelslist of strings or nullOptional

The new list of models the key may call, written as on POST /v1/keys. Null removes the list. An empty list returns 400. It must stay within the lists of the keys above this key and of the calling key, so a key can narrow itself and never widen itself. The change holds every key minted from this one from its next call. A call already running keeps the route it planned.

allowed_providerslist of enums or nullOptional

The new list of model providers, with the rules of allowed_models here. Null removes the list.

allowed_sandbox_providerslist of enums or nullOptional

The new list of sandbox providers, with the rules of allowed_models here. Null removes the list.

Allowed values:

Response headers

x-request-idstringOptional

Meadow’s id for this request, req_ and 24 hex characters. Every response carries it, including errors, streams and unknown routes. Every error in the Error schema repeats it as request_id. Quote it when you report a problem.

Response

The key after the change.
project_idstring
The project the key belongs to. It can be any project of the account.
idstring

The key id (key_...). Use it to read, update or revoke the key. It is not the secret.

created_atdatetime
When the key was minted.
namestringOptional
A label for people. Absent from responses when not given.
scopeslist of enumsOptional

What the key may do. models covers model calls. sandboxes covers sandboxes, images, and build contexts. admin covers projects, keys, and provider keys. When left out, the new key gets the minting key’s scopes among models and sandboxes. It gets admin only when this names it. Must not be empty.

Allowed values:
allowed_modelslist of stringsOptional

Model ids the key may call. Left out, the key may call any model. An empty list returns 400: leave the field out instead. Absent from responses when not set.

Matching is exact and case-sensitive, after Meadow reads the id the way a request’s model is read. A plain id such as claude-haiku-5-5 allows that model on every provider that serves it. A vendor alias counts as the model it names (claude-haiku-4-5 and claude-haiku-4-5-20251001 are one model), and a leading meadow/ is dropped. A prefixed id such as anthropic/claude-haiku-5-5 allows the model on that provider only. A prefix Meadow does not know returns 400.

The list is checked against the model the request names, before any vendor is called. When the vendor answers with another snapshot or reroutes the model, the call is served and the usage record’s served_model shows what answered.

A key minted by a key with allowed_models must name models from that list. A key is also held by the allowed_models of every key above it, at the moment of each call.

allowed_providerslist of enumsOptional

The model providers the key’s calls may be routed to. Left out, any. An empty list returns 400. Absent from responses when not set. OpenRouter guardrails use the same name.

It applies to every attempt of a call: the default route, provider.order, provider.only, a prefixed model id, the fallback models in models and each fallback to the next provider. A call whose route keeps no provider on the list returns 403 key_provider_access_denied before any vendor is called. GET /v1/models lists only these providers. The name is the Meadow provider whose stored key pays for the call: with openrouter on the list, OpenRouter still picks its own upstream.

A key minted by a key with allowed_providers must name providers from the minting key’s list. A key is also held by the allowed_providers of every key above it, at the moment of each call.

allowed_sandbox_providerslist of enumsOptional

The sandbox providers the key may create sandboxes and build images on. Left out, any. An empty list returns 400. Absent from responses when not set. It applies to the create, its failover to the next provider, and build_on. A create whose route keeps no provider on the list returns 403 key_provider_access_denied. A sandbox already running stays reachable after its provider leaves the list.

A key minted by a key with allowed_sandbox_providers must name providers from the minting key’s list. A key is also held by the list of every key above it. A key made for a sandbox with model_access or sandbox_access gets the creating key’s three lists.

Allowed values:
expires_atdatetime or nullOptional
When the key stops working. Must be in the future. Null or left out means it does not expire.
max_requestsinteger or nullOptional

The most model requests the key may make in one period: its whole life, or each day, week or month when limit_reset is set. Null or left out means no limit.

max_tokensinteger or nullOptional
The most model tokens, input plus output, the key may use in one period. Null or left out means no limit. A key with this limit must send an output cap on every model request. The check uses an estimate, so one call can pass the limit before later calls are refused.
limitdouble or nullOptional>=0

The most US dollars the key may spend in one period: its whole life, or each day, week or month when limit_reset is set. The name and the unit are OpenRouter’s limit. Null or left out means no dollar limit.

Send a plain JSON number, at least 0 and below 10^12, with at most 12 decimal places. Meadow reads the digits as written and never through a binary float, so 0.1 is one tenth exactly. A value with more decimal places returns 400.

It covers model calls and sandboxes made with this key and with every key minted from it. Before a model call Meadow reserves the most the call can cost (its estimated tokens at the model’s highest price) and refuses the call with 402 key_spend_limit_exceeded when that does not fit. After the call it charges what the call cost. One call can end above the limit, and every later call is refused until the limit resets or is raised.

A key with this limit, or under a key with one, must send an output cap on every model request. It can only call models Meadow holds a price for at the provider that serves them: a route that includes any other provider returns 403 key_spend_price_unknown. See the Spend limits guide.

A minted key does not need a limit of its own. It spends from what the keys above it have left. When it has one, it cannot be higher than the minting key’s.

limit_actionenumOptional

What happens to running sandboxes when this key’s limit is spent. Null or left out, the default, leaves them running: only new sandboxes and model calls are refused. stop_sandboxes also deletes every running sandbox made with this key or with a key minted from it, within about a minute of the limit being spent. It is the same delete as DELETE /v1/sandboxes/{sandbox_id}: the sandbox ends as terminated, its sandbox.terminated webhook event is sent, and work in it is lost.

It acts only on the limit of the key it is set on. No reference product stops running compute at a budget, so the name is Meadow’s, in the limit_ family.

Allowed values:
max_sandboxesinteger or nullOptional>=0

The most sandboxes that may be alive at once among those made by this key and by every key minted from it. Null or left out means no cap. A sandbox counts while it is creating, running or terminating, and while it is failed with a vendor sandbox Meadow has not yet confirmed deleted. The count and the create are one database transaction, so two creates sent together cannot both take the last place. A create past the cap returns 403 key_sandbox_limit_exceeded. It counts sandboxes, not dollars.

limit_resetenumOptional

When the key’s max_requests, max_tokens and limit counters go back to zero. The name, the values and the clock are OpenRouter’s limit_reset: daily resets at midnight UTC, weekly on Monday at midnight UTC (weeks run Monday to Sunday), monthly on the first of the month at midnight UTC. Null or left out means no reset: the limits cover the key’s whole life. One value covers every limit of the key.

A minted key does not inherit limit_reset. It gets the value sent when it is minted, or none. Its max_requests and max_tokens still cannot be larger numbers than the minting key’s, whatever the two reset periods are. Its usage counts against the minting key and every key above it, each in that key’s own period, so a child’s reset never lifts a limit above it.

A call reserved before a boundary and finished after it is charged to the new period.

Allowed values:
last4stringOptional
The last four characters of the secret.
disabledbooleanOptional

True when the key was switched off with PATCH /v1/keys/{key_id}. A disabled key and the keys minted from it are refused with 401.

requests_usedintegerOptional

Model requests counted against this key in its current period (its whole life when limit_reset is null). It includes the requests of every key minted from this one, at any depth.

A key with a max_requests or max_tokens, on itself or on a key above it, is counted as each call is admitted. A key with no limit anywhere in its chain is counted from the usage records instead (GET /v1/usage): calls that were served. Today and yesterday (UTC) are read from the single records, a few seconds behind. Earlier days are read from the daily totals Meadow keeps.

tokens_usedintegerOptional

Tokens charged to this key in its current period, counted like requests_used. For a key with no limit in its chain it is the input plus output tokens of the usage records, estimates included.

usagedouble or nullOptional

US dollars charged to this key in its current period, the keys minted from it included. The name is OpenRouter’s usage. Null when neither this key nor a key above it has a limit: Meadow counts dollars against a key only while a limit applies to it, and GET /v1/usage has the spend of any key.

It is the number the limit is checked against. A call whose cost could not be computed is charged its reserved estimate here and has no cost in GET /v1/usage, so this can be higher than the sum of the usage records.

limit_remainingdouble or nullOptional

What the key can still spend: the least of limit minus usage over this key and every key above it, never below 0. The name is OpenRouter’s limit_remaining. Null when none of them has a limit. Dollars held by calls in flight are not subtracted, so a call can be refused while this is above 0.

requests_remaininginteger or nullOptional

max_requests minus requests_used, never below 0. Null when the key has no max_requests. It does not look at the keys above this one, whose own limits can stop a call first.

tokens_remaininginteger or nullOptional

max_tokens minus tokens_used, never below 0. Null when the key has no max_tokens. Tokens held by calls in flight are not subtracted, so a call can be refused while this is above 0.

last_used_atdatetime or nullOptional

When this key last authenticated a call of any kind (a model call, a sandbox call, a key or project call), or when a model call was last counted against it or a key below it, whichever is later. It is written at most once a minute for each key, so it can be up to a minute behind. The write runs beside the call and lands up to 2 seconds after it. Null for a key that was never used. Reading a key with itself (GET /v1/key) is a use of that key, and that same call can still show the earlier value.

limit_reset_atdatetime or nullOptional

The next time the counters reset, in UTC. Null when limit_reset is null. OpenRouter returns no such field. It is here so that you need not compute the boundary.

parent_key_idstring or nullOptional

The key that minted this one. Null for a key no other key minted, such as the first admin key. Follow it upward to see the tree: revoking a key revokes every key below it.

revoked_atdatetime or nullOptional
When the key was revoked. Null while it is live.
previous_secret_expires_atdatetime or nullOptional

When the secret replaced by POST /v1/keys/{key_id}/rotate stops working. Null when the key has one secret: it was never rotated, it was rotated with no grace period, or the grace period is over.

created_by_user_idstring or nullOptional

The signed-in person who minted this key in the dashboard. Null for a key another key minted. A person with the member role sees only the keys they minted.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
413
Content Too Large Error
429
Too Many Requests Error
500
Internal Server Error