Skip to content

keys.rotate

Rotate an API key

POST/keys/{id}/rotate

Operation
keys.rotate
MCP tool
not exposed over MCP

Replace a key with a new one carrying the same name, scopes and limits. The new plaintext is in the response and nowhere else. With graceSeconds, the old key keeps working for that long so a fleet can pick the new value up without an outage; with 0 it dies now. A grace window never extends a key that was already expiring sooner.

curl -X POST "https://api.gogoscreen.com/api/v1/keys/<id>/rotate" \
  -H "Authorization: Bearer $GOGOSCREEN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
The shape of a request to this operation. The dashboard sends it with the signed in person's session; an API key is refused.

At a glance

FactDetail
Scopeskeys:manage
Credentialsa signed in dashboard session. An API key cannot be granted these scopes, so this operation is reachable only from a signed in dashboard session.
Rate limit120 requests a minute per credential, in the write class.
IdempotencyRequired. Send an Idempotency-Key header; a retry with the same key and the same body returns the stored answer with Idempotent-Replayed: true. How idempotency works.
MCP toolNot exposed over MCP.
Always setsCache-Control: private, no-store
Verified emailRequired. An account whose email address is not verified meets 403 email_unverified before the operation runs.
AuditEvery call is written to the audit log as api_key_management.

Path parameters

NameTypeRequiredDescription
idstringRequiredThe resource id, from a create answer or the matching list.format: uuid

Request body

A JSON body is optional. Unknown fields are refused rather than ignored, so a typo is a 400 validation_failed rather than a setting that silently did nothing.

NameTypeRequiredDescription
graceSecondsintegerOptionalHow long the old key keeps working, up to a day. 0 revokes it immediately.Default 00–86400

Response

Answers 200. Every answer also carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset, and every error body carries a requestId.

200 OK

Rotate an API key

200 OK body
NameTypeDescription
apiKeyobject
12 fields inside apiKey
NameTypeDescription
createdAtstringformat: date-time
expiresAtstring | nullformat: date-time
idstring
last4stringThe last four characters, for telling two keys apart in a list.
lastUsedAtstring | nullWritten at most once a minute, so it is accurate to the minute and not to the request.format: date-time
namestring
prefixstringgsk_live_ plus the first eight characters of the secret. Enough to recognise a key; not enough to use one.
rateLimitPerDaynumber | nullA per-key daily cap. Null means uncapped by the key itself.
rateLimitPerMinutenumber | nullA per-key ceiling. Null means the rate class's own limit applies; a number can only ever lower it.
revokedAtstring | nullformat: date-time
scopesstring[]
statusstringone of: active, revoked, expired
keystringTHE KEY. This is the only time it is shown: it is never stored in readable form and cannot be recovered. Save it now; if it is lost, rotate.
previousobjectThe key that was replaced, as it now stands.
12 fields inside previous
NameTypeDescription
createdAtstringformat: date-time
expiresAtstring | nullformat: date-time
idstring
last4stringThe last four characters, for telling two keys apart in a list.
lastUsedAtstring | nullWritten at most once a minute, so it is accurate to the minute and not to the request.format: date-time
namestring
prefixstringgsk_live_ plus the first eight characters of the secret. Enough to recognise a key; not enough to use one.
rateLimitPerDaynumber | nullA per-key daily cap. Null means uncapped by the key itself.
rateLimitPerMinutenumber | nullA per-key ceiling. Null means the rate class's own limit applies; a number can only ever lower it.
revokedAtstring | nullformat: date-time
scopesstring[]
statusstringone of: active, revoked, expired
200 OK headers
HeaderMeaning
Cache-ControlAlways private, no-store.
Idempotent-ReplayedPresent only when this answer was stored by an earlier call with the same Idempotency-Key. Nothing new was done.

Errors

Every refusal is { error: { code, message, details?, requestId } }. Branch on code, never on the sentence. The full catalogue is at Errors.

CodeStatusWhen it happensWhat to do
idempotency_key_required400A mutating operation arrived over HTTP with no Idempotency-Key header. It is refused before the body is parsed, so a caller missing both learns about both at once.Add an Idempotency-Key header of up to 128 characters, unique to this request. Over MCP the same value goes in the idempotencyKey tool argument.
validation_failed400The merged path, query and body did not match the operation's schema. The schemas are strict, so an unknown field is a failure rather than something ignored, and a string carrying half of a character is refused before it can be stored.Read details.issues. Each entry carries a path, a message and a machine readable code. Fix every named field and send the request again; the same body always fails the same way.
unauthorized401No credential was presented, or the key is unknown, revoked or expired, or an X-API-Key header carried something that is not an API key. details.reason says which.Send Authorization: Bearer gsk_live_…. A revoked or expired key never starts working again, so issue a new one in the developer console. Put a dashboard session token in Authorization, never in X-API-Key.
email_unverified403The operation declares a verified email and the owning account's address is not verified. A key reads the account's current fact, not the fact that was true when the key was issued.Verify the address on the account, then retry. The key does not need to be reissued.
forbidden_scope403The credential does not carry every scope the operation declares, or it is the wrong kind of credential for it. keys.* and assistant.* are user only and can never be called by a key.details.requiredScopes and details.missingScopes name what is missing. A key's scopes cannot be changed after it is issued, so create a new key with them. When details.allowedActors is present, no key can call this operation at all.
not_found404No resource of that id belongs to this account. A resource that belongs to somebody else answers 404 as well, never 403.Check the id. Do not treat this as a permissions problem.
conflict409The request conflicts with the state the resource is in, and no more specific code applies.Re-read the resource and decide from its current state. Retrying the same request unchanged will not help.
idempotency_conflict409That idempotency key has already been used on this operation with a different request body.Use a fresh key for a different request. A key stands for one intent, not for one attempt.
idempotency_in_progress409The first request under that key is still being worked. Two concurrent identical requests both reach the store and one of them is told this.Wait the Retry-After seconds, which is 2, and send exactly the same request again with the same key. Do not change the body and do not mint a new key.
payload_too_large413The request body is over the transport's limit: 256 kb over HTTP, 1 mb over MCP.Send less. details.limit carries the limit. Version 1 has no upload operations, so a body this size is usually a mistake.
unsupported_media_type415The request carried a body whose Content-Type is not application/json, whose charset is not utf-8, or whose Content-Encoding this API does not decode. A body nobody can read would otherwise be silently discarded.Send Content-Type: application/json and utf-8 bytes. details names the charset, encoding or content type that was objected to.
rate_limited429The credential's per minute budget, the account's per minute ceiling, or a daily cap was exceeded. details.scope is minute, day or account, or global when the product's own daily cap on voice previews is spent.Wait the Retry-After seconds and retry. details.limit and details.resetAt say what was hit and when it reopens. The RateLimit-* headers on every answer let a client pace itself before it gets here.
internal_error500An unhandled failure inside this API. The original message is logged and never answered.Retry once, then quote requestId to support. A 5xx deletes the idempotency claim rather than storing it, so retrying under the same key is safe.