> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.agentphone.ai/api-reference/agents/create-agent-v-1-agents-post/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.agentphone.ai/_mcp/server. # Create Agent POST https://api.agentphone.ai/v1/agents Content-Type: application/json Create a new agent. An agent represents an AI persona (Support Bot, Sales Agent, etc.) that can have phone numbers attached to it. voiceMode: "webhook" (default) forwards transcripts to your webhook. "hosted" uses a built-in LLM with systemPrompt (no webhook needed). Reference: https://docs.agentphone.ai/api-reference/agents/create-agent-v-1-agents-post ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Headers - `X-Sub-Account-Id` (string, optional) — Target a sub-account. Pass a sub-account ID to scope this request. Omit to use the master account. ### Body (application/json) This endpoint expects a CreateAgentRequest. - `name` (string, required) - `description` (string, optional, nullable) - `voiceMode` (enum, optional) - Allowed values: `webhook`, `hosted` - `enableMessaging` (boolean, optional, nullable) — When true, hosted-mode agents can send and read SMS/iMessage during calls. Defaults to true. - `modelTier` (enum, optional) - Allowed values: `turbo`, `balanced`, `max` - `systemPrompt` (string, optional, nullable) - `beginMessage` (string, optional, nullable) - `voice` (string, optional, nullable) - `transferNumber` (string, optional, nullable) - `customTools` (list of CustomToolParam, optional, nullable) — Hosted-mode only. User-defined function tools the agent can call during a call (look up a record, save call notes, etc.). Each points at your HTTPS endpoint; the voice provider invokes it and feeds the JSON response back to the agent. Ignored in webhook mode. Maximum 20 tools. - `voicemailMessage` (string, optional, nullable) - `callScreeningIdentity` (string, optional, nullable) - `callScreeningPurpose` (string, optional, nullable) - `sttMode` (enum, optional) — Speech-to-text mode. 'fast' optimizes for latency, 'accurate' optimizes for transcription accuracy (~200ms additional latency). - Allowed values: `fast`, `accurate` - `ambientSound` (enum, optional) — Background ambience to mask synthetic silence between turns. 'none' disables; 'office', 'coffee-shop', 'outdoor' enable a quiet bed. - Allowed values: `none`, `office`, `coffee-shop`, `outdoor` - `denoisingMode` (enum, optional) — Audio denoising. 'noise-cancellation' (default) handles general noise. 'noise-and-background-speech-cancellation' is more aggressive for callers in cars, cafes, or near TVs. - Allowed values: `noise-cancellation`, `noise-and-background-speech-cancellation` - `maxSilenceMs` (integer, optional, nullable) — Hang up the call after this many milliseconds of caller silence. Default 600000 (10 min). Raise for IVR/hold-music workflows; lower to fail fast on dead lines. Range 10000 (10s) to 3600000 (1 hour). - `voiceSpeed` (double, optional, nullable) — Voice speed multiplier. 1.0 is normal pace; lower values slow speech (0.5 is half speed), higher values speed it up (2.0 is double). Range 0.5 to 2.0. - `interruptionSensitivity` (double, optional, nullable) — How easily callers can interrupt the agent. 0 means the agent is never interrupted, 1 means the agent stops at the first sound. Default 0.8. Range 0.0 to 1.0. - `enableBackchannel` (boolean, optional, nullable) — When true, the agent interjects short filler words like 'uh-huh' or 'mhmm' during longer caller utterances. Set false to keep the agent silent while the caller is speaking. Defaults to true. - `language` (enum, optional) — BCP-47 locale that drives the agent's speech recognition and pronunciation. Defaults to 'en-US'. See the enum for the full set of supported codes. - Allowed values: `af-ZA`, `ar-SA`, `az-AZ`, `bg-BG`, `bs-BA`, `ca-ES`, `cs-CZ`, `cy-GB`, `da-DK`, `de-DE`, `el-GR`, `en-AU`, `en-GB`, `en-IN`, `en-NZ`, `en-US`, `es-419`, `es-ES`, `fa-IR`, `fi-FI`, `fil-PH`, `fr-CA`, `fr-FR`, `gl-ES`, `he-IL`, `hi-IN`, `hr-HR`, `hu-HU`, `hy-AM`, `id-ID`, `is-IS`, `it-IT`, `ja-JP`, `kk-KZ`, `kn-IN`, `ko-KR`, `lt-LT`, `lv-LV`, `mk-MK`, `mr-IN`, `ms-MY`, `ne-NP`, `nl-BE`, `nl-NL`, `no-NO`, `pl-PL`, `pt-BR`, `pt-PT`, `ro-RO`, `ru-RU`, `sk-SK`, `sl-SI`, `sr-RS`, `sv-SE`, `sw-KE`, `ta-IN`, `th-TH`, `tr-TR`, `uk-UA`, `ur-IN`, `vi-VN`, `yue-CN`, `zh-CN` ## Response ### 200 Successful Response - `id` (string, required) - `name` (string, required) - `description` (string, required, nullable) - `voiceMode` (enum, required) - Allowed values: `webhook`, `hosted` - `voice` (string, required) - `createdAt` (datetime, required) - `enableMessaging` (boolean, optional, default: true) - `modelTier` (enum, optional, default: balanced) - Allowed values: `turbo`, `balanced`, `max` - `systemPrompt` (string, optional, nullable) - `beginMessage` (string, optional, nullable) - `transferNumber` (string, optional, nullable) - `customTools` (list of AgentResponseCustomToolsItems, optional, nullable) - `voicemailMessage` (string, optional, nullable) - `callScreeningIdentity` (string, optional, nullable) - `callScreeningPurpose` (string, optional, nullable) - `sttMode` (enum, optional, default: fast) — Speech-to-text mode. 'fast' optimizes for latency, 'accurate' optimizes for transcription accuracy (~200ms additional latency). - Allowed values: `fast`, `accurate` - `ambientSound` (enum, optional, default: none) — Background ambience to mask synthetic silence between turns. 'none' disables; 'office', 'coffee-shop', 'outdoor' enable a quiet bed. - Allowed values: `none`, `office`, `coffee-shop`, `outdoor` - `denoisingMode` (enum, optional, default: noise-cancellation) — Audio denoising. 'noise-cancellation' (default) handles general noise. 'noise-and-background-speech-cancellation' is more aggressive for callers in cars, cafes, or near TVs. - Allowed values: `noise-cancellation`, `noise-and-background-speech-cancellation` - `maxSilenceMs` (integer, optional, default: 600000) — Hang up the call after this many milliseconds of caller silence. Range 10000 (10s) to 3600000 (1 hour). Default 600000 (10 min). - `voiceSpeed` (double, optional, default: 1) — Voice speed multiplier. Range 0.5 to 2.0. Default 1.0. - `interruptionSensitivity` (double, optional, default: 0.8) — How easily callers can interrupt the agent. Range 0.0 to 1.0. Default 0.8. - `enableBackchannel` (boolean, optional, default: true) — When true, the agent interjects short filler words like 'uh-huh' or 'mhmm' during longer caller utterances. Defaults to true. - `language` (string, optional, default: en-US) — BCP-47 locale that drives the agent's speech recognition and pronunciation. Defaults to 'en-US'. - `numbers` (list of AgentNumberResponse, optional, nullable) ## Errors ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### CustomToolParam - `name` (string, required) — Function name the agent calls. Letters, numbers, underscores, hyphens; max 64 chars. Must be unique and not a reserved built-in name. - `description` (string, required) — What the tool does and when to use it. The agent relies on this to decide when to call it. - `url` (string, required) — HTTPS endpoint the voice provider calls when the agent invokes this tool. - `method` (enum, optional) — HTTP method. Defaults to POST. - Allowed values: `GET`, `POST` - `headers` (map from string to string, optional, nullable) — Optional HTTP headers sent with the request (e.g. an Authorization token for your endpoint). - `parameters` (CustomToolParamParameters, optional, nullable) — JSON Schema object describing the arguments the agent fills in. Omit for a no-argument tool. - `timeoutMs` (integer, optional, nullable) — How long to wait for your endpoint before giving up. Range 1000-120000 ms. - `speakDuringExecution` (boolean, optional, nullable) — When true, the agent speaks executionMessage while the tool runs. - `executionMessage` (string, optional, nullable) — What the agent says while the tool runs (used when speakDuringExecution is true). ### AgentResponseCustomToolsItems ### AgentNumberResponse - `id` (string, required) - `phoneNumber` (string, required) - `status` (string, required) - `type` (string, optional, default: sms) ### ValidationError - `loc` (list of ValidationErrorLocItems, required) - `msg` (string, required) - `type` (string, required) ### CustomToolParamParameters JSON Schema object describing the arguments the agent fills in. Omit for a no-argument tool. ### ValidationErrorLocItems ## Examples **Request** ```json { "name": "string" } ``` **Response** ```json { "id": "string", "name": "string", "description": "string", "voiceMode": "webhook", "voice": "string", "createdAt": "2024-01-15T09:30:00Z", "enableMessaging": true, "modelTier": "balanced", "systemPrompt": "string", "beginMessage": "string", "transferNumber": "string", "customTools": [ {} ], "voicemailMessage": "string", "callScreeningIdentity": "string", "callScreeningPurpose": "string", "sttMode": "fast", "ambientSound": "none", "denoisingMode": "noise-cancellation", "maxSilenceMs": 600000, "voiceSpeed": 1, "interruptionSensitivity": 0.8, "enableBackchannel": true, "language": "en-US", "numbers": [ { "id": "string", "phoneNumber": "string", "status": "string", "type": "sms" } ] } ``` **SDK Code** ```python import requests url = "https://api.agentphone.ai/v1/agents" payload = { "name": "string" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.agentphone.ai/v1/agents'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"name":"string"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.agentphone.ai/v1/agents" payload := strings.NewReader("{\n \"name\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.agentphone.ai/v1/agents") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"string\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.agentphone.ai/v1/agents") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"name\": \"string\"\n}") .asString(); ``` ```php request('POST', 'https://api.agentphone.ai/v1/agents', [ 'body' => '{ "name": "string" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.agentphone.ai/v1/agents"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"name\": \"string\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["name": "string"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentphone.ai/v1/agents")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```