> This page is for Compatibility API.

> 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`. Subscribing to `answered` sends an `answered` callback followed by an `in-progress` callback, timestamped one second later; `in-progress` can't be subscribed to separately. If `StatusCallbackEvent` includes `completed`, which it does by default, you also receive a callback with `CallStatus` set to `failed` when SignalWire stops the call before dialing it. The [Voice status callback](/docs/compatibility-api/rest/calls/webhooks/voice-status-callback) lists the reasons.
- `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

### 201

Response returned when a call is created.

- `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, the call started ringing. This is before the call was answered. Null until the call starts.
- `end_time` (string, required, nullable) — The time, in RFC 2822 GMT format, on which the call was terminated. Null until the call ends.
- `duration` (integer, required) — The duration, in seconds, of the call: `end_time` minus `start_time`, rounded up to the next whole second. It includes ringing time, so it's longer than the time the call was connected and usually longer than a recording of the call. For a call still in progress, it's the time elapsed so far; before the call starts, it's `0`.
- `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. - `inbound`: inbound calls. - `outbound-api`: calls launched through the REST API. - `outbound-dial`: calls launched through the Dial verb.
  - Allowed values: `inbound`, `outbound-api`, `outbound-dial`
- `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` (string, required, nullable) — The estimated Mean Opinion Score (MOS) for inbound audio quality, based on the share of incoming audio packets that arrived without loss or delay. It ranges from about 1 to 4.5, the score for a call with no lost or late packets. Returned as a decimal string. Null if the call has no quality measurement.
- `sip_result_code` (string, required, nullable) — The SIP result code for the call.
- `audio_rtt_avg` (double, required, nullable) — The average round-trip time for audio in milliseconds, in steps of 10.
- `audio_rtt_min` (double, required, nullable) — The minimum round-trip time for audio in milliseconds, in steps of 10.
- `audio_rtt_max` (double, required, nullable) — The maximum round-trip time for audio in milliseconds, in steps of 10.
- `audio_in_jitter_min` (double, required, nullable) — The smallest variance measured in the time between incoming audio packets, in milliseconds squared.
- `audio_in_jitter_max` (double, required, nullable) — The largest variance measured in the time between incoming audio packets, in milliseconds squared.
- `audio_out_jitter_min` (double, required, nullable) — The minimum outbound audio jitter in milliseconds.
- `audio_out_jitter_max` (double, required, nullable) — The maximum outbound audio jitter in milliseconds.
- `audio_out_jitter_avg` (double, required, nullable) — The average outbound audio jitter in milliseconds.
- `audio_in_media_packet_count` (integer, required, nullable) — The number of audio packets received in the inbound media stream.
- `audio_out_packet_count` (integer, required, nullable) — Not populated. Always `null`; use `audio_out_media_packet_count` for the number of audio packets sent.
- `audio_out_media_packet_count` (integer, required, nullable) — The number of audio packets sent in the outbound media stream.
- `audio_out_lost` (integer, required, nullable) — The number of outbound audio packets lost.
- `audio_in_mean_interval` (double, required, nullable) — The mean interval between inbound audio packets in milliseconds.
- `audio_in_dtmf_packet_count` (integer, required, nullable) — The number of DTMF packets in the inbound media stream.
- `audio_out_dtmf_packet_count` (integer, required, nullable) — The number of DTMF packets in the outbound media stream.
- `audio_in_skip_packet_count` (integer, required, nullable) — The number of inbound audio intervals filled with comfort noise because no audio packet was available. It grows with lost or late packets and during DTMF digits.
- `audio_in_flush_packet_count` (integer, required, nullable) — The number of queued inbound packets discarded when the media stream was flushed, for example when the call was bridged or unbridged.
- `audio_in_largest_jb_size` (integer, required, nullable) — Not populated. Always `0` when the call has quality statistics.

## 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

### 422 Unprocessable Entity Error

The request could not be processed due to validation errors. Check the error details for more information.

- `code` (string, required) — Error code, as a numeric string.
- `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": "Wed, 19 Sep 2018 20:00:21 +0000",
  "duration": 20,
  "price": 0.003,
  "price_unit": "USD",
  "direction": "outbound-api",
  "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": 40,
  "audio_rtt_min": 30,
  "audio_rtt_max": 50,
  "audio_in_jitter_min": 0.25,
  "audio_in_jitter_max": 8.5,
  "audio_out_jitter_min": 0,
  "audio_out_jitter_max": 2.5,
  "audio_out_jitter_avg": 0.56,
  "audio_in_media_packet_count": 1842,
  "audio_out_packet_count": null,
  "audio_out_media_packet_count": 1840,
  "audio_out_lost": 1,
  "audio_in_mean_interval": 20.03,
  "audio_in_dtmf_packet_count": 0,
  "audio_out_dtmf_packet_count": 0,
  "audio_in_skip_packet_count": 1,
  "audio_in_flush_packet_count": 2,
  "audio_in_largest_jb_size": 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=("<project_id>", "<api_token>"))

print(response.json())
```

```javascript
const url = 'https://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls';
const credentials = btoa("<project_id>:<api_token>");

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("<project_id>", "<api_token>")
	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("<project_id>", "<api_token>")
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<String> response = Unirest.post("https://your_space.signalwire.com/api/laml/2010-04-01/Accounts/AccountSid/Calls")
  .basicAuth("<project_id>", "<api_token>")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->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' => ['<project_id>', '<api_token>'],
]);

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("<project_id>", "<api_token>");
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("<project_id>:<api_token>".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()
```