Create API key
Creates a new tenant API key.
POST /api/v1/keys
The caller must use a key with the management scope. The new key is automatically owned by the calling key's owner. This endpoint cannot grant management; any active Portal user can configure their own active key, while a Workspace Owner can configure active keys owned by other tenant members.
Back to API keys endpoint listRequest parameters
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | Key name for team identification. |
scopes | string[] | No | Business scopes, such as chat, models, or tasks; management is not allowed. |
allowed_models | string[] | No | List of allowed GlobalRouter model IDs. |
blocked_models | string[] | No | List of blocked model IDs. |
allowed_ips | string[] | No | Source IP allowlist. |
rate_limit_per_minute | integer | No | Per-minute rate limit. |
expires_at | string | No | Expiration time; ISO 8601 is recommended. |
Request examples
curl "https://api.globalrouter.com/api/v1/keys" \
-H "Authorization: Bearer $GR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "production-chat-key",
"scopes": ["chat", "models"],
"allowed_models": ["qwen3-32b"],
"blocked_models": ["legacy-model"],
"allowed_ips": ["203.0.113.10"],
"rate_limit_per_minute": 120,
"expires_at": "2026-12-31T23:59:59Z"
}'Response fields
| Field | Type | Required | Description |
|---|---|---|---|
data.id | string | Yes | API key record ID. |
data.api_key | string | Yes | Plaintext value of the new key, returned only once in the creation response. |
data.tenant_id | string | Yes | Tenant ID owning the key. |
data.name | string | Yes | Key name. |
data.key_prefix | string | Yes | Key prefix for identification and troubleshooting. |
data.scopes | string[] | Yes | Scopes. |
data.status | string | Yes | active, disabled, or revoked. |
data.allowed_models | string[] | No | Model allowlist. |
data.blocked_models | string[] | No | Model blocklist. |
data.allowed_ips | string[] | No | Source IP allowlist. |
data.rate_limit_per_minute | integer | No | Current rate limit. |
data.expires_at | string | No | Expiration time. |
data.last_used_at | string | No | Last-used time. |
Response example
{
"data": {
"id": "key_123",
"api_key": "<shown-once>",
"tenant_id": "tenant_123",
"name": "production-chat-key",
"key_prefix": "gr_live",
"scopes": ["chat", "models"],
"status": "active",
"allowed_models": ["qwen3-32b"],
"blocked_models": ["legacy-model"],
"allowed_ips": ["203.0.113.10"],
"rate_limit_per_minute": 120,
"expires_at": "2026-12-31T23:59:59+00:00",
"last_used_at": null
}
}