> 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 domain application

POST https://%7BYour_Space_Name%7D.signalwire.com/api/relay/rest/domain_applications
Content-Type: application/json

Creates a SIP Domain Application that accepts inbound SIP traffic on its generated domain and routes calls to the configured handler. Use it for inbound bring-your-own-carrier or other custom SIP-domain routing. If the handler is an already-created Fabric resource, create the Domain Application first, then use [Assign domain application handler](/docs/apis/rest/domain-applications/assign-resource-domain-application).

#### Permissions

The API token used to authenticate must have the following scope(s) enabled to make a successful request: _Voice_, _Messaging_, or _Fax_.

[Learn more about API scopes](/docs/platform/your-signalwire-api-space).

Reference: https://signalwire.com/docs/apis/rest/domain-applications/create-domain-application

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

### Body (application/json)

- `name` (string, required) — A string representing the friendly name for this domain application.
- `identifier` (string, required) — A string representing the identifier portion of the domain application.
- `user` (string, optional, default: *) — The user portion of the domain application.
- `ip_auth_enabled` (boolean, optional) — Whether the domain application will enforce IP authentication for incoming requests.
- `ip_auth` (list of string, optional, default: []) — A list containing whitelisted IP addresses and IP blocks used if ip_auth_enabled is true.
- `encryption` (enum, optional, default: optional) — Whether connections to this domain application require encryption or if encryption is optional.
  - Allowed values: `optional`, `required`, `forbidden`
- `codecs` (list of string, optional, default: ["PCMU","PCMA"]) — A list of codecs this domain application will support.
- `ciphers` (list of string, optional, default: ["AEAD_AES_256_GCM_8","AES_256_CM_HMAC_SHA1_80","AES_CM_128_HMAC_SHA1_80","AES_256_CM_HMAC_SHA1_32","AES_CM_128_HMAC_SHA1_32"]) — A list of encryption ciphers this domain application will support.
- `call_handler` (enum, optional) — Specify how the domain application will handle calls.
  - Allowed values: `relay_topic`, `relay_application`, `laml_webhooks`, `laml_application`, `video_room`, `relay_script`, `dialogflow`, `ai_agent`, `call_flow`, `relay_context`
- `call_relay_topic` (string, optional) — A string representing the Relay topic to forward incoming calls to. Required when call_handler is relay_topic.
- `call_relay_topic_status_callback_url` (string, optional) — A string representing a URL to send status change messages to.
- `call_relay_application` (string, optional) — A string representing the Relay Application to forward incoming calls to. Required when call_handler is relay_application.
- `call_request_url` (string, optional) — A string representing the LaML URL to access when a call is received. Required when call_handler is laml_webhooks.
- `call_request_method` (enum, optional, default: POST) — A string representing the HTTP method to use with call_request_url.
  - Allowed values: `GET`, `POST`
- `call_fallback_url` (string, optional) — A string representing the LaML URL to access when the call to call_request_url fails.
- `call_fallback_method` (enum, optional, default: POST) — A string representing the HTTP method to use with call_fallback_url.
  - Allowed values: `GET`, `POST`
- `call_status_callback_url` (string, optional) — A string representing a URL to send status change messages to.
- `call_status_callback_method` (enum, optional, default: POST) — A string representing the HTTP method to use with call_status_callback_url.
  - Allowed values: `GET`, `POST`
- `call_laml_application_id` (string, optional) — A string representing the ID of the LaML application to forward incoming calls to. Required when call_handler is laml_application.
- `call_video_room_id` (string, optional) — A string representing the ID of the Video Room to forward incoming calls to. Required when call_handler is video_room.
- `call_relay_script_url` (string, optional) — A string representing the URL of the Relay script to execute when a call is received. Required when call_handler is relay_script.
- `call_dialogflow_agent_id` (string, optional) — A string representing the ID of the Dialogflow Agent to forward incoming calls to. Required when call_handler is dialogflow.
- `call_ai_agent_id` (string, optional) — A string representing the ID of the AI Agent to forward incoming calls to. Required when call_handler is ai_agent.
- `call_flow_id` (string, optional) — A string representing the ID of the Call Flow to forward incoming calls to. Required when call_handler is call_flow.
- `call_flow_version` (enum, optional) — A string representing the version of your Call Flow you'd like to use.
  - Allowed values: `working_copy`, `current_deployed`
- `call_relay_context` (string, optional, deprecated) — This handler type is deprecated. Please use call_relay_application or call_relay_topic instead.
- `call_relay_context_status_callback_url` (string, optional, deprecated) — This property is deprecated. Please use call_relay_topic_status_callback_url instead.

## Response

### 201

The request has succeeded and a new resource has been created as a result.

- `id` (string, required) — The unique identifier of the domain application on SignalWire.
- `type` (string, required) — A string representation of the type of object this record is.
- `domain` (string, required) — The unique domain for this application, combining your space subdomain and identifier.
- `name` (string, required, nullable) — A string representing the friendly name for this domain application.
- `identifier` (string, required) — A string representing the identifier portion of the domain application.
- `user` (string, required) — A string representing the user portion of the domain application.
- `ip_auth_enabled` (boolean, required) — Whether the domain application will enforce IP authentication for incoming requests.
- `ip_auth` (list of string, required) — A list containing whitelisted IP addresses and IP blocks used if ip_auth_enabled is true.
- `call_handler` (enum, required, nullable) — Specify how the domain application will handle calls.
  - Allowed values: `relay_topic`, `relay_application`, `laml_webhooks`, `laml_application`, `video_room`, `relay_script`, `dialogflow`, `ai_agent`, `call_flow`, `relay_context`, `relay_connector`, `fabric_subscriber`, `sip_gateway`, `call_queue`
- `calling_handler_resource_id` (string, required, nullable) — The unique identifier of the calling handler resource.
- `call_relay_topic` (string, required, nullable) — A string representing the Relay topic to forward incoming calls to.
- `call_relay_topic_status_callback_url` (string, required, nullable) — A string representing a URL to send status change messages to.
- `call_request_url` (string, required, nullable) — A string representing the LaML URL to access when a call is received.
- `call_request_method` (enum, required, nullable) — A string representing the HTTP method to use with call_request_url.
  - Allowed values: `GET`, `POST`
- `call_fallback_url` (string, required, nullable) — A string representing the LaML URL to access when the call to call_request_url fails.
- `call_fallback_method` (enum, required, nullable) — A string representing the HTTP method to use with call_fallback_url.
  - Allowed values: `GET`, `POST`
- `call_status_callback_url` (string, required, nullable) — A string representing a URL to send status change messages to.
- `call_status_callback_method` (enum, required, nullable) — A string representing the HTTP method to use with call_status_callback_url.
  - Allowed values: `GET`, `POST`
- `call_laml_application_id` (string, required, nullable) — A string representing the ID of the LaML application to forward incoming calls to.
- `call_video_room_id` (string, required, nullable) — A string representing the ID of the Video Room to forward incoming calls to.
- `call_relay_script_url` (string, required, nullable) — A string representing the URL of the Relay script to execute when a call is received.
- `encryption` (enum, required) — A string representing whether connections to this domain application require encryption or if encryption is optional. Valid values are optional, required, and forbidden.
  - Allowed values: `optional`, `required`, `forbidden`
- `codecs` (list of string, required) — A list of codecs this domain application will support. Currently supported values are: OPUS, G722, PCMU, PCMA, G729, VP8, and H264.
- `ciphers` (list of string, required) — A list of encryption ciphers this domain application will support. Currently supported values are: AEAD_AES_256_GCM_8, AES_256_CM_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_80, AES_256_CM_HMAC_SHA1_32, and AES_CM_128_HMAC_SHA1_32.
- `call_relay_context` (string, required, nullable, deprecated) — Deprecated. Use call_relay_application instead.
- `call_relay_context_status_callback_url` (string, required, nullable, deprecated) — Deprecated. Use call_relay_topic_status_callback_url instead.

## Examples

**Request**

```json
{
  "name": "Test App",
  "identifier": "string"
}
```

**Response**

```json
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "type": "domain_application",
  "domain": "your-space-test_id",
  "name": "Test App",
  "identifier": "string",
  "user": "helpdesk",
  "ip_auth_enabled": true,
  "ip_auth": [
    "string"
  ],
  "call_handler": "relay_topic",
  "calling_handler_resource_id": "fe4093d9-58c2-4931-b4b9-5679f82652c6",
  "call_relay_topic": "office",
  "call_relay_topic_status_callback_url": "https://myapplication/handle_relay_callbacks",
  "call_request_url": "https://example.com/laml",
  "call_request_method": "GET",
  "call_fallback_url": "https://example.com/fallback",
  "call_fallback_method": "GET",
  "call_status_callback_url": "https://example.com/status",
  "call_status_callback_method": "GET",
  "call_laml_application_id": "app-123456",
  "call_video_room_id": "fe4093d9-58c2-4931-b4b9-5679f82652c6",
  "call_relay_script_url": "https://example.com/relay-script",
  "encryption": "required",
  "codecs": [
    "string"
  ],
  "ciphers": [
    "string"
  ],
  "call_relay_context": "office",
  "call_relay_context_status_callback_url": "string"
}
```

**SDK Code**

```python
import requests

url = "https://{your_space_name}.signalwire.com/api/relay/rest/domain_applications"

payload = {
    "name": "Test App",
    "identifier": "string"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<project_id>", "<api_token>"))

print(response.json())
```

```javascript
const url = 'https://{your_space_name}.signalwire.com/api/relay/rest/domain_applications';
const credentials = btoa("<project_id>:<api_token>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"name":"Test App","identifier":"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://{your_space_name}.signalwire.com/api/relay/rest/domain_applications"

	payload := strings.NewReader("{\n  \"name\": \"Test App\",\n  \"identifier\": \"string\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.SetBasicAuth("<project_id>", "<api_token>")
	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://{your_space_name}.signalwire.com/api/relay/rest/domain_applications")

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/json'
request.body = "{\n  \"name\": \"Test App\",\n  \"identifier\": \"string\"\n}"

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_name}.signalwire.com/api/relay/rest/domain_applications")
  .basicAuth("<project_id>", "<api_token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Test App\",\n  \"identifier\": \"string\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://{your_space_name}.signalwire.com/api/relay/rest/domain_applications', [
  'body' => '{
  "name": "Test App",
  "identifier": "string"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<project_id>', '<api_token>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://{your_space_name}.signalwire.com/api/relay/rest/domain_applications");
client.Authenticator = new HttpBasicAuthenticator("<project_id>", "<api_token>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Test App\",\n  \"identifier\": \"string\"\n}", ParameterType.RequestBody);
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/json"
]
let parameters = [
  "name": "Test App",
  "identifier": "string"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/relay/rest/domain_applications")! 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()
```