> For the list of every page, fetch /llms.txt. The API contract is the OpenAPI file linked from the API reference.

# Update an API key

PATCH https%3A%2F%2Fapi.usemeadow.ai/v1/keys/{key_id}
Content-Type: application/json

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`.

```bash
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"}'
```

Reference: https://docs.usemeadow.ai/api-endpoints/keys/update-key

## Authentication

- `Authorization` header (bearer token, required) — A Meadow API key, sent as `Authorization: Bearer mdw_...`. The header `x-api-key: mdw_...` is accepted in its place.

## Request

### Path parameters

- `key_id` (string, required) — The key `id` (`key_...`). The secret does not work here.

### Body (application/json)

This endpoint expects a KeyUpdate.

- `name` (string, optional, nullable) — A label for people. Null clears it.
- `disabled` (boolean, optional) — True switches the key off: it and every key minted from it return 401 until it is set to false. Cannot be null.
- `max_requests` (integer, optional, nullable) — The new request limit. Null removes the limit. It cannot be higher than the limit of the key that minted this key.
- `max_tokens` (integer, optional, nullable) — The new token limit. Null removes the limit. It cannot be higher than the limit of the key that minted this key.
- `limit` (double, optional, nullable) — 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_action` (enum, optional) — 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: `stop_sandboxes`
- `max_sandboxes` (integer, optional, nullable) — 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_reset` (enum, optional) — When the counters reset. Null means no reset. See `limit_reset` on `POST /v1/keys`.
  - Allowed values: `daily`, `weekly`, `monthly`
- `allowed_models` (list of string, optional, nullable) — 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_providers` (list of enum, optional, nullable) — The new list of model providers, with the rules of `allowed_models` here. Null removes the list.
  - Allowed values: `anthropic`, `openai`, `google`, `xai`, `openrouter`, `azure`, `bedrock`, `vertex`, `fireworks`, `deepseek`
- `allowed_sandbox_providers` (list of enum, optional, nullable) — The new list of sandbox providers, with the rules of `allowed_models` here. Null removes the list.
  - Allowed values: `daytona`, `modal`

## Response

### 200

The key after the change.

- `project_id` (string, required) — The project the key belongs to. It can be any project of the account.
- `id` (string, required) — The key id (`key_...`). Use it to read, update or revoke the key. It is not the secret.
- `created_at` (datetime, required) — When the key was minted.
- `name` (string, optional) — A label for people. Absent from responses when not given.
- `scopes` (list of enum, optional) — 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: `models`, `sandboxes`, `admin`
- `allowed_models` (list of string, optional) — 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_providers` (list of enum, optional) — 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 values: `anthropic`, `openai`, `google`, `xai`, `openrouter`, `azure`, `bedrock`, `vertex`, `fireworks`, `deepseek`
- `allowed_sandbox_providers` (list of enum, optional) — 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: `daytona`, `modal`
- `expires_at` (datetime, optional, nullable) — When the key stops working. Must be in the future. Null or left out means it does not expire.
- `max_requests` (integer, optional, nullable) — 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_tokens` (integer, optional, nullable) — 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.
- `limit` (double, optional, nullable) — 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_action` (enum, optional) — 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: `stop_sandboxes`
- `max_sandboxes` (integer, optional, nullable) — 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_reset` (enum, optional) — 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: `daily`, `weekly`, `monthly`
- `last4` (string, optional) — The last four characters of the secret.
- `disabled` (boolean, optional) — 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_used` (integer, optional) — 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_used` (integer, optional) — 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.
- `usage` (double, optional, nullable) — 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_remaining` (double, optional, nullable) — 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_remaining` (integer, optional, nullable) — `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_remaining` (integer, optional, nullable) — `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_at` (datetime, optional, nullable) — 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_at` (datetime, optional, nullable) — 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_id` (string, optional, nullable) — 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_at` (datetime, optional, nullable) — When the key was revoked. Null while it is live.
- `previous_secret_expires_at` (datetime, optional, nullable) — 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_id` (string, optional, nullable) — 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

The request breaks a rule. The message names the field.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 401 Unauthorized Error

The key is missing, malformed, unknown, revoked, or expired, or a key it was minted from no longer exists. Check the key and the header.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 403 Forbidden Error

The calling key lacks the `admin` scope, or the new limit is higher than the limit of the key that minted this key.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 404 Not Found Error

No key with this id in the account.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 409 Conflict Error

The key is revoked, or disabling it would leave the account with no usable admin key.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 413 Content Too Large Error

The request body is larger than this route allows: 1 MiB for JSON bodies, 16 MiB on the model routes, 100 MiB for a file upload, and 100 MB for a build context.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 429 Too Many Requests Error

More than 20 failed authentications came from your address in one minute, and this request also failed to authenticate: fix the key, wait for `retry-after` seconds, then retry. Or the server instance was full and no slot came free for the account within 3 seconds (`error.code` `account_in_flight_limit_exceeded`): wait for `retry-after` seconds, then retry.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

### 500 Internal Server Error

Meadow failed. Retry with backoff, and tell us if it persists.

- `error` (ErrorError, required)
- `request_id` (string, optional) — The same id as the `x-request-id` response header. Quote it when you report a problem.

## Types

### ErrorError

- `type` (enum, required) — The class of the failure. - `invalid_request`: the request is malformed or breaks a rule (400), or is too large (413). - `conflict`: the request is valid and the current state refuses it (409). Before 2026-11-24 a 409 used `invalid_request`. - `unauthorized`: the key is missing, unknown, revoked, or expired (401). - `forbidden`: the key's scope or limit does not allow this, or the project's routing is locked (403). - `not_found`: no such resource or route (404). - `no_provider_key`: no stored credential can serve this request (422). - `all_providers_failed`: every vendor in the route was tried (502). - `provider_error`: a vendor failed and no fallback was possible (502). - `rate_limited`: too many requests (429). - `insufficient_quota`: a dollar `limit` on the key, or on a key above it, is spent (402). The name is OpenAI's. - `unavailable`: a dependency Meadow needs is not set up (503). - `internal`: Meadow failed (500), or the feature is not set up (501).
  - Allowed values: `invalid_request`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `no_provider_key`, `all_providers_failed`, `provider_error`, `rate_limited`, `insufficient_quota`, `unavailable`, `internal`
- `message` (string, required) — A sentence for people. It can change, so do not match on it.
- `code` (string, optional) — A stable name for the specific failure. Every Meadow error carries one. `type` stays the general class, and several codes share a type. Branch on `code` when you need to tell two failures of one type apart, for example `api_key_expired` from `api_key_revoked`. The full list is in the Errors guide. A new code can be added at any time, so treat a code you do not know as its `type`. A spent limit (`key_request_limit_exceeded`, `key_token_limit_exceeded`) stays a 403 and not a 429, so a client that retries a 429 does not resend a call a spent key can never make. A spent dollar `limit` (`key_spend_limit_exceeded`) is a 402 for the same reason.
- `param` (string, optional) — The request field, query parameter or header the error is about, when there is one. A nested field is written with dots, such as `credentials.api_key`. Set on most validation errors (400).
- `attempts` (list of Attempt, optional) — The vendors Meadow tried for this request, in order. Present only when it tried at least one.
- `retry` (enum, optional) — Whether to send the same request again. Set on routes under `/v1/sandboxes` only. The values are BoxRouter's (https://boxrouter.ai/docs/error-codes). - `safe`: send the same request again, after `retry-after` seconds when the response has that header. A 429, a 409 `exec_start_in_progress` or `idempotency_request_in_progress`, a 502 `sandbox_unreachable`, and a 5xx on a `GET`, `PUT` or `DELETE`, on `POST /v1/sandboxes/route`, or on a sandbox create or background command start sent with `Idempotency-Key`. - `after_fix`: change the request, the key or the account first. Any other 4xx. - `check_outcome`: read the sandbox or the command before you send it again, because the work may have happened. A 5xx on any other `POST`, which includes a blocking command. - `never`: do not send it again. A 501. When the response has `x-should-retry`, `retry` is `safe` exactly when the header is `true`.
  - Allowed values: `safe`, `after_fix`, `check_outcome`, `never`
- `outcome` (enum, optional) — What happened to the work. Set on routes under `/v1/sandboxes` only. The values are BoxRouter's (https://boxrouter.ai/docs/error-codes). - `not_started`: nothing was changed. Every 4xx, a 501, and a 502 `sandbox_unreachable`. - `unknown`: the work may have happened. Any other 5xx. - `completed` and `partial`: the work happened, in whole or in part. Meadow does not send them today. Handle them as `unknown`. A sandbox create that fails after Meadow accepted it is not an error response: the create returns 202, and the sandbox later has `status` `failed` and a `failure_reason`.
  - Allowed values: `not_started`, `completed`, `partial`, `unknown`

### Attempt

One try at one vendor, for a model call or a sandbox create.

- `provider` (enum, required) — The name of a vendor. Model providers and sandbox providers share one list. Model providers: `anthropic`, `openai`, `google`, `xai`, `azure`, `bedrock`, `vertex`, `openrouter`, `fireworks`, `deepseek`. Sandbox providers: `daytona`, `modal`.
  - Allowed values: `anthropic`, `openai`, `google`, `xai`, `azure`, `bedrock`, `vertex`, `openrouter`, `fireworks`, `deepseek`, `daytona`, `modal`
- `outcome` (enum, required) — How the try ended. - `served`: this vendor served the request. - `unsupported`: the vendor cannot do what was asked, such as a resource size, a network rule, or a model it does not offer. - `refused`: the vendor rejected the request or the stored credential. - `no_capacity`: the vendor had no capacity. - `timeout`: the vendor did not answer in time. - `rate_limited`: the vendor answered 429. - `error`: any other failure.
  - Allowed values: `served`, `unsupported`, `refused`, `no_capacity`, `timeout`, `rate_limited`, `error`
- `reason` (enum, optional) — A stable code for why the try ended as it did. It is narrower than `outcome`, and it is the code to branch on or to count. More values can be added: treat one you do not know like `vendor_error`. - `served`: this vendor served the request. - `no_capacity`: the vendor had no capacity. - `quota_exceeded`: the vendor account is out of quota or credit. - `rate_limited`: the vendor answered 429. - `timeout`: the vendor did not answer in time. - `auth_failed`: the vendor rejected the stored vendor key. - `invalid_request`: the vendor rejected the request itself. - `refused`: the vendor refused for another reason. - `unsupported`: the vendor cannot do what was asked, such as a model, a GPU type, a size or a network rule. - `no_provider_key`: skipped, because no usable vendor key was stored. - `image_pull_failed`, `build_failed`: the vendor could not pull or build the image (sandboxes). - `provider_lost`: the vendor lost the sandbox while it was starting. - `vendor_error`: any other failure.
  - Allowed values: `served`, `no_capacity`, `quota_exceeded`, `rate_limited`, `timeout`, `auth_failed`, `invalid_request`, `refused`, `unsupported`, `no_provider_key`, `image_pull_failed`, `build_failed`, `provider_lost`, `vendor_error`
- `started_at` (datetime, optional) — When Meadow started this try. Absent on attempts recorded before 2026-11-24.
- `finished_at` (datetime, optional) — When this try ended.
- `detail` (string, optional) — A short description of what happened, written by Meadow, such as `provider returned HTTP 404`. On a `served` sandbox attempt it reports resources the vendor granted that differ from the request, such as `provider granted cpu 2 instead of 1.5` or `gpu type H200 instead of H100`. It says `provider built a copy of the image for this size` when this create made a new Daytona snapshot for an `image_id`. On an `unsupported` attempt it carries the vendor's size limit, such as `daytona cannot serve this size: CPU request 8 exceeds maximum allowed per sandbox (4)`. Absent when there is nothing to say.
- `duration_ms` (integer, optional) — How long the try took, in milliseconds.

## Examples

### After the limits example (not captured live)

**Response**

```json
{
  "project_id": "prj_000057e9",
  "id": "key_0000507b",
  "created_at": "2026-11-24T09:12:03.512Z",
  "name": "nightly-eval",
  "scopes": [
    "models"
  ],
  "expires_at": null,
  "max_requests": 500,
  "max_tokens": 500000,
  "limit_reset": "monthly",
  "last4": "7QpL",
  "disabled": false,
  "requests_used": 42,
  "tokens_used": 87600,
  "requests_remaining": 458,
  "tokens_remaining": 412400,
  "last_used_at": "2026-11-24T10:41:27.903Z",
  "limit_reset_at": "2026-12-01T00:00:00Z",
  "parent_key_id": "key_0000b694",
  "revoked_at": null
}
```

**SDK Code**

```python After the limits example (not captured live)
import requests

url = "https://api.example.com/v1/keys/key_00003a89"

headers = {"Authorization": "Bearer <token>"}

response = requests.patch(url, headers=headers)

print(response.json())
```

```javascript After the limits example (not captured live)
const url = 'https://api.example.com/v1/keys/key_00003a89';
const options = {method: 'PATCH', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go After the limits example (not captured live)
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/keys/key_00003a89"

	req, _ := http.NewRequest("PATCH", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby After the limits example (not captured live)
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/keys/key_00003a89")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java After the limits example (not captured live)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.example.com/v1/keys/key_00003a89")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php After the limits example (not captured live)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.example.com/v1/keys/key_00003a89', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp After the limits example (not captured live)
using RestSharp;

var client = new RestClient("https://api.example.com/v1/keys/key_00003a89");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift After the limits example (not captured live)
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/keys/key_00003a89")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Lower the token limit and reset it every month

**Request**

```json
{
  "max_tokens": 500000,
  "limit_reset": "monthly"
}
```

**Response**

```json
{
  "project_id": "prj_000057e9",
  "id": "key_0000507b",
  "created_at": "2026-11-24T09:12:03.512Z",
  "name": "nightly-eval",
  "scopes": [
    "models"
  ],
  "expires_at": null,
  "max_requests": 500,
  "max_tokens": 500000,
  "limit_reset": "monthly",
  "last4": "7QpL",
  "disabled": false,
  "requests_used": 42,
  "tokens_used": 87600,
  "requests_remaining": 458,
  "tokens_remaining": 412400,
  "last_used_at": "2026-11-24T10:41:27.903Z",
  "limit_reset_at": "2026-12-01T00:00:00Z",
  "parent_key_id": "key_0000b694",
  "revoked_at": null
}
```

**SDK Code**

```python Lower the token limit and reset it every month
import requests

url = "https://api.example.com/v1/keys/key_00003a89"

payload = {
    "max_tokens": 500000,
    "limit_reset": "monthly"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Lower the token limit and reset it every month
const url = 'https://api.example.com/v1/keys/key_00003a89';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"max_tokens":500000,"limit_reset":"monthly"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Lower the token limit and reset it every month
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/keys/key_00003a89"

	payload := strings.NewReader("{\n  \"max_tokens\": 500000,\n  \"limit_reset\": \"monthly\"\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Lower the token limit and reset it every month
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/keys/key_00003a89")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"max_tokens\": 500000,\n  \"limit_reset\": \"monthly\"\n}"

response = http.request(request)
puts response.read_body
```

```java Lower the token limit and reset it every month
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.example.com/v1/keys/key_00003a89")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"max_tokens\": 500000,\n  \"limit_reset\": \"monthly\"\n}")
  .asString();
```

```php Lower the token limit and reset it every month
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.example.com/v1/keys/key_00003a89', [
  'body' => '{
  "max_tokens": 500000,
  "limit_reset": "monthly"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Lower the token limit and reset it every month
using RestSharp;

var client = new RestClient("https://api.example.com/v1/keys/key_00003a89");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"max_tokens\": 500000,\n  \"limit_reset\": \"monthly\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Lower the token limit and reset it every month
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "max_tokens": 500000,
  "limit_reset": "monthly"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/keys/key_00003a89")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Switch the key off

**Request**

```json
{
  "disabled": true
}
```

**Response**

```json
{
  "project_id": "prj_000057e9",
  "id": "key_0000507b",
  "created_at": "2026-11-24T09:12:03.512Z",
  "name": "nightly-eval",
  "scopes": [
    "models"
  ],
  "expires_at": null,
  "max_requests": 500,
  "max_tokens": 500000,
  "limit_reset": "monthly",
  "last4": "7QpL",
  "disabled": false,
  "requests_used": 42,
  "tokens_used": 87600,
  "requests_remaining": 458,
  "tokens_remaining": 412400,
  "last_used_at": "2026-11-24T10:41:27.903Z",
  "limit_reset_at": "2026-12-01T00:00:00Z",
  "parent_key_id": "key_0000b694",
  "revoked_at": null
}
```

**SDK Code**

```python Switch the key off
import requests

url = "https://api.example.com/v1/keys/key_00003a89"

payload = { "disabled": True }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Switch the key off
const url = 'https://api.example.com/v1/keys/key_00003a89';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"disabled":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Switch the key off
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/keys/key_00003a89"

	payload := strings.NewReader("{\n  \"disabled\": true\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Switch the key off
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/keys/key_00003a89")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"disabled\": true\n}"

response = http.request(request)
puts response.read_body
```

```java Switch the key off
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.example.com/v1/keys/key_00003a89")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"disabled\": true\n}")
  .asString();
```

```php Switch the key off
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.example.com/v1/keys/key_00003a89', [
  'body' => '{
  "disabled": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Switch the key off
using RestSharp;

var client = new RestClient("https://api.example.com/v1/keys/key_00003a89");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"disabled\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Switch the key off
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["disabled": true] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/keys/key_00003a89")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Remove the request limit and the reset

**Request**

```json
{
  "max_requests": null
}
```

**Response**

```json
{
  "project_id": "prj_000057e9",
  "id": "key_0000507b",
  "created_at": "2026-11-24T09:12:03.512Z",
  "name": "nightly-eval",
  "scopes": [
    "models"
  ],
  "expires_at": null,
  "max_requests": 500,
  "max_tokens": 500000,
  "limit_reset": "monthly",
  "last4": "7QpL",
  "disabled": false,
  "requests_used": 42,
  "tokens_used": 87600,
  "requests_remaining": 458,
  "tokens_remaining": 412400,
  "last_used_at": "2026-11-24T10:41:27.903Z",
  "limit_reset_at": "2026-12-01T00:00:00Z",
  "parent_key_id": "key_0000b694",
  "revoked_at": null
}
```

**SDK Code**

```python Remove the request limit and the reset
import requests

url = "https://api.example.com/v1/keys/key_00003a89"

payload = { "max_requests": None }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript Remove the request limit and the reset
const url = 'https://api.example.com/v1/keys/key_00003a89';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"max_requests":null}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Remove the request limit and the reset
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1/keys/key_00003a89"

	payload := strings.NewReader("{\n  \"max_requests\": null\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Remove the request limit and the reset
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1/keys/key_00003a89")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"max_requests\": null\n}"

response = http.request(request)
puts response.read_body
```

```java Remove the request limit and the reset
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.example.com/v1/keys/key_00003a89")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"max_requests\": null\n}")
  .asString();
```

```php Remove the request limit and the reset
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.example.com/v1/keys/key_00003a89', [
  'body' => '{
  "max_requests": null
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Remove the request limit and the reset
using RestSharp;

var client = new RestClient("https://api.example.com/v1/keys/key_00003a89");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"max_requests\": null\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Remove the request limit and the reset
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["max_requests": ] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/keys/key_00003a89")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```