Rotate an API key
POST
/api/settings/service-accounts/{id}/keys/{keyId}/rotate
const url = 'https://forge.example.com/api/settings/service-accounts/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/keys/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/rotate';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"overlapDays":1,"days":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”id
required
string format: uuid
keyId
required
string format: uuid
Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
overlapDays
required
null | integer | string format: int32
days
required
null | integer | string format: int32
Example generated
{ "overlapDays": 1, "days": 1}Responses
Section titled “Responses”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"}default
Section titled “default”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"}