Skip to main content

Create agent

Creates a new agent in your company. When you use a Specific agents key, the new agent is automatically added to that key's allowed list, so you can manage it right away.

Endpoint

POST /v1/agents

Request body

{
"name": "API Test Agent",
"greeting": "Hello!",
"prompt": "You are a helpful assistant.",
"farewell": "Goodbye!",
"voiceId": "YOUR_VOICE_ID",
"outputVariables": [
{
"name": "customerName",
"description": "The caller's full name",
"type": "string"
}
]
}

Parameters

FieldTypeRequiredDescription
namestringYesAgent name (must not be empty).
greetingstringNoOpening message the agent says when the call starts.
promptstringNoSystem prompt that defines the agent behavior.
farewellstringNoClosing message said at the end of the call.
voiceIdstringNoVoice identifier for the agent.
outputVariablesarrayNoVariables to capture during the call. See below.

outputVariables items

FieldTypeRequiredDescription
namestringYesVariable name.
descriptionstringNoWhat the variable represents.
typestringNoVariable data type (e.g. string).
valuestringNoDefault value.
enumstring[]NoAllowed values, if restricted to a set.

Request example

curl -X POST "https://api.fonema.ai/v1/agents" \
-H "Authorization: Bearer YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"name": "API Test Agent",
"greeting": "Hello!",
"prompt": "You are a helpful assistant.",
"farewell": "Goodbye!",
"voiceId": "YOUR_VOICE_ID",
"outputVariables": []
}'

Response

Returns 201 Created:

{
"name": "API Test Agent",
"slug": "api-test-agent-x1y2z3w4",
"message": "Agent created successfully"
}

Use the returned slug to further configure the agent with Edit agent.

Errors

StatusDescription
400Invalid request body (e.g. missing name).
403No company is associated with the API key.