curl --request POST \
--url https://api.tryhamsa.com/v2/voice-agents/guardrails \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "No passwords",
"appliesIn": "EVERY_TURN",
"checksIn": "CALLER_SAYS",
"callerAgentCheck": {
"caller": {
"lookFor": "PATTERN",
"lookForValue": "\\b(password|pin)\\b",
"behaviour": "MESSAGE",
"behaviourValue": "I can't take passwords over the phone."
}
},
"mode": "ENFORCE",
"instructions": "Never ask for or repeat a password or PIN.",
"severity": "CRITICAL"
}
EOF{
"success": true,
"message": "success",
"data": {
"id": "6e2b9c41-7d3a-4f58-9b12-c4d5e6f70812",
"projectId": "fbb9e8b2-2dbb-40f9-a051-9404624e3247",
"userId": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"createdBy": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "No passwords",
"appliesIn": "EVERY_TURN",
"conditionsMatch": "ALL",
"conditions": [
{
"variable": "channel",
"condition": "is_not",
"value": "internal"
}
],
"checksIn": "CALLER_SAYS",
"callerAgentCheck": {
"caller": {
"lookFor": "PATTERN",
"lookForValue": "\\b(password|pin)\\b",
"behaviour": "MESSAGE",
"behaviourValue": "I can't take passwords over the phone."
}
},
"mode": "ENFORCE",
"matchingExamples": null,
"instructions": "Never ask for or repeat a password or PIN.",
"notes": null,
"severity": "CRITICAL",
"status": null,
"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 Guardrail
Creates a guardrail: a check on the caller’s words, the agent’s replies or both. When the check matches (words, a pattern, or a function or macro), it can say a line, hang up with an optional goodbye line, or run a function or macro. In MONITOR mode it only records when it would fire; in ENFORCE mode it acts. Its instructions are also added to the model so it avoids the problem in the first place. Every guardrail belongs to the project: assign it to agents with PUT /v2/voice-agents/{voiceAgentId}/guardrails, or with guardrailIds 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/guardrails \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"name": "No passwords",
"appliesIn": "EVERY_TURN",
"checksIn": "CALLER_SAYS",
"callerAgentCheck": {
"caller": {
"lookFor": "PATTERN",
"lookForValue": "\\b(password|pin)\\b",
"behaviour": "MESSAGE",
"behaviourValue": "I can't take passwords over the phone."
}
},
"mode": "ENFORCE",
"instructions": "Never ask for or repeat a password or PIN.",
"severity": "CRITICAL"
}
EOF{
"success": true,
"message": "success",
"data": {
"id": "6e2b9c41-7d3a-4f58-9b12-c4d5e6f70812",
"projectId": "fbb9e8b2-2dbb-40f9-a051-9404624e3247",
"userId": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"createdBy": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"name": "No passwords",
"appliesIn": "EVERY_TURN",
"conditionsMatch": "ALL",
"conditions": [
{
"variable": "channel",
"condition": "is_not",
"value": "internal"
}
],
"checksIn": "CALLER_SAYS",
"callerAgentCheck": {
"caller": {
"lookFor": "PATTERN",
"lookForValue": "\\b(password|pin)\\b",
"behaviour": "MESSAGE",
"behaviourValue": "I can't take passwords over the phone."
}
},
"mode": "ENFORCE",
"matchingExamples": null,
"instructions": "Never ask for or repeat a password or PIN.",
"notes": null,
"severity": "CRITICAL",
"status": null,
"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?