curl --request PUT \
--url https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/functions-macros \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"functionMacroIds": [
"9c1d2e3f-4a5b-4c6d-8e7f-0a1b2c3d4e5f",
"2b3c4d5e-6f70-4812-9a3b-4c5d6e7f8091"
]
}
'{
"success": true,
"message": "success",
"data": [
{
"id": "9c1d2e3f-4a5b-4c6d-8e7f-0a1b2c3d4e5f",
"projectId": "fbb9e8b2-2dbb-40f9-a051-9404624e3247",
"userId": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"createdBy": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"updatedBy": null,
"name": "has_card_number",
"notes": "Matches 13 to 19 digits in a row",
"type": "JAVASCRIPT_FUNCTION",
"usedAs": "CHECK",
"code": "return /\\d{13,19}/.test(text.replace(/[\\s-]/g, ''));",
"params": null,
"requiredParams": [
"name"
],
"createdAt": "2026-10-20T09:15:00.000Z",
"updatedAt": "2026-10-20T09:15:00.000Z",
"isActive": true
}
]
}{
"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"
}
}Functions & Macros
Set Agent Functions and Macros
Replaces the agent’s functions and macros with this list. New ones start active, ones already assigned keep their switch, ones left out are removed. An empty list removes all. The change is saved in your own draft, like Update Voice Agent: a test call of the draft uses it, and callers get it when the draft is published. Only active ones reach calls. Editing a function or macro itself still applies to every agent right away.
PUT
/
v2
/
voice-agents
/
{voiceAgentId}
/
functions-macros
curl --request PUT \
--url https://api.tryhamsa.com/v2/voice-agents/{voiceAgentId}/functions-macros \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"functionMacroIds": [
"9c1d2e3f-4a5b-4c6d-8e7f-0a1b2c3d4e5f",
"2b3c4d5e-6f70-4812-9a3b-4c5d6e7f8091"
]
}
'{
"success": true,
"message": "success",
"data": [
{
"id": "9c1d2e3f-4a5b-4c6d-8e7f-0a1b2c3d4e5f",
"projectId": "fbb9e8b2-2dbb-40f9-a051-9404624e3247",
"userId": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"createdBy": "b7d9e979-4a16-437b-8571-4ed92a94faa8",
"updatedBy": null,
"name": "has_card_number",
"notes": "Matches 13 to 19 digits in a row",
"type": "JAVASCRIPT_FUNCTION",
"usedAs": "CHECK",
"code": "return /\\d{13,19}/.test(text.replace(/[\\s-]/g, ''));",
"params": null,
"requiredParams": [
"name"
],
"createdAt": "2026-10-20T09:15:00.000Z",
"updatedAt": "2026-10-20T09:15:00.000Z",
"isActive": true
}
]
}{
"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
Path Parameters
Body
application/json
Was this page helpful?