Skip to content

Rotate a secret (sync or async)

POST
/v1/secrets/{name}/rotate
curl --request POST \
--url 'https://example.com/v1/secrets/example/rotate?scopeKind=tenant' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "scope": { "kind": "tenant", "tenantId": "example" }, "envName": "example", "newValue": "example", "revokeOldAfterMs": 1 }'

Requires the secrets:rotate capability. The scope comes from body scope, else from scopeKind + scopeId in the query; one of them is required, and when both are present they must name the same scope. Authorization checks that scope. Sync providers return 201 with { kind: "sync", newVersionId, oldVersionId, oldVersionRevokedAt? }. Async providers return 202 with { kind: "async", rotationId, statusUrl, eventsUrl }; poll via GET /v1/secrets/:name/rotations/:rotationId or subscribe via SSE at the events URL. kind is the discriminant.

name
required
string
>= 1 characters

Secret name (opaque string within the tenant + envName).

envName

Per-environment slug. [a-z][a-z0-9-]{0,62} — RFC-1035-like label.

string
/^[a-z][a-z0-9-]{0,62}$/

Alternative to body envName. When both are present they must match (400 env-name-mismatch).

scopeKind

Discriminator for the ?scopeKind + ?scopeId + ?inherit triplet. Tenant carries no id (implicit from session); org/project require scopeId.

string
Allowed values: tenant org project

Alternative to body scope (with scopeId). When both are present they must name the same scope (400 scope-mismatch).

scopeId
string
>= 1 characters

Required IF scopeKind is org or project. MUST be absent if scopeKind=tenant (tenant is implicit from the session). Malformed combinations return 400 scope-invalid.

Idempotency-Key
string
>= 1 characters

Caller-supplied idempotency key. Retries with the same key return the original response byte-identical (per docs/API-ROUTE-CONVENTIONS.md §3.1).

Media typeapplication/json
object
scope
One of:
object
kind
required
string
Allowed values: tenant
tenantId
required
string
envName

Per-environment slug. [a-z][a-z0-9-]{0,62} — RFC-1035-like label.

string
/^[a-z][a-z0-9-]{0,62}$/
newValue
string
revokeOldAfterMs
integer

Sync rotation complete.

Media typeapplication/json
object
kind
required
string
Allowed values: sync
newVersionId
required
integer
>= 1
oldVersionId
required
integer
>= 1
oldVersionRevokedAt
string format: date-time
Example
{
"kind": "sync"
}

Async rotation accepted; poll or subscribe.

Media typeapplication/json
object
kind
required
string
Allowed values: async
rotationId
required
string format: uuid
statusUrl
required
string
eventsUrl
required
string
Example
{
"kind": "async"
}

Malformed request body.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Missing / malformed / expired / revoked bearer token.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Bearer token missing secrets:rotate capability.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Unknown secret.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Idempotency-Key was reused with a different body, or resource-state conflict.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Server error (unmapped domain code or framework crash).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}