Create a webhook endpoint
const url = 'https://api.vaartix.com/webhooks';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"url":"https://api.acme.in/webhooks/vaartix","events":["email.delivered","email.bounced","email.complained"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.vaartix.com/webhooks \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "url": "https://api.acme.in/webhooks/vaartix", "events": [ "email.delivered", "email.bounced", "email.complained" ] }'Vaartix sends a signed POST to the URL for each event you choose. The response includes
the signing secret once; store it to verify requests. A team can have up to 10 endpoints.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
A public https:// URL.
Example
https://api.acme.in/webhooks/vaartixExample
[ "email.delivered", "email.bounced", "email.complained"]Responses
Section titled “Responses”The new endpoint, including its signing secret.
object
Endpoints are turned off automatically after 5 deliveries in a row fail every attempt.
The signing secret. Shown only when created or rotated.
Example
{ "id": "wh_4n8x2k7q1m9c3v5d", "events": [ "email.sent" ], "status": "enabled", "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"}validation_error: the request is invalid. The message says which field and why.
object
object
Stable, machine-readable error type.
Human-readable explanation, safe to show to developers.
Example
{ "error": { "type": "validation_error", "message": "to: \"priya@\" is not a valid email address." }}unauthorized: the API key is missing, invalid or revoked.
object
object
Stable, machine-readable error type.
Human-readable explanation, safe to show to developers.
Example
{ "error": { "type": "validation_error" }}forbidden: the key cannot do this, for example a send-only key on a management endpoint.
object
object
Stable, machine-readable error type.
Human-readable explanation, safe to show to developers.
Example
{ "error": { "type": "validation_error" }}conflict: the request clashes with the current state, for example too many endpoints.
object
object
Stable, machine-readable error type.
Human-readable explanation, safe to show to developers.
Example
{ "error": { "type": "validation_error" }}