Create a webhook
Registers a URL on an advanced (multichannel) campaign, or on all of them. The URL then receives a JSON POST each time one of the selected events happens. The events and their bodies are described in the events of this section.
One campaign. Pass its id in campaignId. webhookId in the response is the id of the registration. Registering the same URL again on the same campaign adds a second registration, and the URL then receives everything twice: to change the events, delete the URL first.
All campaigns. Pass ALL_CAMPAIGNS in campaignId. The URL is added to every campaign that is not FINISHED or ARCHIVED and does not have it yet, and it is kept for the campaigns you create later. A campaign that already has the URL keeps its events. webhookId is then the id of your account, not of a registration: read the ids with GET /webhook.
Pitfalls. Always send type: advanced. Without it, the route works on legacy email campaigns: a campaign id answers 404, and ALL_CAMPAIGNS answers success: true while no advanced campaign gets the URL. Event names are not validated: a misspelled name is accepted and never fires.
Errors. 400 INVALID_PARAMETERS when a field is missing, events is empty or hookUrl is not a URL. 400 without code when campaignId is not a valid id. 404 CAMPAIGN_NOT_FOUND when the campaign does not exist on your account.
Authorization
apiKey Your 48 character API key, sent as is (a Bearer prefix is tolerated). Create it at https://v3.emelia.io/settings/api.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/webhook" \ -H "Authorization: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "hookUrl": "https://hooks.acme.com/emelia/9f2c4e1a7b", "campaignId": "6651f0c2a1b2c3d4e5f60718", "type": "advanced", "events": [ "MAIL_REPLIED", "LINKEDIN_REPLIED" ] }'{ "success": true, "webhookId": "6702c1d4e5f6a7b8c9d0e1f2"}