Skip to main content
POST
/
v2
/
voice-agents
Create Voice Agent
curl --request POST \
  --url https://api.tryhamsa.com/v2/voice-agents \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Customer Support Agent",
  "type": "Single Prompt",
  "conversation": {
    "greetingMessage": "Welcome! How may I assist you?",
    "greetingMessageType": "TEXT",
    "preamble": "You are a customer support assistant.",
    "pokeMessages": [
      "Are you still there?"
    ],
    "params": {},
    "alignment": {
      "greetingMessage": "ltr",
      "preamble": "ltr"
    }
  },
  "voice": {
    "voiceId": "en-US-Neural2-A",
    "lang": "en"
  },
  "llm": {
    "provider": "openai",
    "model": "gpt-4",
    "temperature": 0.7,
    "baseUrl": "https://api.example.com",
    "apiKey": "sk-..."
  },
  "callSettings": {
    "noiseCancellation": "telephony_optimized",
    "cancelNoisePer": "conversation",
    "interrupt": true,
    "responseDelay": 400,
    "minInterruptionDuration": 0.5,
    "vadActivationThreshold": 0.5,
    "userInactivityTimeout": 15,
    "maxCallDuration": 300,
    "silenceThreshold": 800,
    "backgroundNoise": false,
    "enableAutoGainControl": false,
    "sendDenoisedToStt": false,
    "waitForUserToSpeakFirst": 0,
    "thinkingVoice": false,
    "speakerIdentification": false,
    "agenticRag": false,
    "languageDialectSwitcher": false,
    "genderDetection": false,
    "smartCallEnd": false
  },
  "tools": [],
  "knowledgeBaseItemsIds": [
    "48f7656f-098b-4c43-b165-7cfd2cc8ac30"
  ],
  "voiceDictionaryIds": [
    "48f7656f-098b-4c43-b165-7cfd2cc8ac30"
  ],
  "phoneNumber": {
    "type": "TWILIO",
    "id": "48f7656f-098b-4c43-b165-7cfd2cc8ac30"
  },
  "webhookUrl": "https://example.com/webhook",
  "webhookAuth": {},
  "workflow": {},
  "outcomeResponseShape": {}
}
'
{
  "success": true,
  "message": "Voice agent created successfully",
  "messageKey": "VoiceAgentCreatedSuccessfully",
  "data": {
    "id": "48f7656f-098b-4c43-b165-7cfd2cc8ac30",
    "type": "Single Prompt",
    "name": "Customer Support Agent",
    "conversation": {
      "greetingMessage": "Hello, how can I help you today?",
      "greetingMessageType": null,
      "preamble": "You are a helpful assistant.",
      "pokeMessages": [],
      "params": {},
      "alignment": {
        "greetingMessage": "ltr",
        "preamble": "ltr"
      }
    },
    "voice": {
      "voiceId": "en-US-Neural2-A",
      "voiceRecordId": null,
      "voiceRecord": {
        "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "name": "<string>",
        "provider": "<string>",
        "language": "<string>",
        "image": "<string>",
        "languageCode": "<string>",
        "voiceRecord": {}
      },
      "lang": "en",
      "ttsParams": {}
    },
    "llm": {
      "provider": "openai",
      "model": "gpt-4",
      "temperature": 0.2,
      "baseUrl": null,
      "apiKey": null
    },
    "callSettings": {
      "noiseCancellation": "telephony_optimized",
      "cancelNoisePer": "conversation",
      "interrupt": true,
      "responseDelay": 400,
      "userInactivityTimeout": 15,
      "maxCallDuration": 300,
      "silenceThreshold": 800,
      "backgroundNoise": false,
      "thinkingVoice": false,
      "speakerIdentification": false,
      "agenticRag": false,
      "languageDialectSwitcher": false,
      "minInterruptionDuration": 0.5,
      "vadActivationThreshold": 0.5,
      "enableAutoGainControl": false,
      "sendDenoisedToStt": false,
      "genderDetection": false,
      "smartCallEnd": false,
      "waitForUserToSpeakFirst": 0
    },
    "tools": [
      {}
    ],
    "knowledgeBaseItemsIds": [],
    "voiceDictionaryIds": [],
    "phoneNumber": {
      "type": "TWILIO",
      "id": "48f7656f-098b-4c43-b165-7cfd2cc8ac30"
    },
    "webhookUrl": null,
    "webhookAuth": {},
    "workflow": {},
    "outcomeResponseShape": {},
    "resolvedWebTools": [
      {}
    ],
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-01-15T10:30:00Z",
    "account": {
      "plan": "pro"
    }
  }
}

Authorizations

Authorization
string
header
required

Pass the API key in the Authorization header, You need to put Token keyword before the API key. e.g. 'Authorization: Token '

Body

application/json
name
string
required

Name of the voice agent (max 150 characters).

Maximum string length: 150
Example:

"Customer Support Agent"

type
enum<string>
default:Single Prompt

Type of voice agent.

Available options:
Single Prompt,
Flow Agent
Example:

"Single Prompt"

conversation
object

Conversation settings for the voice agent.

voice
object

Voice settings for the agent.

llm
object

LLM configuration.

callSettings
object

Call and audio settings.

tools
object[]

Web tools attached to the agent.

knowledgeBaseItemsIds
string<uuid>[]

Array of knowledge base item UUIDs.

Example:
["48f7656f-098b-4c43-b165-7cfd2cc8ac30"]
voiceDictionaryIds
string<uuid>[]

Array of voice dictionary UUIDs.

Example:
["48f7656f-098b-4c43-b165-7cfd2cc8ac30"]
phoneNumber
object

Phone number configuration.

webhookUrl
string<uri>

Webhook URL for external integrations.

Example:

"https://example.com/webhook"

webhookAuth
object

Webhook authentication configuration.

workflow
object

Workflow configuration for flow agents.

outcomeResponseShape
object

Expected outcome response structure.

Response

Successful response

success
boolean
Example:

true

message
string
Example:

"Voice agent created successfully"

messageKey
string
Example:

"VoiceAgentCreatedSuccessfully"

data
object

Voice agent data structure