Create a webhook endpoint
curl --request POST \
--url https://{dsn}/api/v1/webhooks/endpoints \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"url": "https://app.example.com/webhooks/email",
"trigger_events": [
"email.new",
"email.update",
"account.status.disconnected"
],
"description": "CRM sync"
}
'import requests
url = "https://{dsn}/api/v1/webhooks/endpoints"
payload = {
"url": "https://app.example.com/webhooks/email",
"trigger_events": ["email.new", "email.update", "account.status.disconnected"],
"description": "CRM sync"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://app.example.com/webhooks/email',
trigger_events: ['email.new', 'email.update', 'account.status.disconnected'],
description: 'CRM sync'
})
};
fetch('https://{dsn}/api/v1/webhooks/endpoints', 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://{dsn}/api/v1/webhooks/endpoints",
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://app.example.com/webhooks/email',
'trigger_events' => [
'email.new',
'email.update',
'account.status.disconnected'
],
'description' => 'CRM sync'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://{dsn}/api/v1/webhooks/endpoints"
payload := strings.NewReader("{\n \"url\": \"https://app.example.com/webhooks/email\",\n \"trigger_events\": [\n \"email.new\",\n \"email.update\",\n \"account.status.disconnected\"\n ],\n \"description\": \"CRM sync\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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://{dsn}/api/v1/webhooks/endpoints")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://app.example.com/webhooks/email\",\n \"trigger_events\": [\n \"email.new\",\n \"email.update\",\n \"account.status.disconnected\"\n ],\n \"description\": \"CRM sync\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{dsn}/api/v1/webhooks/endpoints")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://app.example.com/webhooks/email\",\n \"trigger_events\": [\n \"email.new\",\n \"email.update\",\n \"account.status.disconnected\"\n ],\n \"description\": \"CRM sync\"\n}"
response = http.request(request)
puts response.read_body{
"$ref": "#/components/examples/WebhookEndpoint/value"
}{
"status": 400,
"type": "errors/invalid_parameters",
"title": "Invalid parameters",
"detail": "limit must be between 1 and 250"
}{
"status": 401,
"type": "errors/unauthorized",
"title": "Unauthorized",
"detail": "missing or invalid API key"
}Webhooks
Create a webhook endpoint
Registers a URL of your app. The engine sends it a POST with the event envelope for every
trigger_events event. The response contains the endpoint’s secret: check the
X-Email-Engine-Signature header (HMAC-SHA256 of the body) with it.
Your endpoint must answer 2xx within 10 seconds; otherwise the call is retried 8 times over about an hour.
POST
/
webhooks
/
endpoints
Create a webhook endpoint
curl --request POST \
--url https://{dsn}/api/v1/webhooks/endpoints \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"url": "https://app.example.com/webhooks/email",
"trigger_events": [
"email.new",
"email.update",
"account.status.disconnected"
],
"description": "CRM sync"
}
'import requests
url = "https://{dsn}/api/v1/webhooks/endpoints"
payload = {
"url": "https://app.example.com/webhooks/email",
"trigger_events": ["email.new", "email.update", "account.status.disconnected"],
"description": "CRM sync"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://app.example.com/webhooks/email',
trigger_events: ['email.new', 'email.update', 'account.status.disconnected'],
description: 'CRM sync'
})
};
fetch('https://{dsn}/api/v1/webhooks/endpoints', 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://{dsn}/api/v1/webhooks/endpoints",
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://app.example.com/webhooks/email',
'trigger_events' => [
'email.new',
'email.update',
'account.status.disconnected'
],
'description' => 'CRM sync'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://{dsn}/api/v1/webhooks/endpoints"
payload := strings.NewReader("{\n \"url\": \"https://app.example.com/webhooks/email\",\n \"trigger_events\": [\n \"email.new\",\n \"email.update\",\n \"account.status.disconnected\"\n ],\n \"description\": \"CRM sync\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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://{dsn}/api/v1/webhooks/endpoints")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://app.example.com/webhooks/email\",\n \"trigger_events\": [\n \"email.new\",\n \"email.update\",\n \"account.status.disconnected\"\n ],\n \"description\": \"CRM sync\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{dsn}/api/v1/webhooks/endpoints")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://app.example.com/webhooks/email\",\n \"trigger_events\": [\n \"email.new\",\n \"email.update\",\n \"account.status.disconnected\"\n ],\n \"description\": \"CRM sync\"\n}"
response = http.request(request)
puts response.read_body{
"$ref": "#/components/examples/WebhookEndpoint/value"
}{
"status": 400,
"type": "errors/invalid_parameters",
"title": "Invalid parameters",
"detail": "limit must be between 1 and 250"
}{
"status": 401,
"type": "errors/unauthorized",
"title": "Unauthorized",
"detail": "missing or invalid API key"
}Authorizations
Your access token, from your dashboard under API keys.
Body
application/json
Your HTTPS endpoint. Private and local addresses are refused.
The events sent to this URL.
Minimum array length:
1Available options:
email.new, email.new.bounce, email.update, email.delete, email.draft.new, email.draft.delete, email.folder.create, email.folder.update, email.folder.delete, tracking.open, tracking.click, account.add, account.reconnect, account.remove, account.status.running, account.status.errored, account.status.disconnected, account.initial_sync.running, account.initial_sync.completed, account.initial_sync.failed Only these accounts (acc_…). Empty = every account.
Your description. Not sent in events.
Extra headers sent with every call.
Show child attributes
Show child attributes
Response
The endpoint.
Allowed value:
"WebhookEndpoint"we_…
Available options:
email.new, email.new.bounce, email.update, email.delete, email.draft.new, email.draft.delete, email.folder.create, email.folder.update, email.folder.delete, tracking.open, tracking.click, account.add, account.reconnect, account.remove, account.status.running, account.status.errored, account.status.disconnected, account.initial_sync.running, account.initial_sync.completed, account.initial_sync.failed Show child attributes
Show child attributes
Signs the calls (HMAC-SHA256).