Rotate API Key
PUT /api/v1/gateway/keys/{key_id}/rotate
Issues a new key to replace an existing one. The old key keeps working until the grace period ends, allowing a smooth cutover. The full new key is returned only once, in this response. Requires an admin-or-above role (admin / ops / super).
Auth: this endpoint belongs to the console backend API (base URL
https://portal.aiin1.ai— note, notapi.portal.aiin1.ai). It requires anaccess_tokenobtained by logging in with a console account (valid 15 minutes); thesk-nex-API token does not work here. See Billing Reconciliation & Automated Usage Sync for the login flow.
Request parameters
| Param | In | Type | Required | Description |
|---|---|---|---|---|
key_id |
path | string(uuid) | yes | Key ID |
Example
curl -X PUT https://portal.aiin1.ai/api/v1/gateway/keys/KEY_ID/rotate \
-H "Authorization: Bearer $ACCESS_TOKEN"Response
| Field | Type | Required | Description |
|---|---|---|---|
new_key_id |
string(uuid) | yes | New key ID |
new_key |
string | null | no | Full new key, shown once |
new_key_prefix |
string | yes | New key prefix |
old_key_id |
string(uuid) | yes | Old key ID |
old_key_grace_until |
string(datetime) | yes | When the old key stops working (grace-period end) |
message |
string | no | Message |