curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/policies \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Refund policy",
"appliesIn": "PER_USER_RESPONSE",
"matchingExamples": "I want my money back. Can I get a refund? Cancel and refund me.",
"instructions": "Refunds are offered only within 14 days of purchase. Never promise a refund outside that window.",
"severity": "HIGH"
}
'{
"success": true,
"message": "success",
"data": {
"id": "a3f1c2d4-5b6e-4f70-8a91-b2c3d4e5f601",
"projectId": "fbb9e8b2-2dbb-40f9-a051-9404624e3247",
"userId": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"createdBy": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Refund policy",
"appliesIn": "PER_USER_RESPONSE",
"conditionsMatch": "ALL",
"conditions": [
{
"variable": "customer_tier",
"condition": "equals",
"value": "gold"
}
],
"matchingExamples": "I want my money back. Can I get a refund?",
"instructions": "Refunds are offered only within 14 days of purchase. Never promise a refund outside that window.",
"notes": "Reviewed by legal",
"severity": "HIGH",
"status": "PROCESSED",
"failureReason": null,
"createdAt": "2026-10-20T09:15:00.000Z",
"updatedAt": "2026-10-20T09:15:00.000Z"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Create Policy
Creates a policy: an instruction added to the model while it applies, on every turn (EVERY_TURN) or only when what the caller says matches it (PER_USER_RESPONSE). conditions limit it to calls whose variables match. The model follows it by meaning, so it is not guaranteed. Every policy belongs to the project: assign it to agents with PUT /v2/voice-agents/{voiceAgentId}/policies, or with policyIds when you create a v2 agent (updating an agent does not change its assignments). A change applies to every agent using it.
curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/policies \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Refund policy",
"appliesIn": "PER_USER_RESPONSE",
"matchingExamples": "I want my money back. Can I get a refund? Cancel and refund me.",
"instructions": "Refunds are offered only within 14 days of purchase. Never promise a refund outside that window.",
"severity": "HIGH"
}
'{
"success": true,
"message": "success",
"data": {
"id": "a3f1c2d4-5b6e-4f70-8a91-b2c3d4e5f601",
"projectId": "fbb9e8b2-2dbb-40f9-a051-9404624e3247",
"userId": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"createdBy": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "Refund policy",
"appliesIn": "PER_USER_RESPONSE",
"conditionsMatch": "ALL",
"conditions": [
{
"variable": "customer_tier",
"condition": "equals",
"value": "gold"
}
],
"matchingExamples": "I want my money back. Can I get a refund?",
"instructions": "Refunds are offered only within 14 days of purchase. Never promise a refund outside that window.",
"notes": "Reviewed by legal",
"severity": "HIGH",
"status": "PROCESSED",
"failureReason": null,
"createdAt": "2026-10-20T09:15:00.000Z",
"updatedAt": "2026-10-20T09:15:00.000Z"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}{
"code": 8404,
"message": "Policy not found!",
"messageKey": "PolicyNotFound",
"params": {
"reason": "NO_DRAFT"
}
}Authorizations
Body
EVERY_TURN: applies on every turn of the call. PER_USER_RESPONSE: applies only when what the caller says matches the rule, found by meaning (the name, instructions and matchingExamples are searched), so the exact words don't matter.
EVERY_TURN, PER_USER_RESPONSE Was this page helpful?