Create a secret or add a version
const url = 'https://example.com/v1/secrets';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"scope":{"kind":"tenant","tenantId":"example"},"envName":"example","name":"example","value":"example","writeMode":"create-new","tags":{"additionalProperty":"example"},"rotationDueAt":"2026-04-15T12:00:00Z","ifVersion":1,"appEnvFile":true}'};
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 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "scope": { "kind": "tenant", "tenantId": "example" }, "envName": "example", "name": "example", "value": "example", "writeMode": "create-new", "tags": { "additionalProperty": "example" }, "rotationDueAt": "2026-04-15T12:00:00Z", "ifVersion": 1, "appEnvFile": true }'Accepts a plaintext value (as do POST /v1/secrets/:name/rotate via newValue and POST /v1/deployments/:deploymentId/secrets); every other secrets route is metadata-only. Requires the secrets:write capability. writeMode: create-new returns 201 with the record; add-version returns 200. Existing-secret conflicts on create-new return 409 secret-write-conflict.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Caller-supplied idempotency key, scoped to the caller: the same key from someone else in the tenant is their own request (from 0.1.5). Retries with the same key return the original response byte-identical (per docs/API-ROUTE-CONVENTIONS.md §3.1). A retry sent while the first request still runs is answered 409 idempotency-key-in-flight with Retry-After, on a runtime whose store holds keys (from 0.1.5); retry after it, and you get the first request’s answer. An answer that carries a secret (a new API key or public run token, a session token, a generated signing secret) isn’t kept: a retry gets 409 idempotency-key-replay-withheld, with the first request’s status and when it succeeded (from 0.1.5).
Request Bodyrequired
Section titled “Request Bodyrequired”object
Per-environment slug. [a-z][a-z0-9-]{0,62} — RFC-1035-like label.
A new secret name: 1 to 255 ASCII letters, digits, ., - and _, starting with a letter, digit or _, with any . between two non-. characters. The server holds a newly-created name to this shape (create-new, or an add-version of a name not yet stored); a name already stored outside this shape still reads, rotates and takes new versions.
object
Under kindgi dev only: write the app’s own env file (the last of dev.envFiles, .env.local by default) instead of Kindgi’s .kindgi/secrets.env, for a value the app reads too, such as a webhook signing secret. A runtime with a secrets store refuses it with bad-input.
Responses
Section titled “Responses”Version added (add-version).
object
object
Per-environment slug. [a-z][a-z0-9-]{0,62} — RFC-1035-like label.
object
Example
{ "record": { "scope": { "kind": "tenant" } }}Secret created (create-new).
object
object
Per-environment slug. [a-z][a-z0-9-]{0,62} — RFC-1035-like label.
object
Example
{ "record": { "scope": { "kind": "tenant" } }}A body that fails validation (bad-input), or a secret the store refuses for its name or its value: reserved-name-prefix, secret-name-invalid (a new name that isn’t 1 to 255 ASCII letters, digits, ., - and _ starting with a letter, digit or _, with any . between two non-. characters, or, under kindgi dev, isn’t capital letters, digits and underscores, starts with a digit, or is KINDGI_*; the message says the rule), secret-value-too-large, or secret-value-invalid (under kindgi dev, a value no env-file quoting can hold so that it reads back unchanged; the message says why).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Bearer token missing secrets:write capability.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
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.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
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.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Server error (unmapped domain code or framework crash).
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}secret-provider-unauthorized: the secrets store’s external provider refused the runtime’s credentials.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}secret-provider-unavailable: the secrets store’s external provider can’t be reached.
object
object
Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).
Optional, kind-specific.
object
Server-assigned request id; also echoed via X-Request-Id header.
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}See also
GET /v1/secrets: List secret metadata- Keep secrets in your own secret manager
- Kindgi 0.1.9
- Error code
bad-input - Error code
env-not-served - Error code
request-too-large - Error code
reserved-name-prefix - Error code
secret-name-invalid - Error code
secret-provider-rate-limited - Error code
secret-provider-unauthorized - Error code
secret-provider-unavailable - Error code
secret-value-invalid - Error code
secret-value-too-large - Every error code