Integratie: Webhooks

Spotler MailPro ondersteunt webhooks, waarmee je realtime meldingen kunt ontvangen wanneer specifieke gebeurtenissen plaatsvinden in je e-mailcampagnes of contactgegevens. Dit maakt een naadloze integratie met externe systemen mogelijk om workflows te automatiseren, gebruikersactiviteit te volgen of databases te synchroniseren.

Een webhook is een automatische notificatie van MailPro aan een ander systeem. MailPro verstuurt een HTTPS-request wanneer een ingestelde gebeurtenis plaatsvindt.

Let op: De Webhooks-functionaliteit moet voor je MailPro-licentie worden geactiveerd voordat je deze kunt gebruiken.

In dit artikel vind je informatie over:

Woordenlijst Webhooks

Term Definitie
Subscription Configuratie die bepaalt welk topic MailPro bewaakt en waar notificaties voor overeenkomende gebeurtenissen worden afgeleverd.
Vendor De eigenaar van een subscription op een specifiek webhooktopic.
Topic Systeemgebeurtenis waarop een subscription kan luisteren.
Delivery URL Het HTTPS-endpoint waarop notificaties worden afgeleverd.

Een webhook instellen

Om webhooknotificaties te ontvangen, heb je een HTTPS-endpoint in je applicatie en een webhooksubscription in MailPro nodig. Webhooksubscriptions maak en beheer je via de Spotler MailPro REST API.

1. Bereid je delivery URL voor

Maak in je eigen applicatie een HTTPS-endpoint dat webhookrequests kan ontvangen en verwerken.

Als je endpoint een IP-allowlist gebruikt, volg dan de richtlijnen voor IP-allowlisting in MailPro (inloggen vereist).

2. Maak je webhooksubscription aan

Gebruik REST-credentials om requests naar de Spotler MailPro REST API te authenticeren. Je kunt de Webhook-endpoints rechtstreeks vanuit je integratie aanroepen. Voor handmatige configuratie of tests zijn dezelfde endpoints beschikbaar in de Swagger-documentatie van je licentie op https://[license].webpower.eu/admin/api/swagger. Configureer:

  • Delivery URL: het HTTPS-endpoint waarop je notificaties wilt ontvangen.
  • Topic: kies een gebeurtenis uit de beschikbare webhook topics. Gebruik bijvoorbeeld contact.created om notificaties te ontvangen wanneer een contact wordt aangemaakt.
  • Secret: het secret waarmee webhookrequests worden ondertekend. Jouw applicatie gebruikt dit secret om de signature te controleren.

3. Ontvang en controleer notificaties

Zodra de subscription is aangemaakt, stuurt MailPro requests naar je delivery URL wanneer gebeurtenissen voor het ingestelde topic plaatsvinden.

Controleer de x-mailpro-signature-header voordat je de notificatie verwerkt. MailPro berekent een HMAC-SHA256-signature over de exacte, ongewijzigde raw request body met het ingestelde secret. De header bevat de signature als hexadecimale tekenreeks in lowercase.

4. Test je koppeling

Laat een gebeurtenis voor het ingestelde topic plaatsvinden en controleer of jouw applicatie de notificatie ontvangt en verwerkt. Je endpoint moet een 2xx-antwoord teruggeven om succesvolle ontvangst te bevestigen.

Webhook request headers

Header Description Example
x-mailpro-license De naam van de MailPro-licentie die het webhookrequest heeft geïnitieerd. Dit is het licentiedeel van het domein, bijvoorbeeld sandbox in https://sandbox.webpower.eu/. sandbox
x-mailpro-subscriber-id De identifier van de webhooksubscription. 5
x-mailpro-topic Het topic dat het gebeurtenis- en payloadtype identificeert. contact.created
x-mailpro-signature Hexadecimale HMAC-SHA256-signature in lowercase, berekend over de exacte raw request body met het ingestelde secret. 2c8508...92c31e91

Retry mechanisme

Wanneer een webhookrequest geen 2xx-statuscode ontvangt, bijvoorbeeld omdat het delivery endpoint tijdelijk overbelast of niet beschikbaar is, probeert MailPro het request opnieuw af te leveren. MailPro doet maximaal vijf retrypogingen. De eerste retry vindt plaats na 500 milliseconden en de wachttijd verdubbelt na iedere retry. De laatste retry vindt plaats na 8.000 milliseconden. Als deze retry ook mislukt, wordt de aflevering als mislukt geregistreerd.

Beschikbare webhook topics

De volgende topics worden ondersteund:

contact.created

Gets triggered after the creation of an contact.

Note

This topic don’t honors the opt-in state of the contact. Which can result in receiving contacts that don’t (yet) have finished their opt-in process for receiving (marketing) emails.

Field Datatype Example
contact_id int 1
campaign_id int 25
email string user@example.com
mobile_nr string|null +31612345678
lang string|null null
fields {field: string, value: string}[] [{field: "firstName", value: "John"}, {field: "lastName", value: "Doe"}]
created_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300012,
  "campaign_id": 20,
  "email": "user@example.com",
  "mobile_nr": null,
  "lang": null,
  "fields": [
    { "field": "firstname", "value": "John" },
    { "field": "lastname", "value": "Doe" }
  ],
  "created_on": "2024-09-13T12:30:00+02:00"
}
contact.changed

Get’s triggered after the creation of an contact.

Field Datatype Example
contact_id int 1
campaign_id int 25
email string user@example.com
mobile_nr string|null +31612345678
lang string|null null
fields {field: string, value: string}[] [{field: "firstName", value: "John"}, {field: "lastName", value: "Doe"}]
changed_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300012,
  "campaign_id": 20,
  "email": "user@example.com",
  "mobile_nr": null,
  "lang": null,
  "fields": [
    { "field": "firstname", "value": "John" },
    { "field": "lastname", "value": "Doe" }
  ],
  "changed_on": "2024-09-13T12:30:00+02:00"
}
contact.removed

Get’s triggered after the removal of a single contact.

Field Datatype Example
contact_id int 1
campaign_id int 25
email string user@example.com
mobile_nr string|null +31612345678
lang string|null null
fields {field: string, value: string}[] [{field: "firstName", value: "John"}, {field: "lastName", value: "Doe"}]
removed_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300012,
  "campaign_id": 20,
  "email": "user@example.com",
  "mobile_nr": null,
  "lang": null,
  "fields": [
    { "field": "firstname", "value": "John" },
    { "field": "lastname", "value": "Doe" }
  ],
  "removed_on": "2024-09-13T12:30:00+02:00"
}
contact.group.added

Get’s triggered after a contact got added to a group.

Field Datatype Example
contact_id int 1
campaign_id int 25
group_id int 70
added_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300012,
  "campaign_id": 20,
  "group_id": 70,
  "added_on": "2024-09-13T12:30:00+02:00"
}
contact.group.removed

Get’s triggered a contact got removed from a group.

Field Datatype Example
contact_id int 1
campaign_id int 25
group_id int 70
removed_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300012,
  "campaign_id": 20,
  "group_id": 70,
  "removed_on": "2024-09-13T12:30:00+02:00"
}
contact.any

Receives any message of topic that starts with contact.

Payload definition: One of the contact.definitions based on the received topic given as HTTP header.

Note

This topic will always receive newly added contact topics in future product releases. Make sure to always check the topic type in the header before processing the content, as we can’t guarantee the payload definition of new topics are inline with the existing one's.

interaction.clicked

Get’s triggered after contact clicked on a link inside a mail.

Field Datatype Example
contact_id int 1
campaign_id int 25
mailing_id int 200
sendout_id int|null 312
click_name string Request now your today
url string https://spotler.com/demo
reference string|null automation_338
clicked_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300010,
  "campaign_id": 20,
  "mailing_id": 132,
  "sendout_id": 52,
  "click_name": "Request now your today",
  "url": "https://spotler.com/demo",
  "reference": "automation_338",
  "clicked_on": "2024-09-13T12:30:00+02:00"
}
interaction.opened

Get’s triggered after contact opened a received mail.

Field Datatype Example
contact_id int 1
campaign_id int 25
mailing_id int 200
sendout_id int|null 312
reference string|null automation_338
opened_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300010,
  "campaign_id": 20,
  "mailing_id": 132,
  "sendout_id": 52,
  "reference": "automation_338",
  "opened_on": "2024-09-13T12:30:00+02:00"
}
interaction.sms.sent

Get’s triggered after a sms got sent to a contact.

Field Datatype Example
contact_id int 1
campaign_id int 25
sms_id int 300
sendout_id int|null 105
reference string|null automation_338
sent_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300010,
  "campaign_id": 20,
  "sms_id": 132,
  "sendout_id": 52,
  "reference": "automation_338",
  "sent_on": "2024-09-13T12:30:00+02:00"
}
interaction.email.sent

Get’s triggered after the creation of an contact.

Field Datatype Example
contact_id int 1
campaign_id int 25
email_id int 301
sendout_id int|null 105
weblink string https://local.domain.com/x/?midrid
reference string|null automation_338
sent_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300010,
  "campaign_id": 20,
  "email_id": 132,
  "sendout_id": 52,
  "weblink": "https://local.domain.com/x/?midrid",
  "reference": "automation_338",
  "sent_on": "2024-09-13T12:30:00+02:00"
}
interaction.email.bounced

Get’s triggered after the mail server of the contact denied delivering the sent mail.

Note

Only bounce messages of the contact mail servers are reported. This topic will not be triggered when the contact is included in any of the bounce exclude lists. Those instances will be handled as a not sent interaction.

Field Datatype Example
contact_id int 1
campaign_id int 25
email_id int 301
sendout_id int|null 25
bounce_type "soft"|"hard" "soft"
bounced_on string (ISO_8601) 2024-09-13T12:30:00+02:00
reference string|null automation_338
{
  "contact_id": 300010,
  "campaign_id": 20,
  "email_id": 132,
  "sendout_id": 52,
  "bounce_type": "soft",
  "bounced_on": "2024-09-13T12:30:00+02:00",
  "reference": "automation_338"
}
interaction.complaint

Get’s triggered after the contact filed a spam complaint.

Field Datatype Example
contact_id int 1
campaign_id int 25
mailing_id int 301
sendout_id int|null 25
complained_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300010,
  "campaign_id": 20,
  "mailing_id": 132,
  "sendout_id": 52,
  "complained_on": "2024-09-13T12:30:00+02:00"
}
interaction.unsubscribed

Get’s triggered after the a contact unsubscribed.

Field Datatype Example
contact_id int 1
campaign_id int 25
mailing_id int 301
sendout_id int|null 25
email string user@example.com
mobile_nr string|null +31612345678
lang string|null null
fields {field: string, value: string}[] [{field: "firstName", value: "John"}, {field: "lastName", value: "Doe"}]
unsubscribed_on string (ISO_8601) 2024-09-13T12:30:00+02:00
{
  "contact_id": 300012,
  "campaign_id": 20,
  "mailing_id": 132,
  "sendout_id": 52,
  "email": "user@example.com",
  "mobile_nr": null,
  "lang": null,
  "fields": [
    { "field": "firstname", "value": "John" },
    { "field": "lastname", "value": "Doe" }
  ],
  "unsubscribed_on": "2024-09-13T12:30:00+02:00"
}
interaction.any

Receives any message of topic that starts with interaction.

Payload definition: One of the interaction. definitions based on the received topic given as HTTP header.

Note

This topic will always receive newly added interaction topics in future product releases. Make sure to always check the topic type in the header before processing the content, as we won’t guarantee the payload definition of new topics are inline with the existing one's.