---
title: Update an API key
url: https://runapi.ai/docs/api/management/keys/update.md
canonical: https://runapi.ai/docs/api/management/keys/update
locale: en
---

# Update an API key

Update an existing Standard API key and retrieve its current usage summary.

## Endpoint

PATCH /api/v1/keys/:id

Base URL: https://runapi.ai

API version: v1

Authentication: Authorization: Bearer YOUR_MANAGEMENT_API_KEY


Authorization: Requires an account-admin Management API key and permits only keys owned by its user.

## Request

Send values only in the listed request location.

### JSON body

```json
{
  "allowed_models": {
    "description": "Replacement model allowlist; null or an empty array clears it.",
    "required": false,
    "type": "array | null"
  },
  "credit_limit_cents": {
    "description": "Spending cap in USD cents; null clears the cap and reset interval.",
    "required": false,
    "type": "integer | null"
  },
  "credit_limit_reset_interval": {
    "description": "Reset cadence for the spending cap.",
    "enum": [
      "daily",
      "weekly",
      "monthly"
    ],
    "required": false,
    "type": "string | null"
  },
  "enabled": {
    "description": "Whether requests using this key are accepted.",
    "required": false,
    "type": "boolean"
  },
  "name": {
    "description": "Replacement friendly name for the API key.",
    "required": false,
    "type": "string"
  }
}
```

### Path parameters

```json
{
  "id": {
    "description": "API key prefix ID, for example token_123.",
    "required": true,
    "type": "string"
  }
}
```

## Success response

HTTP 200 - PATCH /api/v1/keys/:id

```json
{
  "allowed_models": [
    "gpt-5.4"
  ],
  "created_at": "2026-07-27T10:00:00.000Z",
  "credit_limit_cents": 1000,
  "credit_limit_reset_interval": "daily",
  "credit_usage_cents_by_model": {
    "gpt-5.4": 250
  },
  "credit_usage_cents_this_month": 250,
  "credit_usage_cents_this_week": 100,
  "credit_usage_cents_today": 25,
  "credit_usage_cents_total": 250,
  "enabled": true,
  "guardrail_id": "guardrail_123",
  "id": "token_123",
  "last_used_at": null,
  "masked_token": "runapi_abc...wxyz",
  "name": "Production primary"
}
```

## Error response (401)

HTTP 401

```json
{
  "error": "Authentication required"
}
```

## Error response (403)

HTTP 403

```json
{
  "error": "Management API key required"
}
```

## Error response (403)

HTTP 403

```json
{
  "error": "Account admin required"
}
```

## Error response (400)

HTTP 400

```json
{
  "error": "page must be an integer"
}
```

## Error response (404)

HTTP 404

```json
{
  "error": "Resource not found"
}
```

## Error response (422)

HTTP 422

```json
{
  "errors": {
    "base": [
      "Validation failed"
    ]
  }
}
```

## cURL example



### curl

```curl
curl -X PATCH https://runapi.ai/api/v1/keys/token_123 \
  -H 'Authorization: Bearer YOUR_MANAGEMENT_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Production primary","enabled":true}'
```

## Related reference

- [API Keys](/docs/api/management/keys)
- [API Key object](/docs/api/management/keys/object)
