Skip to main content
PATCH
/
api
/
v1
/
keys
/
{hash}
curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production-backend-v2",
    "limit": 200,
    "limit_reset": "monthly",
    "allowed_providers": ["openai", "anthropic", "google"],
    "allowed_models": ["openai/gpt-5.4", "anthropic/claude-sonnet-4.6", "google/gemini-2.5-flash"]
  }'
import requests

resp = requests.patch(
    "https://api.arouter.ai/api/v1/keys/KEY_HASH",
    headers={"Authorization": "Bearer lr_mgmt_xxxx"},
    json={
        "name": "production-backend-v2",
        "limit": 200,
        "limit_reset": "monthly",
        "allowed_providers": ["openai", "anthropic", "google"],
    },
)
print(resp.json())
updated, err := client.UpdateKey(ctx, "KEY_HASH", &arouter.UpdateKeyRequest{
    Name:             stringPtr("production-backend-v2"),
    Limit:            float64Ptr(200),
    LimitReset:       stringPtr("monthly"),
    AllowedProviders: []string{"openai", "anthropic", "google"},
})
const updated = await router.updateKey("KEY_HASH", {
  name: "production-backend-v2",
  limit: 200,
  limit_reset: "monthly",
  allowed_providers: ["openai", "anthropic", "google"],
});
console.log(updated.data.name); // "production-backend-v2"
curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "production-backend-v2",
    "limit": 200,
    "limit_reset": "monthly",
    "allowed_providers": ["openai", "anthropic", "google"],
    "allowed_models": ["openai/gpt-5.4", "anthropic/claude-sonnet-4.6", "google/gemini-2.5-flash"]
  }'
import requests

resp = requests.patch(
    "https://api.arouter.ai/api/v1/keys/KEY_HASH",
    headers={"Authorization": "Bearer lr_mgmt_xxxx"},
    json={
        "name": "production-backend-v2",
        "limit": 200,
        "limit_reset": "monthly",
        "allowed_providers": ["openai", "anthropic", "google"],
    },
)
print(resp.json())
updated, err := client.UpdateKey(ctx, "KEY_HASH", &arouter.UpdateKeyRequest{
    Name:             stringPtr("production-backend-v2"),
    Limit:            float64Ptr(200),
    LimitReset:       stringPtr("monthly"),
    AllowedProviders: []string{"openai", "anthropic", "google"},
})
const updated = await router.updateKey("KEY_HASH", {
  name: "production-backend-v2",
  limit: 200,
  limit_reset: "monthly",
  allowed_providers: ["openai", "anthropic", "google"],
});
console.log(updated.data.name); // "production-backend-v2"
All fields in the request body are optional — only include the fields you want to change.

Disable / Enable a Key

curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx" \
  -H "Content-Type: application/json" \
  -d '{"disabled": true}'
Disabled keys immediately stop accepting requests. Set disabled: false to re-enable.

Update Spending Limits

curl -X PATCH https://api.arouter.ai/api/v1/keys/KEY_HASH \
  -H "Authorization: Bearer lr_mgmt_xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "limit": 500,
    "limit_reset": "monthly"
  }'
Set limit to null to remove the spending cap. The limit_reset field controls when the counter resets: daily (midnight UTC), weekly (Monday midnight UTC), or monthly (1st of month midnight UTC). Set to null for a lifetime cap.