Create an email domain
POST
/
email_domains
Create an email domain
curl --request POST \
--url https://api.telnyx.com/v2/email_domains \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"domain": "example.com",
"inbound_enabled": true,
"tracking": {
"open_tracking": true,
"click_tracking": true,
"unsubscribe_tracking": false
}
}
'import requests
url = "https://api.telnyx.com/v2/email_domains"
payload = {
"domain": "example.com",
"inbound_enabled": True,
"tracking": {
"open_tracking": True,
"click_tracking": True,
"unsubscribe_tracking": False
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
domain: 'example.com',
inbound_enabled: true,
tracking: {open_tracking: true, click_tracking: true, unsubscribe_tracking: false}
})
};
fetch('https://api.telnyx.com/v2/email_domains', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telnyx.com/v2/email_domains",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'domain' => 'example.com',
'inbound_enabled' => true,
'tracking' => [
'open_tracking' => true,
'click_tracking' => true,
'unsubscribe_tracking' => false
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.telnyx.com/v2/email_domains"
payload := strings.NewReader("{\n \"domain\": \"example.com\",\n \"inbound_enabled\": true,\n \"tracking\": {\n \"open_tracking\": true,\n \"click_tracking\": true,\n \"unsubscribe_tracking\": false\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.telnyx.com/v2/email_domains")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"domain\": \"example.com\",\n \"inbound_enabled\": true,\n \"tracking\": {\n \"open_tracking\": true,\n \"click_tracking\": true,\n \"unsubscribe_tracking\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/email_domains")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"domain\": \"example.com\",\n \"inbound_enabled\": true,\n \"tracking\": {\n \"open_tracking\": true,\n \"click_tracking\": true,\n \"unsubscribe_tracking\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"record_type": "email_domain",
"domain": "example.com",
"type": "custom",
"status": "pending",
"usable_for_sending": false,
"usable_for_inbound": false,
"verification": {
"ownership": "pending",
"spf": "missing_optional",
"dkim": "pending",
"dmarc": "missing_optional",
"mx": "not_required"
},
"dns_records": [],
"dkim": {
"selector": null,
"algorithm": null,
"key_length": null,
"active": false,
"rotated_at": null
},
"inbound": {
"enabled": false,
"catch_all": false,
"mx_required": false
},
"dmarc_policy": {
"p": "none",
"pct": 100,
"rua": "mailto:dmarc@telnyx.com"
},
"tracking": {
"open_tracking": false,
"click_tracking": false,
"unsubscribe_tracking": false
},
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z",
"verified_at": null
}
}{
"errors": [
{
"code": "10015",
"title": "Validation Failed",
"detail": "domain is invalid",
"source": {
"pointer": "/data/attributes/domain"
}
}
]
}{
"errors": [
{
"code": "500",
"title": "Internal Server Error",
"detail": "An unexpected error occurred"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Example:
"example.com"
Enable inbound routing for this domain
DMARC policy. Omit/null for the advisory default (v=DMARC1; p=none; rua=mailto:dmarc@telnyx.com).
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
Email domain created
Show child attributes
Show child attributes
Example:
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"record_type": "email_domain",
"domain": "example.com",
"type": "custom",
"status": "pending",
"usable_for_sending": false,
"usable_for_inbound": false,
"verification": {
"ownership": "pending",
"spf": "missing_optional",
"dkim": "pending",
"dmarc": "missing_optional",
"mx": "not_required"
},
"dns_records": [],
"dkim": {
"selector": null,
"algorithm": null,
"key_length": null,
"active": false,
"rotated_at": null
},
"inbound": {
"enabled": false,
"catch_all": false,
"mx_required": false
},
"dmarc_policy": {
"p": "none",
"pct": 100,
"rua": "mailto:dmarc@telnyx.com"
},
"tracking": {
"open_tracking": false,
"click_tracking": false,
"unsubscribe_tracking": false
},
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z",
"verified_at": null
}
Was this page helpful?
⌘I
Create an email domain
curl --request POST \
--url https://api.telnyx.com/v2/email_domains \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"domain": "example.com",
"inbound_enabled": true,
"tracking": {
"open_tracking": true,
"click_tracking": true,
"unsubscribe_tracking": false
}
}
'import requests
url = "https://api.telnyx.com/v2/email_domains"
payload = {
"domain": "example.com",
"inbound_enabled": True,
"tracking": {
"open_tracking": True,
"click_tracking": True,
"unsubscribe_tracking": False
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
domain: 'example.com',
inbound_enabled: true,
tracking: {open_tracking: true, click_tracking: true, unsubscribe_tracking: false}
})
};
fetch('https://api.telnyx.com/v2/email_domains', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telnyx.com/v2/email_domains",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'domain' => 'example.com',
'inbound_enabled' => true,
'tracking' => [
'open_tracking' => true,
'click_tracking' => true,
'unsubscribe_tracking' => false
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.telnyx.com/v2/email_domains"
payload := strings.NewReader("{\n \"domain\": \"example.com\",\n \"inbound_enabled\": true,\n \"tracking\": {\n \"open_tracking\": true,\n \"click_tracking\": true,\n \"unsubscribe_tracking\": false\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.telnyx.com/v2/email_domains")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"domain\": \"example.com\",\n \"inbound_enabled\": true,\n \"tracking\": {\n \"open_tracking\": true,\n \"click_tracking\": true,\n \"unsubscribe_tracking\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/email_domains")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"domain\": \"example.com\",\n \"inbound_enabled\": true,\n \"tracking\": {\n \"open_tracking\": true,\n \"click_tracking\": true,\n \"unsubscribe_tracking\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"record_type": "email_domain",
"domain": "example.com",
"type": "custom",
"status": "pending",
"usable_for_sending": false,
"usable_for_inbound": false,
"verification": {
"ownership": "pending",
"spf": "missing_optional",
"dkim": "pending",
"dmarc": "missing_optional",
"mx": "not_required"
},
"dns_records": [],
"dkim": {
"selector": null,
"algorithm": null,
"key_length": null,
"active": false,
"rotated_at": null
},
"inbound": {
"enabled": false,
"catch_all": false,
"mx_required": false
},
"dmarc_policy": {
"p": "none",
"pct": 100,
"rua": "mailto:dmarc@telnyx.com"
},
"tracking": {
"open_tracking": false,
"click_tracking": false,
"unsubscribe_tracking": false
},
"created_at": "2026-01-01T00:00:00Z",
"updated_at": "2026-01-01T00:00:00Z",
"verified_at": null
}
}{
"errors": [
{
"code": "10015",
"title": "Validation Failed",
"detail": "domain is invalid",
"source": {
"pointer": "/data/attributes/domain"
}
}
]
}{
"errors": [
{
"code": "500",
"title": "Internal Server Error",
"detail": "An unexpected error occurred"
}
]
}