Skip to main content

Overview

Hypersender sends an SMS webhook to your URL when a message is sent, delivered, fails, or expires, when your phone receives an SMS, and when the phone goes online or offline. You receive it with your own route. The SDK is only needed when you reply. A webhook is a POST with a JSON body and your secret in the Authorization header, so any Python framework can handle it. The examples use Flask and FastAPI.

Set up the webhook

1

Add the webhook in the dashboard

In the Hypersender dashboard, open your SMS instance, add a webhook with your public HTTPS URL, for example https://example.com/sms/webhook, and pick the events you want.
2

Set a secret

Set an Authorization Secret on the webhook. Hypersender sends it in the Authorization header so you can reject requests that did not come from Hypersender. Save the same value as HYPERSENDER_SMS_WEBHOOK_SECRET.
3

Answer quickly

Reply with a 2xx status right away. If handling an event takes time, store the payload and process it in the background.

Receive and verify webhooks

The secret is sent exactly as you saved it, with no Bearer prefix. Compare it with hmac.compare_digest, not ==.

Payload

Every SMS webhook has two keys: event and data. For message events, data is the message:
For phone.* events, data is the phone, with fields such as is_online, last_heartbeat_at, and phone_number. request_id is the value you passed to send_message, so you can match a delivery report to your own record. The SMS webhooks reference shows every field and header.

SMS webhook events

Handle each event

Route on event. This example auto-replies to incoming SMS, tracks delivery, and alerts when the phone goes offline:
Call handle(body["event"], body["data"]) from your route after the secret check. For slow work, hand it to a background task (FastAPI BackgroundTasks, Celery, RQ) and return right away.

Retries and duplicates

If your endpoint does not answer with a 2xx in time, Hypersender retries, so the same event can arrive more than once and out of order.
  • Use event plus data["id"] (and data["status"] for message events) as the key to skip duplicates.
  • Compare updated_at before overwriting a newer state.

Next steps

Last modified on November 24, 2026