Webhook event payloads
Webhook events are JSON notifications that report message activity or application state to an external consumer. Each request has a common envelope with event identity and a typed payload, while the payload shape depends on the event family. See Webhook delivery for registration, queuing, retry, and transport behavior.
Event taxonomy
The event taxonomy separates inbound message events from outbound SMS state events, device health signals, and application lifecycle signals. Batch variants exist only for inbound SMS, data SMS, and MMS flows.
| Event family | Events | Payload purpose |
|---|---|---|
| Inbound SMS | sms:received | Text SMS content and receipt details |
| Inbound data SMS | sms:data-received | Base64-encoded binary SMS data and receipt details |
| Outbound SMS | sms:sent, sms:delivered, sms:failed, sms:cancelled | State changes for a sent message |
| Inbound MMS | mms:received, mms:downloaded | MMS notice before download or full content after download |
| Batch delivery | sms:batch:received, sms:batch:data-received, mms:batch:received, mms:batch:downloaded | A list of payloads from the matching inbound event |
| Device and application state | system:ping, app:started | Health status or active SIM information |
An event consumer should use the event value to select the payload schema. A batch event is not a different message model. It wraps several payloads from one supported inbound event in a messages list.
References: app/…/WebHookEvent.kt• L5-55 app/…/swagger.json• L1384-1449
Webhook envelope
The webhook envelope identifies the delivery and its source device. The payload field carries the event-specific object, so consumers can route by event before reading message or application fields.
| Field | Meaning |
|---|---|
id | Unique identifier for this webhook event delivery |
webhookId | Identifier of the registered webhook that receives the event |
event | Event name from the webhook taxonomy |
deviceId | Identifier of the device that emitted the event |
payload | Event-specific payload object |
The application creates one envelope for each registered webhook that matches the event. The same source event can therefore produce separate deliveries with different webhookId values.
References: app/…/WebHookEventDTO.kt• L3-9 app/…/WebHooksService.kt• L126-167
Message payloads
Message payloads share identifiers and phone context so an external system can join receipt and delivery events to one message. messageId identifies the message, sender identifies its source, recipient identifies its destination when known, and simNumber identifies the one-based SIM slot when the device can determine it.
phoneNumber is retained as a compatibility field. New consumers should use sender for received events and recipient for sent events. Phone context can be absent when the device cannot determine its SIM number or phone number.
| Shared field | Meaning |
|---|---|
messageId | Message identifier used across related message events |
sender | Sender phone number; for outbound events this can be the device number |
recipient | Recipient phone number; for inbound events this can be the device number |
simNumber | One-based SIM slot number, or null when unknown |
phoneNumber | Older sender-or-recipient field kept for compatibility |
Event-specific fields extend this shared model:
| Event | Additional fields |
|---|---|
sms:received | message, receivedAt |
sms:data-received | data, receivedAt |
sms:sent | partsCount, sentAt |
sms:delivered | deliveredAt |
sms:failed | failedAt, reason |
sms:cancelled | cancelledAt |
Time fields represent the event time and are serialized as date-time values. Data SMS content is Base64 encoded. A failed SMS includes a reason chosen from the message state error or an Unknown fallback.
The system:ping payload reports the current health value in a health field. It is a health signal rather than a message payload.
References: app/…/MessageEventPayload.kt• L3-11 app/…/SmsEventPayload.kt• L5-65 app/…/EventsReceiver.kt• L32-91 app/…/swagger.json• L1451-1497
MMS payloads
MMS delivery has two stages because the first notification can arrive before the message content is available. mms:received reports the incoming MMS and its download metadata. mms:downloaded reports the full message body and the attachment data available after download.
| Event | Additional fields | Meaning |
|---|---|---|
mms:received | transactionId, subject, size, contentClass, receivedAt | Early MMS notice and content metadata |
mms:downloaded | body, subject, attachments, receivedAt | Downloaded message content |
Each item in attachments contains partId, contentType, name, size, and data. data is Base64 encoded and can be null when content is not available. body and subject can also be null.
The two events use the shared message fields. Consumers that need message content should wait for mms:downloaded; consumers that only need arrival notice can act on mms:received.
The Inbound SMS and MMS capture page explains how these inbound events enter the system. The Outbound message delivery page explains the message states that produce outbound SMS events.
References: app/…/MmsReceivedPayload.kt• L5-15 app/…/MmsDownloadedPayload.kt• L5-21 app/…/ReceiverService.kt• L174-203 app/…/swagger.json• L4-112
Batch payloads
Batch payloads reduce the number of webhook requests when several inbound messages are processed together. The payload is an object with a messages list, and every list item uses the single-message model for the related event.
The supported mappings are:
| Batch event | Item payload |
|---|---|
sms:batch:received | sms:received payload |
sms:batch:data-received | sms:data-received payload |
mms:batch:received | mms:received payload |
mms:batch:downloaded | mms:downloaded payload |
The application groups messages by event type before it builds batches. It then splits each group into bounded chunks. This keeps unlike message types out of one batch and preserves the item shape that consumers already use for individual events.
References: app/…/BatchEventPayload.kt• L3-5 app/…/SmsBatchReceivedPayload.kt• L3-5 app/…/SmsDataBatchReceivedPayload.kt• L3-5 app/…/MmsBatchReceivedPayload.kt• L3-5 app/…/MmsBatchDownloadedPayload.kt• L3-5 app/…/ReceiverService.kt• L207-247
Application-started payload
The app:started event tells external consumers that the application has started and reports the active SIM cards at that point. Its payload contains a simCards list rather than message fields.
Each SIM entry describes the physical slot and the available subscription data:
| Field | Meaning |
|---|---|
slotIndex | Zero-based physical slot index |
simNumber | One-based SIM slot number |
phoneNumber | Phone number associated with the SIM, when available |
carrierName | Carrier name, when available |
iccid | SIM identifier, when available |
The event is emitted after the application starts its main services. It gives an external consumer a current device and SIM view without requiring a separate message event.
References: app/…/AppStartedPayload.kt• L3-7 app/…/SimCard.kt• L3-18 app/…/OrchestratorService.kt• L35-66 app/…/swagger.json• L1226-1249
Event-to-payload flow
Inbound capture and message state changes produce typed payloads before the webhook service adds the common envelope. The resulting event is then matched to registered consumers and enters the delivery flow described in Webhook delivery.
flowchart LR
A[Inbound SMS or MMS] --> B[Message payload]
C[Outbound message state] --> B
D[Application start or ping] --> E[System payload]
B --> F[Event name]
E --> F
F --> G[Common webhook envelope]
G --> H[Matching registered webhook]
H --> I[External consumer]
The inbound path saves the message before it emits its payload. Duplicate inbound messages do not create another event. Outbound state events are emitted per destination, so one multi-recipient message can yield separate recipient-specific deliveries.
References: app/…/ReceiverService.kt• L100-186 app/…/EventsReceiver.kt• L17-93 app/…/OrchestratorService.kt• L61-66 app/…/WebHooksService.kt• L126-170
Change checklist
When these files or sections are changed, remember to consider these:
- Update the event taxonomy and the API schema together when an event name is added, removed, or renamed.
- Keep each batch event mapped to the same item payload as its individual event. A mismatch breaks consumers that share item parsing logic.
- Preserve the shared message-field meaning across inbound and outbound events. In particular, check
sender,recipient, and the compatibilityphoneNumberfield. - Update both MMS stages when message identifiers or attachment fields change. Consumers may use
mms:receivedas the key for latermms:downloadedcontent. - Keep
app:startedSIM field names aligned with the SIM model used by the device and API schema. - Treat date-time and Base64 fields as external data contracts. A format change affects every event consumer.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Consumer parses only the single-message schema for a batch event | The top-level messages list is not processed | Branch on the event value before decoding payload |
Consumer treats mms:received as full MMS content | The consumer acts before body or attachment data is available | Use mms:downloaded for content-dependent work |
| SIM or phone data is unavailable | simNumber, recipient, or SIM-card fields can be null | Handle missing device subscription data without rejecting the event |
| Data SMS or attachment content is decoded as plain text | Binary content is corrupted | Base64-decode data fields before use |
| One outbound message has multiple recipients | State events arrive as separate recipient-specific deliveries | Correlate by messageId and recipient |
| An inbound message is detected as a duplicate | No new payload is emitted for that message | Use the message identifier and event history as an idempotency key |
Key files
| File | Why to read it |
|---|---|
| app/…/WebHookEvent.kt | Defines the event names and supported batch relationships |
| app/…/WebHookEventDTO.kt | Defines the common webhook envelope |
| app/…/MessageEventPayload.kt | Defines fields shared by message events |
| app/…/SmsEventPayload.kt | Defines SMS receipt and outbound state payloads |
| app/…/MmsReceivedPayload.kt | Defines the pre-download MMS notice |
| app/…/MmsDownloadedPayload.kt | Defines downloaded MMS content and attachment data |
| app/…/ReceiverService.kt | Connects inbound SMS/MMS records to individual and batch webhook payloads |
| app/…/EventsReceiver.kt | Connects outbound message states and system pings to webhook events |
| app/…/OrchestratorService.kt | Emits the application-started event |
| app/…/swagger.json | Publishes the external event and payload schema |