> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # Create a Call POST https://YOUR_SPACE.signalwire.com/api/laml/2010-04-01/Accounts/{AccountSid}/Calls Content-Type: application/x-www-form-urlencoded Starts an outbound call whose behavior is supplied by a cXML URL or Application SID. Use this form-encoded route for integrations built around cXML call control and Call SIDs; use the [Calling API](/docs/apis/rest/calls/call-commands) for SWML-driven calls and command-based control. #### Permissions The API token used to authenticate must have the following scope(s) enabled to make a successful request: _Voice_. [Learn more about API scopes](/docs/platform/your-signalwire-api-space). Reference: https://signalwire.com/docs/compatibility-api/rest/calls/create-a-call ## Authentication - `Authorization` header (basic auth, required) — SignalWire Basic Authentication using Project ID and API Token. The client sends HTTP requests with the Authorization header containing the word Basic followed by a space and a base64-encoded string of project_id:token. The project ID will be used as the username and the API token as the password. Example: ``` Authorization: Basic base64(project_id:token) ``` ## Request ### Path parameters - `AccountSid` (string, required) — The Project ID that uniquely identifies the Account. ### Body (application/x-www-form-urlencoded) This endpoint expects a CreateCallRequest. - `To` (string, required) — The address that received the call. Can be a phone number in E.164 format, a SIP URI, or a client identifier. - `From` (string, required) — The address that initiated the call. Must be a phone number in E.164 format for PSTN calls. - `Url` (string, optional) — The URL to handle the call. Required if `ApplicationSid` and `Laml`/`Twiml` are not used. - `ApplicationSid` (string, optional) — The unique identifier of the application used to handle the call. Required if `Url` and `Laml`/`Twiml` are not used. - `Method` (enum, optional, default: POST) — Whether the request to `Url` is a `GET` or a `POST`. Default is `POST`. - Allowed values: `GET`, `POST` - `FallbackUrl` (string, optional) — The URL SignalWire will request if errors occur when fetching the `Url`. - `FallbackMethod` (enum, optional, default: POST) — Whether the request to `FallbackUrl` is a `GET` or a `POST`. Default is `POST`. - Allowed values: `GET`, `POST` - `StatusCallback` (string, optional) — The URL SignalWire will send webhooks to on every requested `StatusCallbackEvent` event. See the [Voice status callback](/docs/compatibility-api/rest/calls/webhooks/voice-status-callback) webhook for the payload your URL will receive. - `StatusCallbackMethod` (enum, optional, default: POST) — Whether the request to `StatusCallback` URL is a `GET` or a `POST`. Default is `POST`. - Allowed values: `GET`, `POST` - `StatusCallbackEvent` (list of string, optional, default: ["completed"]) — The status events that trigger a SignalWire webhook. Valid values: initiated, ringing, answered, completed, ringing_forwarded, ringing_queued. Defaults to `completed`. - `CallerId` (string, optional) — The number, in E.164 format, or identifier of the caller. Used to override the From for caller ID purposes. - `SendDigits` (string, optional) — The digits to press after a call is connected. Valid characters are 0-9, #, *, w (wait 0.5s), and W (wait 1s). - `Timeout` (integer, optional, default: 60) — The time in seconds SignalWire will wait before assuming the call has no answer. Default is `60` seconds. - `MachineDetection` (enum, optional, default: none) — Whether a human or machine picked up the call. Default is `none`. - Allowed values: `Enable`, `DetectMessageEnd`, `none` - `MachineDetectionTimeout` (integer, optional, default: 30) — The time in seconds SignalWire will wait for machine detection before timing out. Default is `30` seconds. - `MachineDetectionSpeechThreshold` (integer, optional, default: 2400) — How many milliseconds of voice to decide it is a machine. Default is `2400` milliseconds. - `MachineDetectionSpeechEndThreshold` (integer, optional, default: 1200) — Number of milliseconds to wait for voice to finish. Default is `1200` milliseconds. - `MachineDetectionSilenceTimeout` (integer, optional, default: 5000) — Number of milliseconds to wait for initial voice before giving up. Default is `5000` milliseconds. - `MachineWordsThreshold` (integer, optional, default: 6) — How many words to count to decide it is a machine. Default is `6`. - `AsyncAmd` (boolean, optional, default: false) — Whether or not to execute machine detection asynchronously. Default is `false`. - `AsyncAmdStatusCallbackMethod` (enum, optional, default: POST) — Whether the request to `AsyncAmdStatusCallback` is a `GET` or a `POST`. Default is `POST`. - Allowed values: `GET`, `POST` - `AsyncAmdStatusCallback` (string, optional) — The URL to request when the machine detection is completed. - `AsyncAmdPartialResults` (boolean, optional, default: false) — Whether or not to report partial (interim) results to the callback url. Default is `false`. - `Record` (boolean, optional, default: false) — Whether or not to record a call. Default is `false`. - `RecordingChannels` (enum, optional, default: mono) — The number of channels in the recording. Default is `mono`. - Allowed values: `mono`, `dual` - `RecordingTrack` (enum, optional, default: both) — Specifies whether to record the `inbound`, `outbound`, or `both` audio. Default is `both`. - Allowed values: `inbound`, `outbound`, `both` - `RecordingStatusCallback` (string, optional) — The URL to request when recording is available. See the [Recording status callback](/docs/compatibility-api/rest/recordings/webhooks/recording-status-callback) webhook for the payload your URL will receive. - `RecordingStatusCallbackMethod` (enum, optional, default: POST) — Whether the request to `RecordingStatusCallback` URL is a `GET` or a `POST`. Default is `POST`. - Allowed values: `GET`, `POST` - `RecordingStatusCallbackEvent` (string, optional, default: completed) — The recording status events that trigger a webhook. Space-separated list. Valid values: completed, in-progress, absent. Default is `completed`. - `Trim` (enum, optional, default: trim-silence) — Whether leading and trailing silence is trimmed from a recording. Default is `trim-silence`. - Allowed values: `trim-silence`, `do-not-trim` - `SipAuthUsername` (string, optional) — The username to authenticate the caller when making an outbound SIP call. - `SipAuthPassword` (string, optional) — The password to authenticate the caller when making an outbound SIP call. - `MaxPricePerMinute` (string, optional) — The maximum price in USD acceptable for the call to be created. Format: up to 4 decimal places. ## Response ### 200 The request has succeeded. - `sid` (string, required) — The unique identifier for the call. - `account_sid` (string, required) — The unique identifier for the account that created this call. - `date_created` (string, required) — The date, in RFC 2822 GMT format, this call was created. - `date_updated` (string, required) — The date, in RFC 2822 GMT format, this call was updated. - `parent_call_sid` (string, required, nullable) — The unique identifier for the call that created this call. - `to` (string, required) — The address that received the call. - `formatted_to` (string, required) — The formatted number that received the call. - `to_formatted` (string, required) — The formatted number that received the call. Alias for formatted_to. - `from` (string, required) — The address that initiated the call. - `formatted_from` (string, required) — The formatted number that initiated the call. - `from_formatted` (string, required) — The formatted number that initiated the call. Alias for formatted_from. - `phone_number_sid` (string, required, nullable) — The unique identifier for the phone number. - `status` (enum, required) — The status of the call. - Allowed values: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `busy`, `failed`, `no-answer` - `start_time` (string, required, nullable) — The time, in RFC 2822 GMT format, on which the call began. - `end_time` (string, required, nullable) — The time, in RFC 2822 GMT format, on which the call was terminated. - `duration` (integer, required) — The duration, in seconds, of the call. - `price` (float, required, nullable) — The charge for the call. - `price_unit` (string, required) — The currency, in ISO 4127 format, for the price of the call. - `direction` (enum, required) — The direction of the call. - Allowed values: `inbound`, `outbound` - `answered_by` (enum, required, nullable) — Who/what the call was answered by. - Allowed values: `human`, `machine` - `api_version` (string, required) — The version of the SignalWire API. - `forwarded_from` (string, required, nullable) — The number this call was forwarded from. Always null. - `caller_name` (string, required, nullable) — The caller name. Always null. - `uri` (string, required) — The URI for the call. - `subresource_uris` (CallSubresourceUris, required) — A Map of available sub-resources. - `annotation` (string, required, nullable) — The annotation for the call. Always null. - `group_sid` (string, required, nullable) — The group SID for the call. Always null. - `audio_in_mos` (float, required, nullable) — The Mean Opinion Score for audio quality (1.0-5.0). - `sip_result_code` (string, required, nullable) — The SIP result code for the call. - `audio_rtt_avg` (integer, required, nullable) — The average round-trip time for audio in milliseconds. - `audio_rtt_min` (integer, required, nullable) — The minimum round-trip time for audio in milliseconds. - `audio_rtt_max` (integer, required, nullable) — The maximum round-trip time for audio in milliseconds. - `audio_out_jitter_min` (integer, required, nullable) — The minimum outbound audio jitter in milliseconds. - `audio_out_jitter_max` (integer, required, nullable) — The maximum outbound audio jitter in milliseconds. - `audio_out_jitter_avg` (integer, required, nullable) — The average outbound audio jitter in milliseconds. - `audio_out_lost` (integer, required, nullable) — The number of outbound audio packets lost. ## Errors ### 400 Bad Request Error The request was invalid. Review the errors array for specific issues with your request. - `errors` (list of CompatibilityErrorArrayItem, optional) — A list of errors ### 401 Unauthorized Error Authentication failed. Please verify your credentials and try again. - `code` (integer, required) — Error code. - `message` (string, required) — Error message. - `more_info` (string, required) — URL for more information about the error. - `status` (integer, required) — HTTP status code. ### 422 Unprocessable Entity Error The request could not be processed due to validation errors. Check the error details for more information. - `code` (integer, required) — Error code. - `message` (string, required) — Error message. - `more_info` (string, required) — URL for more information about the error. - `status` (integer, required) — HTTP status code. ## Types ### CallSubresourceUris Call subresource URIs. - `notifications` (string, required, nullable) — The URI for notifications. Always null. - `recordings` (string, required) — The URI for recordings. ### CompatibilityErrorArrayItem Error item in the errors array format. - `code` (string, optional) — The numeric string identifying the API error code - `message` (string, optional) — Error text - `more_info` (string, optional) — Url for more information on error code ## Examples **Request** ```json { "To": "+13105678901", "From": "+13103384645" } ``` **Response** ```json { "sid": "b3877c40-da60-4998-90ad-b792e98472ca", "account_sid": "b3877c40-da60-4998-90ad-b792e98472af", "date_created": "Wed, 19 Sep 2018 20:00:00 +0000", "date_updated": "Wed, 19 Sep 2018 21:00:00 +0000", "parent_call_sid": "b3877c40-da60-4998-90ad-b792e98472af", "to": "+13105678901", "formatted_to": "(310) 567-8901", "to_formatted": "(310) 567-8901", "from": "+13103384645", "formatted_from": "(310) 338-4645", "from_formatted": "(310) 338-4645", "phone_number_sid": "b3877c40-da60-4998-90ad-b792e98472pn", "status": "queued", "start_time": "Wed, 19 Sep 2018 20:00:01 +0000", "end_time": "Fri, 21 Sep 2018 10:00:00 +0000", "duration": 20, "price": 0.003, "price_unit": "USD", "direction": "inbound", "answered_by": "human", "api_version": "2010-04-01", "forwarded_from": null, "caller_name": null, "uri": "/api/laml/2010-04-01/Accounts/b3877c40-da60-4998-90ad-b792e98472af/Calls/b3877c40-da60-4998-90ad-b792e98472ca.json", "subresource_uris": { "notifications": null, "recordings": "/api/laml/2010-04-01/Accounts/b3877c40-da60-4998-90ad-b792e98472af/Calls/b3877c40-da60-4998-90ad-b792e98472ca/Recordings.json" }, "annotation": null, "group_sid": null, "audio_in_mos": 4.5, "sip_result_code": "200", "audio_rtt_avg": 50, "audio_rtt_min": 20, "audio_rtt_max": 100, "audio_out_jitter_min": 1, "audio_out_jitter_max": 10, "audio_out_jitter_avg": 5, "audio_out_lost": 0 } ``` **SDK Code** ```python import requests url = "https://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls" payload = "" headers = { "Content-Type": "application/x-www-form-urlencoded" } response = requests.post(url, data=payload, headers=headers, auth=("", "")) print(response.json()) ``` ```javascript const url = 'https://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls'; const credentials = btoa(":"); const options = { method: 'POST', headers: { Authorization: `Basic ${credentials}`, 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams('') }; 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" "net/http" "io" ) func main() { url := "https://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls" req, _ := http.NewRequest("POST", url, nil) req.SetBasicAuth("", "") req.Header.Add("Content-Type", "application/x-www-form-urlencoded") 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://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request.basic_auth("", "") request["Content-Type"] = 'application/x-www-form-urlencoded' 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://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls") .basicAuth("", "") .header("Content-Type", "application/x-www-form-urlencoded") .asString(); ``` ```php request('POST', 'https://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls', [ 'form_params' => null, 'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let credentials = Data(":".utf8).base64EncodedString() let headers = [ "Authorization": "Basic \(credentials)", "Content-Type": "application/x-www-form-urlencoded" ] let request = NSMutableURLRequest(url: NSURL(string: "https://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers 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() ```