/policies/{bundleId}/publishPublish Policy
Atomically publishes a draft bundle, activating it as the project's live policy.
It validates the bundle, marks the previously published bundle as superseded, marks the draft published, and triggers Postgres RLS recompilation.
Requires PROJECT_ADMIN.
Returns K9O_POLICY_BUNDLE_INVALID (422) if validation fails at publish time, leaving the previously published bundle active.
A rule's requires_approval_from is checked for shape only: a role nobody holds yet still publishes, and nobody can approve its cases until someone holds it.
| bundleId * | path | The policy bundle id ( The |
| projectSlug * | path | The project's slug: the path segment after It is unique within the org. |
| acknowledgeSelfLockout | boolean | Set to true to publish a bundle that would take away your own read access to one or more collections. Without it such a publish is refused with 409 The approver sees the acknowledged lockout on the pending change. |
| HTTP | K9O Code | Description |
|---|---|---|
| 202 | Accepted | |
| 400 | K9O_POLICY_NESTING_TOO_DEEP | A policy rule in the bundle exceeds the maximum nesting depth of 20. |
| 400 | K9O_POLICY_UNKNOWN_OPERATOR | The bundle contains a policy rule with an unrecognised operator name. |
| 400 | K9O_POLICY_UNKNOWN_CONTEXT_FIELD | A subject or resource operand path in the bundle does not resolve to a known field. |
| 401 | K9O_SESSION_EXPIRED | The caller's session token is expired or invalid; re-authenticate to continue. |
| 403 | K9O_ACCESS_DENIED | The caller does not hold PROJECT_ADMIN role, which is required to publish a policy bundle. |
| 404 | K9O_POLICY_NOT_FOUND | No policy bundle with the supplied identifier exists in this project. |
| 409 | K9O_POLICY_PUBLISH_CONFLICT | The bundle is already published or superseded and cannot be re-published. |
| 422 | K9O_POLICY_BUNDLE_INVALID | The bundle fails validation at publish time, for example because a referenced schema column was dropped since the draft was created. |
| data * | object | A publish waiting for approval. Nothing is in force yet. |
| pendingChangeId * | string | The id of the queued publish ( A different project admin approves or rejects it through the pending-approvals endpoints. |
| bundleId * | string | The bundle waiting to be published ( |
| status * | "pending_approval" | Always |
| meta * | any |
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.policies.publish('pol_demo00000001', {})Showing example in TypeScript
{
"acknowledgeSelfLockout": false
}{
"data": {
"pendingChangeId": "string",
"bundleId": "string",
"status": "pending_approval"
}
}