Key Management API
A Management Key is a management credential dedicated to programmatically managing Regular API Keys, with the prefix sk-mgmt-. The Base URL is https://tokenplus.net, and the authentication method is Authorization: Bearer sk-mgmt-xxx.
A Management Key can only call the 7 endpoints listed here and can only manage the current user's own Regular API Keys.
Supported Endpoints
| Method | Path | Function |
|---|---|---|
| GET | /v1/keys | Paginated query of Regular API Keys |
| POST | /v1/keys | Create a Regular API Key |
| GET | /v1/keys/{key_id} | Query Regular API Key details |
| PATCH | /v1/keys/{key_id} | Modify name, limit, and model policy |
| DELETE | /v1/keys/{key_id} | Delete a Regular API Key |
| POST | /v1/keys/{key_id}/toggle | Enable or disable a Regular API Key |
| GET | /v1/keys/{key_id}/usage | Query Regular API Key usage |
Unsupported Scenarios
A Management Key cannot:
- call model, task, file, or other business endpoints;
- call
/v1/modelsto query models; - call login-user, administrator, or legacy
/api/token/*endpoints; - create, query, modify, or delete other Management Keys;
- manage other users' Regular API Keys.
Management Keys can only be created and maintained by a user after logging into the site, on the Management → Management Keys page. The full key is displayed only once at creation.
General Request Conventions
| Item | Convention |
|---|---|
| Base URL | https://tokenplus.net |
| Auth header | Authorization: Bearer sk-mgmt-... |
| Write request type | Content-Type: application/json |
| Regular API Key identifier | key_... |
| Time format | UTC RFC 3339, e.g. 2026-08-04T08:00:00Z |
| Write request idempotency header | Idempotency-Key, optional, recommended, max 255 bytes |
The Management API only accepts Authorization Bearer authentication; it does not accept sessions, system access tokens, or Regular API Keys.
Rate Limit Policy
| Rate limit bucket | Default limit | Dimension |
|---|---|---|
| Auth attempts | 180 per 180 seconds | Source IP |
| Reads | 180 per 180 seconds | Management Key, user, source IP |
| Writes | 20 per 1200 seconds | Management Key, user, source IP |
| Usage queries | 10 per 1200 seconds | Management Key, user, source IP |
Exceeding any dimension returns 429 rate_limit_exceeded.
Regular API Key Data Structure
Main fields of the list and detail endpoints:
- Common Fields
- Idempotency and Safe Retry
| Field | Type | Description |
|---|---|---|
id | string | Regular API Key public ID, format key_... |
name | string | Key name |
key_type | string | Always regular |
key_preview | string | Masked preview, e.g. sk-abcd**********wxyz; not the full key |
status | string | active or disabled |
status_reason | string/null | Reason for unavailability: pending_subscription, expired, limit_exhausted, or manual |
disabled | boolean | Whether currently unavailable |
limit | number | Dollar limit; 0 means no limit |
limit_reset | string | never, daily, weekly, or monthly |
remaining | number/null | Remaining dollar limit in the current window; null when there is no limit |
created_at | string | UTC RFC 3339 creation time |
last_used_at | string/null | Most recent use time |
model_allowlist | string[] | Model allowlist returned by the detail endpoint |
model_blocklist | string[] | Model blocklist returned by the detail endpoint |
usage | number | Cumulative stored usage amount of the Regular API Key |
In the list and detail responses, status_reason is null when the status is active.
The following write endpoints support the Idempotency-Key header:
POST /v1/keysPATCH /v1/keys/{key_id}DELETE /v1/keys/{key_id}POST /v1/keys/{key_id}/toggle
Rules:
- The idempotency key is scoped to the Management Key, HTTP method, path, and the normalized request body.
- Replaying an equivalent request with the same idempotency key within 30 days returns the first result without duplicating the change. Changing only the JSON field order, whitespace, or line breaks does not form a different request.
- Using the same idempotency key for a different normalized request returns
409 idempotency_conflict. - The create response contains the Regular API Key plaintext; its encrypted replay content is retained for only 24 hours.
- Replaying after 24 hours but within 30 days of creation returns
409 idempotency_expiredand does not create the key again. - When a client cannot confirm the result, it should reuse the original idempotency key and the exact same request; new business operations must generate a new idempotency key.
Error Responses
- Error Format
- Status Codes and Error Codes
All Management API errors use a fixed structure:
{
"error": {
"code": "invalid_parameter",
"message": "Invalid JSON request body.",
"param": null,
"request_id": "req_..."
}
}
Callers should determine the error based on the HTTP status code and error.code, and must not match on the message text.
| HTTP status | error.code | Typical scenario |
|---|---|---|
| 400 | invalid_parameter | Parameter out of range, invalid JSON, unknown field, invalid date or cursor |
| 400 | unsupported_key_type | Attempting to use key_type=management |
| 401 | invalid_management_key | Management Key missing, malformed, unknown, disabled, or deleted, or the owning user is disabled |
| 404 | key_not_found | The target Regular API Key does not exist, does not belong to the current user, or has been deleted |
| 409 | conflict | Concurrent modification of limit policy or balance |
| 409 | key_limit_reached | The number of Regular API Keys has reached the applicable limit |
| 409 | idempotency_conflict | The idempotency key was used for a different request |
| 409 | idempotency_expired | The idempotent replay content has expired |
| 409 | usage_snapshot_expired | The usage snapshot expired or the retention watermark changed |
| 415 | invalid_parameter | The write endpoint Content-Type is not application/json |
| 422 | usage_query_too_large | The usage snapshot contains more than 1000 models |
| 429 | rate_limit_exceeded | Auth, read, write, usage query rate limiting, or concurrent usage limit |
| 500 | internal_error | Service internal error or fail-closed on Redis failure |
| 503 | management_api_disabled | The global Management API switch is off |
| 503 | usage_detail_unavailable | Consumption log details are unavailable |
| 504 | usage_query_timeout | Usage query exceeds 5 seconds |
To prevent credential probing, unknown, disabled, deleted, or malformed Management Keys, as well as cases where the owning user is disabled, use the same 401 invalid_management_key response.