Create a webhook for an email domain
Creates a webhook endpoint subscribed to a specific allowlist of event types. Both email.* events (published by email-api) and email_domain.* events (published by this service) flow through the same webhooks.
POST
/
email_domains
/
{domain_id}
/
webhooks
Create a webhook for an email domain
curl --request POST \
--url https://api.telnyx.com/v2/email_domains/{domain_id}/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/webhooks/email",
"events": [
"email.sent",
"email.delivered",
"email.bounced"
]
}
'import requests
url = "https://api.telnyx.com/v2/email_domains/{domain_id}/webhooks"
payload = {
"url": "https://example.com/webhooks/email",
"events": ["email.sent", "email.delivered", "email.bounced"]
}
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({
url: 'https://example.com/webhooks/email',
events: ['email.sent', 'email.delivered', 'email.bounced']
})
};
fetch('https://api.telnyx.com/v2/email_domains/{domain_id}/webhooks', 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/{domain_id}/webhooks",
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([
'url' => 'https://example.com/webhooks/email',
'events' => [
'email.sent',
'email.delivered',
'email.bounced'
]
]),
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/{domain_id}/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://example.com/webhooks/email\",\n \"events\": [\n \"email.sent\",\n \"email.delivered\",\n \"email.bounced\"\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/{domain_id}/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/webhooks/email\",\n \"events\": [\n \"email.sent\",\n \"email.delivered\",\n \"email.bounced\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/email_domains/{domain_id}/webhooks")
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 \"url\": \"https://example.com/webhooks/email\",\n \"events\": [\n \"email.sent\",\n \"email.delivered\",\n \"email.bounced\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "123e4567-e89b-12d3-a456-426614174003",
"record_type": "email_webhook",
"url": "https://example.com/webhooks/email",
"events": [
"email.sent",
"email.delivered",
"email.bounced"
],
"domain_id": "123e4567-e89b-12d3-a456-426614174000",
"created_at": "2026-06-18T12:00:00Z",
"updated_at": "2026-06-18T12:00:00Z"
}
}{
"errors": [
{
"code": "10001",
"title": "Not Found",
"detail": "The requested email domain was not found"
}
]
}{
"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.
Path Parameters
Email domain UUID
Body
application/json
HTTPS endpoint to deliver subscribed events to.
At least one event type is required.
Minimum array length:
1Event types a webhook may subscribe to. The union of email.* events (published by email-api) and email_domain.* lifecycle events (published by this service). An event not listed here can never be subscribed to and is silently dropped.
Available options:
email.scheduled, email.sandbox, email.queued, email.sending, email.sent, email.delivered, email.deferred, email.bounced, email.failed, email.complained, email.opened, email.clicked, email.unsubscribed, email.received, email_domain.created, email_domain.verified, email_domain.degraded, email_domain.suspended, email_domain.deleted Response
Email webhook created
Show child attributes
Show child attributes
Example:
{
"id": "123e4567-e89b-12d3-a456-426614174003",
"record_type": "email_webhook",
"url": "https://example.com/webhooks/email",
"events": [
"email.sent",
"email.delivered",
"email.bounced"
],
"domain_id": "123e4567-e89b-12d3-a456-426614174000",
"created_at": "2026-06-18T12:00:00Z",
"updated_at": "2026-06-18T12:00:00Z"
}
Was this page helpful?
⌘I
Create a webhook for an email domain
curl --request POST \
--url https://api.telnyx.com/v2/email_domains/{domain_id}/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/webhooks/email",
"events": [
"email.sent",
"email.delivered",
"email.bounced"
]
}
'import requests
url = "https://api.telnyx.com/v2/email_domains/{domain_id}/webhooks"
payload = {
"url": "https://example.com/webhooks/email",
"events": ["email.sent", "email.delivered", "email.bounced"]
}
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({
url: 'https://example.com/webhooks/email',
events: ['email.sent', 'email.delivered', 'email.bounced']
})
};
fetch('https://api.telnyx.com/v2/email_domains/{domain_id}/webhooks', 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/{domain_id}/webhooks",
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([
'url' => 'https://example.com/webhooks/email',
'events' => [
'email.sent',
'email.delivered',
'email.bounced'
]
]),
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/{domain_id}/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://example.com/webhooks/email\",\n \"events\": [\n \"email.sent\",\n \"email.delivered\",\n \"email.bounced\"\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/{domain_id}/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/webhooks/email\",\n \"events\": [\n \"email.sent\",\n \"email.delivered\",\n \"email.bounced\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/email_domains/{domain_id}/webhooks")
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 \"url\": \"https://example.com/webhooks/email\",\n \"events\": [\n \"email.sent\",\n \"email.delivered\",\n \"email.bounced\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "123e4567-e89b-12d3-a456-426614174003",
"record_type": "email_webhook",
"url": "https://example.com/webhooks/email",
"events": [
"email.sent",
"email.delivered",
"email.bounced"
],
"domain_id": "123e4567-e89b-12d3-a456-426614174000",
"created_at": "2026-06-18T12:00:00Z",
"updated_at": "2026-06-18T12:00:00Z"
}
}{
"errors": [
{
"code": "10001",
"title": "Not Found",
"detail": "The requested email domain was not found"
}
]
}{
"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"
}
]
}