Update the Policy draft
PATCH /v1/policies/{policy_id}
| Property | Value |
|---|---|
| Operation | update_policy |
| Group | Policies |
| Scope | policies:write |
| Route class | control |
| Idempotency | No Idempotency-Key |
| Audit | Audited policy.update (mutation) |
| Released in | 1.47.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Replaces the named fields of the draft at the revision If-Match names and lints the document again. enabled is the kill switch: it lives on the Policy, is read at dispatch and takes effect from the next Call without a publish. An archived Policy is refused with policy_archived. A write to an organization-scoped Policy, or one that disables a compliance-tagged Policy, also needs policies:admin and is otherwise refused with forbidden and the detail policies_admin_required.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the policies:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X PATCH "$VOCAL_API/v1/policies/pol_..." \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H 'If-Match: "1"' \
-H "Content-Type: application/json" \
-d '{}'const response = await fetch(`${process.env.VOCAL_API}/v1/policies/pol_...`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'If-Match': '"1"',
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
console.log(response.status, await response.text());import os
import requests
response = requests.patch(
f"{os.environ['VOCAL_API']}/v1/policies/pol_...",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"If-Match": '"1"',
},
json={},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
policy_id | path | PolicyId | yes | The id of a Policy: pol_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log. |
if-match | header | string | yes | The revision the change was made against, quoted as the ETag returns it, or * to overwrite. |
Request body
Content type application/json, required: PolicyUpdateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
action_type | PolicyActionType | no | |
compliance_tag | ComplianceTag or null | no | |
description | string or null | no | For reviewers; never sent to the model. |
enabled | boolean | no | |
hook | HookPoint | no | |
logic | JdmDocumentInput | no | Replaces the whole document. The JDM document under the Vocal profile: its input is the hook's Call context and it writes the parameters of the action type under action, or nothing. Every save and publish lints it (policyLint); an error refuses with 422 validation_failed. |
name | PolicyName | no | |
priority | integer | no | |
scope | PolicyScope | no |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
200 | application/json | Policy | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
404 | application/json | ErrorEnvelope | not_found |
409 | application/json | ErrorEnvelope | policy_archived |
412 | application/json | ErrorEnvelope | revision_mismatch |
422 | application/json | ErrorEnvelope | validation_failed, capability_not_available |
428 | application/json | ErrorEnvelope | precondition_required |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 200 answer
The shape is Policy.
| Field | Type | Required | Description |
|---|---|---|---|
action_type | PolicyActionType | yes | The one action type the document may output; its legality at hook is checked at save. |
active_version | integer or null | yes | The version Agent version publish pins (agent scope) or dispatch resolves (organization scope), or null when none is active. |
analysis | PolicyAnalysis | yes | |
archived_at | Timestamp or null | yes | When DELETE archived the Policy, or null. An archived Policy takes no write, publish or activation (409 policy_archived); its pinned versions keep running. |
compliance_tag | ComplianceTag or null | yes | |
created_at | Timestamp | yes | |
description | string or null | yes | For reviewers; never sent to the model. |
enabled | boolean | yes | The kill switch, read at dispatch and effective from the next Call; not part of any version. |
hook | HookPoint | yes | |
id | PolicyId | yes | |
latest_version | integer or null | yes | The highest published version, or null before the first publish. |
logic | JdmDocument | yes | |
name | PolicyName | yes | |
object | "policy" | yes | |
organization_id | OrganizationId | yes | |
origin | PolicyOrigin | yes | |
priority | integer | yes | Lower runs first; ties go to organization scope, then to the id. |
revision | integer | yes | Counts writes to the draft; returned as the ETag and required in If-Match. |
scope | PolicyScope | yes | |
setting_path | SettingPath or null | yes | For a derived Policy, the setting it was compiled from; null when authored. |
updated_at | Timestamp | yes |