Creates a new key for an API token and sets all other keys to expire. The replacement key scope must be contained by the calling API token role, one of the session user roles, or the normalized workload role scope. Rotation outside that scope returns 403. The caller-expiry cap is deferred for rotation compatibility: non-delegated tokens can renew their configured lifetime, including six-month tokens, and replacement keys may outlive the caller. Delegated callers can rotate only their own token, regardless of role permissions. Delegated token expiry stays fixed: rotating its parent does not renew it. Delegated replacement keys remain bounded by that fixed token deadline.
Required permission
Account > Admin > ApiTokens > Update
Path parameters
tokenId
string requiredID of the API token
Request body
- {object}
otherKeysExpiresAt
stringExpiry time for all existing keys. Defaults to immediate expiry.
Response body
- {object}Response object.
data
{object} requiredResult data.key
{object} requiredThe newly created API key.id
string requiredUUID of the new API key.issuedAt
string requiredThe time the key was issued.token
string requiredThe API token for authentication.
POST /v1/tokens/{tokenId}/keys
POST /v1/teams/{teamId}/tokens/{tokenId}/keys
Example request
Request body
curl --header "Content-Type: application/json" \
--header "Authorization: Bearer NORTHFLANK_API_TOKEN" \
--request POST \
--data '{}' \
https://api.northflank.com/v1/tokens/{tokenId}/keysExample response
200 OK
The newly created API key and token.
JSON
{
"data": {
"key": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"issuedAt": "2021-01-20T11:19:53.175Z"
},
"token": "eyJhbGciOiJIUzI1NiIs..."
}
}