Skip to content

Rotate an API key

POST
/api/settings/service-accounts/{id}/keys/{keyId}/rotate
curl --request POST \
--url https://forge.example.com/api/settings/service-accounts/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/keys/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "overlapDays": 1, "days": 1 }'

Makes a new key with the same name and networks and answers it whole, this once. The old key keeps working for overlapDays, 0 to 7 (7 when left out), and no longer than it would have; with 0 it is revoked at once. An overlap needs the account to have no other live key. Never cached. Needs a step-up from the last 10 minutes (409 with stepUpNeeded). For administrators.

id
required
string format: uuid
keyId
required
string format: uuid
Media typeapplication/json
object
overlapDays
required
null | integer | string format: int32
/^-?(?:0|[1-9]\d*)$/
days
required
null | integer | string format: int32
/^-?(?:0|[1-9]\d*)$/

Example generated

{
"overlapDays": 1,
"days": 1
}

OK

Media typeapplication/json
object
key
required
object
id
required
string format: uuid
name
required
string
lastFour
required
string
createdAt
required
string format: date-time
createdBy
required
null | string
expiresAt
required
string format: date-time
revokedAt
required
null | string format: date-time
revokedBy
required
null | string
lastUsedAt
required
null | string format: date-time
lastUsedAddress
required
null | string
allowedNetworks
required
Array<string>
status
required
string
replaces
required
null | string format: uuid
secret
required
string

Example generated

{
"key": {
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"name": "example",
"lastFour": "example",
"createdAt": "2026-04-15T12:00:00Z",
"createdBy": "example",
"expiresAt": "2026-04-15T12:00:00Z",
"revokedAt": "2026-04-15T12:00:00Z",
"revokedBy": "example",
"lastUsedAt": "2026-04-15T12:00:00Z",
"lastUsedAddress": "example",
"allowedNetworks": [
"example"
],
"status": "example",
"replaces": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
},
"secret": "example"
}

A refusal or an error, as a problem document. A model or draft you may not see answers 404, as one that does not exist.

Media typeapplication/problem+json
object
type
string
title
string
status
integer
detail
string
instance
string

Example generated

{
"type": "example",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example"
}