VocalDocscontracts 1.65.0

Create a Policy draft

POST /v1/policies

PropertyValue
Operationcreate_policy
GroupPolicies
Scopepolicies:write
Route classcontrol
IdempotencyIdempotency-Key accepted: a retry with the same key replays the first answer
AuditAudited policy.create (mutation)
Released in1.47.0
Phase 0 hostServed (the hosted api pins 1.65.0)

Creates a Policy draft at revision 1. The document is linted under the Vocal profile at its hook and for its action type, and every error finding is a detail of 422 validation_failed, naming the node and the code; warnings return in analysis.warnings. A reserved action type (set_setting; raise_event until 1.58.0, record_opt_out until 1.61.0) is refused with capability_not_available. 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 POST "$VOCAL_API/v1/policies" \
  -H "Authorization: Bearer $VOCAL_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "h2-appointment-tools-require-verification",
    "hook": "on_call_start",
    "action_type": "block",
    "logic": {
      "nodes": [
        {
          "id": "<id>",
          "name": "<name>",
          "type": "inputNode"
        }
      ],
      "edges": []
    }
  }'

Parameters

NameInTypeRequiredDescription
idempotency-keyheaderstringnoA client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response.

Request body

Content type application/json, required: PolicyCreateRequest.

FieldTypeRequiredDescription
action_typePolicyActionTypeyes
compliance_tagComplianceTag or nullnoNull when omitted.
descriptionstringnoFor reviewers; never sent to the model.
enabledbooleannoTrue when omitted.
hookHookPointyes
logicJdmDocumentInputyesThe 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.
namePolicyNameyes
priorityintegerno500 when omitted.
scopePolicyScopenoagent when omitted.

Responses

StatusContent typeShapeError codes
201application/jsonPolicy
400application/jsonErrorEnvelopeinvalid_request
401application/jsonErrorEnvelopeunauthenticated
403application/jsonErrorEnvelopeforbidden, org_suspended
409application/jsonErrorEnvelopeidempotency_in_progress, idempotency_key_reused
422application/jsonErrorEnvelopevalidation_failed, capability_not_available
429application/jsonErrorEnveloperate_limited
500application/jsonErrorEnvelopeinternal_error

Fields of the 201 answer

The shape is Policy.

FieldTypeRequiredDescription
action_typePolicyActionTypeyesThe one action type the document may output; its legality at hook is checked at save.
active_versioninteger or nullyesThe version Agent version publish pins (agent scope) or dispatch resolves (organization scope), or null when none is active.
analysisPolicyAnalysisyes
archived_atTimestamp or nullyesWhen DELETE archived the Policy, or null. An archived Policy takes no write, publish or activation (409 policy_archived); its pinned versions keep running.
compliance_tagComplianceTag or nullyes
created_atTimestampyes
descriptionstring or nullyesFor reviewers; never sent to the model.
enabledbooleanyesThe kill switch, read at dispatch and effective from the next Call; not part of any version.
hookHookPointyes
idPolicyIdyes
latest_versioninteger or nullyesThe highest published version, or null before the first publish.
logicJdmDocumentyes
namePolicyNameyes
object"policy"yes
organization_idOrganizationIdyes
originPolicyOriginyes
priorityintegeryesLower runs first; ties go to organization scope, then to the id.
revisionintegeryesCounts writes to the draft; returned as the ETag and required in If-Match.
scopePolicyScopeyes
setting_pathSettingPath or nullyesFor a derived Policy, the setting it was compiled from; null when authored.
updated_atTimestampyes