Publish a policy
const url = 'https://example.com/v1/policies';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"id":"example","tenantId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","version":"example","kind":"access-control","description":"example","spec":{}}'};
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/policies \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "id": "example", "tenantId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "version": "example", "kind": "access-control", "description": "example", "spec": {} }'Body is a full Policy — the server validates top-level shape (id, tenantId, semver version, kind ∈ closed enum, spec is an object), and spec for tool-errors, hitl and retention (a retention policy with an unknown domain or mode: archive is refused with 400 validation-failed, naming the field). Other kinds’ specs are their runtime consumer’s to validate. Re-publishing an existing (policyId, version) returns 409 policy-already-registered. A workspace has one retention policy per domain, plus one for *: a second policy id for a covered domain is refused with 409 policy-scope-taken (details.heldBy names the policy that covers it; publish a new version of that one instead), and a new version can’t move a policy to another domain (409 policy-scope-changed). Where this server has a retention limit for a domain, a policy for that domain that keeps its rows longer, or holds them (graceSeconds: -1), is refused with 400 retention-over-limit (details.limitSeconds is the limit); a * policy isn’t, as the server caps each limited domain when it sweeps. A known kind that no runtime consumer applies yet (access-control, adapter-allowlist, rate-limit, compliance) is refused with 400 kind-not-applied (details.appliedKinds lists the ones that are): publishing it would change nothing. Idempotency-Key applies (retries with the same key replay the original 201).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Responses
Section titled “Responses”Policy published.
object
Examplegenerated
{ "policyId": "example", "version": "example"}Validation failed (see details.issues); kind-not-applied: no runtime consumer applies that kind yet; or retention-over-limit: the retention policy keeps its domain’s rows longer than this server’s limit, or holds them (details.limitSeconds).
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" }}Not a tenant admin (permission-denied). Without an authorization store, a tenant admin is the deployment’s API token, an admin key, or a console signed in with either.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}policy-already-registered: that (id, version) exists. policy-scope-taken: another policy covers the retention domain (details.heldBy). policy-scope-changed: the version would move the policy to another domain. 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" }}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 Idempotency-Key store (idempotency-store-unavailable) or the authorization store (authz-backend-unavailable) couldn’t be reached before the request ran, or the database was too busy for its authorization check (database-busy), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key. 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/policies: List workspace policies- Error code
authz-backend-unavailable - Error code
database-busy - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
kind-not-applied - Error code
permission-denied - Error code
policy-already-registered - Error code
policy-scope-changed - Error code
policy-scope-taken - Error code
rate-limit-exceeded - Error code
request-too-large - Error code
retention-over-limit - Error code
tenant-state-unavailable - Every error code