Rotate a secret (sync or async)
const url = 'https://example.com/v1/secrets/example/rotate?scopeKind=tenant';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"scope":{"kind":"tenant","tenantId":"example"},"envName":"example","newValue":"example","revokeOldAfterMs":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://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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Query Parameters
Section titled “Query Parameters”Header Parameters
Section titled “Header Parameters”Request Body
Section titled “Request Body”object
Responses
Section titled “Responses”Sync rotation complete.
object
Example
{ "kind": "sync"}Async rotation accepted; poll or subscribe.
object
Example
{ "kind": "async"}A body that fails validation (bad-input), or a rotation the store refuses as it would the write: secret-value-too-large for a new value over its size limit, or reserved-name-prefix for a kindgi. name.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Bearer token missing secrets:rotate capability. Without an authorization store, key-project-mismatch (details.keyProjectId): the API key or session is limited to a project, and this writes above it, to the workspace, an org or a team (with a store, that is permission-denied).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Unknown secret (secret-not-found). secret-revoked: the secret is revoked, so it can’t be rotated. Or a hard revoke of it overtook the rotate, so what it wrote isn’t served; the message says what becomes of that value.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Idempotency-Key was reused with a different body, or resource-state conflict. Or env-not-served: this runtime keeps every value under the env it serves (whoami’s servedEnv, with refusesOtherEnvs), so a value under another env would never be read. details.envName is the env asked for, details.servedEnv the one to use. A secret that a provider, MCP endpoint or webhook endpoint registered before names under that env, at the scope it’s read at, is still written: it’s read there. Nothing is stored otherwise. Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}secret-provider-rate-limited: the secrets store’s external provider is limiting the runtime’s requests. Or rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Server error (unmapped domain code or framework crash).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The store doesn’t rotate (secret-operation-unsupported): under kindgi dev secrets live in the env files and have no versions; the message says what to do instead.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}secret-provider-unauthorized: the secrets store’s external provider refused the runtime’s credentials.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}secret-provider-unavailable: the secrets store’s external provider can’t be reached. idempotency-store-unavailable (with Retry-After): the Idempotency-Key store couldn’t be read before the request ran, so nothing was changed. authz-backend-unavailable (with Retry-After): the authorization store couldn’t be reached, so the request wasn’t run. database-busy (with Retry-After): the database was too busy for the authorization check, so the request wasn’t run. Or tenant-state-unavailable (with Retry-After), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”See also
GET /v1/secrets/{name}: Get secret metadataDELETE /v1/secrets/{name}: Revoke a secretGET /v1/secrets/{name}/versions: List secret versionsGET /v1/secrets/{name}/versions/{versionId}: Get one secret-version record- Store a secret
- Kindgi 0.6.0
- Error code
authz-backend-unavailable - Error code
bad-input - Error code
database-busy - Error code
env-not-served - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
key-project-mismatch - Error code
permission-denied - Error code
rate-limit-exceeded - Error code
request-too-large - Error code
reserved-name-prefix - Error code
secret-not-found - Error code
secret-operation-unsupported - Error code
secret-provider-rate-limited - Error code
secret-provider-unauthorized - Error code
secret-provider-unavailable - Error code
secret-revoked - Error code
secret-value-too-large - Error code
tenant-state-unavailable - Every error code