Skip to content

Publish a policy

View as Markdown
POST
/v1/policies
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 tenant 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). 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).

Idempotency-Key
string
>= 1 characters

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).

Media typeapplication/json
object
id
required
string
>= 1 characters
tenantId

Optional. When present, must match the caller tenant (server-derived from the token). Cross-tenant publish is rejected.

string format: uuid
version
required
string
/^\d+\.\d+\.\d+$/
kind
required
string
Allowed values: access-control model-routing adapter-allowlist rate-limit retention compliance tool-errors hitl
description
string
spec
required
object
key
additional properties
any

Policy published.

Media typeapplication/json
object
policyId
required
string
version
required
string
Examplegenerated
{
"policyId": "example",
"version": "example"
}

Validation failed (see details.issues), or kind-not-applied: no runtime consumer applies that kind yet.

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"
}
}

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.

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"
}
}

The request body is over the API’s limit (request-too-large; details.maxBytes says how much).

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"
}
}

See also