- Message delivery webhooks: Configure using the
callback_urlparameter of your send request to receive delivery updates - Inbound message webhooks: Receive inbound WhatsApp messages from your users (see WhatsApp 2-Way messaging)
- Subscription management webhooks: Configure through your subscription management config (managed by our Customer Success team) to receive subscription events (STOP, START, HELP)
Message delivery events
The event object
string
The unique identifier of the event.
string
The type of the event, possible values are:
object
The payload of the event, whose structure depends on the event type.
RFC3339 date string
The timestamp of the event creation.
Delivery status payload fields
For delivery status events (pending_delivery, delivered, failed), the payload includes:
string
The unique identifier of the template used to send the message. Useful for differentiating events when multiple templates share the same callback URL.
integer
The actual number of SMS segments used, as reported by the provider. Only present for SMS messages.
string
The SMS encoding type used for the message. Either
GSM-7 (standard characters, up to 160 chars per segment) or UCS-2 (Unicode including emoji, up to 70 chars per segment). Only present for SMS messages.string
The delivery channel used. One of
sms, rcs or whatsapp.string
Present on
failed events. Provides more detail on why delivery failed. See the Delivery statuses table for possible values.How to set up your Webhook
To start receiving webhook events in your app, create and register a webhook endpoint by following the steps below. You can register and create one endpoint to handle several different event types at once, or set up individual endpoints for specific events.1
Implement the handler
Develop a webhook endpoint function to receive event data POST requests.
2
Pass the URL
Add your webhook endpoint URL to your Notify API requests to start
receiving message delivery events.
3
Return OK
Return a
200 OK HTTP response to the POST request to acknowledge receipt
of the event. If you don’t, Prelude will retry sending the event with
exponential backoff for up to 2 weeks. Retries are spaced progressively
further apart (1 min, 2 min, 4 min, … up to 12 hours) to allow your
endpoint time to recover if it’s temporarily down.Delivery statuses
Failed delivery statuses come with astatus field which can have the following values: failed, undeliverable, or expired.
An additional reason provides more information about the failure. Some of these may be retriable — Prelude will automatically retry delivery until we reach the expiry window defined in the expires_at field of the Send Message request.
Here are the possible reason values:
Delivery statuses are indicative, but they may not always be fully reliable. Depending on the market, a “delivered” confirmation can indicate delivery to the mobile network operator, the cell tower, or — in some cases — the end user’s handset.
Cost reconciliation can take up to 15 minutes. During this window, the billed amount may not yet reflect the final cost of the message.
Security
Prelude’s webhooks support the following security features:Webhook Signature
To ensure the authenticity of the webhook events, we use a signature mechanism. The signature is a base64 URL-encoded RSASSA-PSS on the SHA256 hash of the payload. The signature is sent as a string prefixed withrsassa-pss-sha256= in the X-Webhook-Signature header of each request to your webhook endpoint.
To enable the webhook signature, go to the Prelude dashboard in the Verify API->Configure->Webhooks section and generate a webhook signing key for your application.
You can then verify the signature of the webhook events in your webhook endpoint and process the event only if the signature is valid.
The same signing key is used for both the Verify and Notify APIs.
IP Whitelisting
You should whitelist the following IP addresses to ensure that your webhook endpoint receives events from Prelude:Inbound message events
When a user sends a WhatsApp message to your business number, Prelude forwards it as a webhook event. Use themessage_id from the event payload to send a reply within the 24-hour conversation window.
Inbound event object
string
The unique identifier of the event.
string
The event type:
inbound.message.received.object
string
The unique inbound message identifier (prefixed with
im_). Use this value in context.reply_to when sending a reply.string
The channel the message was received on. Currently
whatsapp.string
The sender’s phone number in E.164 format.
string
Your WhatsApp Business phone number that received the message.
RFC3339 date string
The timestamp of the event creation.
Example inbound message event
Subscription management events
When users interact with your messages by sending subscription keywords (STOP, START, or HELP), Prelude will send webhook events to the callback URL configured in your subscription management config.
Subscription event object
string
The unique identifier of the event.
string
The type of subscription event:
object
string
The subscription action keyword sent by the user. Possible values:
STOP, START, HELP.string
The phone number that sent the subscription keyword (E.164 format).
string
The destination phone number (your short code or long code).
RFC3339 date string
The timestamp when the subscription keyword was received.
RFC3339 date string
The timestamp of the event creation.
Example subscription webhooks
Handling subscription events
When you receive a subscription event:- STOP: The user has been automatically unsubscribed. Subsequent API calls for this phone number will return an error.
- START: The user has been resubscribed and can receive marketing messages again.
- HELP: The user requested information. A default help message is automatically sent, but you may want to log this event.
Carrier disconnect events
When a phone number is disconnected by its carrier (e.g. line terminated, number ported, or prepaid plan expired), Prelude automatically unsubscribes it from all subscription management configs and sends a webhook event to each config’s callback URL.Unlike subscription events, carrier disconnect events are not initiated by the user. The carrier reported the number as disconnected. You should still remove the number from your subscriber lists — disconnected numbers can be reassigned to new subscribers who never consented to your messages.
Carrier disconnect event object
string
The unique identifier of the event.
string
Always
marketing.subscription.carrier_disconnect.object
RFC3339 date string
The timestamp of the event creation.
Example carrier disconnect webhook
Handling carrier disconnect events
When you receive a carrier disconnect event:- The phone number has been automatically unsubscribed from all subscription management configs.
- Future API calls to send marketing messages to this number will return an error.
- You should remove this number from all your subscriber lists and campaigns.