Android Sms Gateway Server Webhook: In-Depth Guide

Featured illustration for Android Sms Gateway Server Webhook: In-Depth Guide

Your HTTPS URL receives signed delivery and inbound events. Verify HMAC, dedupe event ids, ack fast. The radio still spends operator airtime.

Written by the SMS Gateway team for operators who run phones and airtime themselves — not for theoretical cloud SMS demos.

InformationAndroid SMS GatewayIn-DepthHub F
Article
Published
March 1, 2026
Updated
April 9, 2026
Reading time
7 minute read

Key Takeaways

  • An Android SMS gateway server webhook is your HTTPS endpoint receiving signed POSTs for DLR and inbound SMS.
  • Verify X-SmsGateway-Signature = v1=hex(HMAC-SHA256("{timestamp}.{body}", secret)). Reject stale timestamps.
  • Deduplicate on X-SmsGateway-Event-Id. A retry is the same event, not a license to send again.
  • Register URLs via the webhooks API; live event names live in Developer Center.
  • You bring phones and airtime. Pricing is devices plus send volume.

Android sms gateway server webhook is the backend half of two-way and DLR: a public HTTPS URL you own, signed POSTs, and a unique constraint on event id. Product page: webhooks. API spoke: API webhook in-depth.

Live contract: Developer Center. You bring the phone and airtime. We meter devices and volume.

POST /hooks/sms

X-SmsGateway-Signature: v1=…

Your server is the subscriber

Register at POST /api/v1/webhooks. The control plane POSTs JSON. The Android does not open a hole in your VPC — you publish a URL the plane can reach.

A 200 you return after enqueueing work is enough. A 500 makes us retry. Retry plus a non-idempotent handler is how you double-text.

HMAC headers

X-SmsGateway-Signature = v1=hex(HMAC-SHA256("{timestamp}.{body}", secret)). Timestamp is X-SmsGateway-Timestamp (unix seconds). Deduplicate on X-SmsGateway-Event-Id. HMAC background: RFC 2104.

Illustrative delivered payload:

{
  "id": "evt_01K2F8QW3N4RXB7M",
  "type": "message.delivered",
  "createdAt": "2026-08-12T14:04:09Z",
  "apiVersion": "2026-08-12",
  "data": {
    "message": {
      "id": 41823,
      "number": "+14155552671",
      "text": "Your verification code is 481920",
      "status": "Delivered",
      "campaignId": 17,
      "deviceId": 3,
      "metadata": { "orderId": "1234" },
      "sentAt": "2026-08-12T14:04:02Z",
      "deliveredAt": "2026-08-12T14:04:09Z"
    }
  }
}

PHP receiver sample

<?php
header('Content-Type: application/json');

$secret = getenv('SMS_GATEWAY_WEBHOOK_SECRET');
$timestamp = $_SERVER['HTTP_X_SMSGATEWAY_TIMESTAMP'] ?? '';
$sigHeader = $_SERVER['HTTP_X_SMSGATEWAY_SIGNATURE'] ?? '';
$eventId = $_SERVER['HTTP_X_SMSGATEWAY_EVENT_ID'] ?? '';
$body = file_get_contents('php://input');

if ($timestamp === '' || $sigHeader === '' || $secret === '') {
    http_response_code(400);
    echo json_encode(['error' => 'missing_signature']);
    exit;
}

if (abs(time() - (int) $timestamp) > 300) {
    http_response_code(401);
    echo json_encode(['error' => 'stale_timestamp']);
    exit;
}

$expected = 'v1=' . hash_hmac('sha256', $timestamp . '.' . $body, $secret);
$ok = false;
foreach (preg_split('/\s+/', $sigHeader) as $candidate) {
    if (hash_equals($expected, $candidate)) {
        $ok = true;
        break;
    }
}
if (!$ok) {
    http_response_code(401);
    echo json_encode(['error' => 'bad_signature']);
    exit;
}

// Deduplicate on X-SmsGateway-Event-Id (retries and replays reuse it).
$data = json_decode($body, true) ?: [];
$type = $data['type'] ?? '';
$message = $data['data']['message'] ?? [];

if ($type === 'message.received') {
    $from = $message['number'] ?? '';
    $text = $message['text'] ?? '';
    error_log("Inbound SMS $eventId from $from: $text");
}

http_response_code(200);
echo json_encode(['ok' => true]);

C# pattern lives with C# samples. PHP: PHP samples. Those are REST examples, not a packaged SDK product.

Event handling

typeYour jobDo not
message.delivered / failedUpdate order/OTP row; unique on event idPOST /messages again from the handler
message.receivedParse STOP vs YES/NO with a policyTreat every inbound as marketing consent
Unknown type200 + log; do not 500-loopCrash the worker

Retries are not new events

Same event id ⇒ same row. If you auto-reply, that outbound send needs its own Idempotency-Key. Idempotent send · duplicate sends.

Public HTTPS, not localhost

ngrok for staging is fine. Production needs a stable cert and a secret in env — never in the APK. API keys in env.

Webhooks are not SMS credit

Callbacks are HTTP. Radio sends still burn operator airtime and platform volume. Free: 300 SMS lifetime. Developer: 25,000/year. Starter/Pro/Business uncap platform volume, devices 2/5/15. Pause on Free/Developer at allowance. No unlimited carrier SMS.

Pricing.

Checklist

  • Signature + timestamp window + event-id unique index.
  • 200 after persist; heavy work async.
  • Inbound STOP vs operational keywords written down.
  • Webhook secret rotated like the API key.

Next steps

Point staging at the PHP sample, send one OTP, confirm delivered + received events once each. Two-way SMS.

Jump to the live product docs for this topic—not another long-form article.

FAQ

Frequently asked questions

Direct answers about android sms gateway server webhook.

What is an Android SMS gateway server webhook?

Your application server accepts POST callbacks when a message is delivered, fails, or an inbound SMS hits the paired phone. The Android is the radio; the webhook is how your backend learns.

How do I verify the webhook?

HMAC-SHA256 over timestamp + "." + raw body, header v1=hex. Compare with hash_equals. Confirm header names in docs if they ever change.

Should I send SMS from inside the webhook handler?

Only with a new business event and a new Idempotency-Key. Replaying message.delivered must not fire another SMS.

Do webhooks cost extra SMS?

No. They are HTTP. Operator airtime is still per radio send. Free is 300 SMS lifetime.
Keep learning

Topically related guides—chosen by subject overlap, not a fixed sitewide footer.

Information
android sms gateway server delivery reports

Android Sms Gateway Server Delivery Reports: In-Depth Guide

Android Sms Gateway Server Delivery Reports: In-Depth Guide. Long-tail article focused on exact query "android sms gateway server delivery reports". Expand with examples, limits, FAQ, and links to hub F. Priced by devices and SMS send volume; BYO phone and operator credit. Developer Center owns live API parameters.

Oct 21, 202516 min
Read article
Information
android sms gateway server dual sim

Android Sms Gateway Server Dual Sim: In-Depth Guide

Android Sms Gateway Server Dual Sim: In-Depth Guide. Long-tail article focused on exact query "android sms gateway server dual sim". Expand with examples, limits, FAQ, and links to hub F. Priced by devices and SMS send volume; BYO phone and operator credit. Developer Center owns live API parameters.

Nov 22, 202516 min
Read article
Information
android sms gateway server for bulk sms

Android Sms Gateway Server For Bulk Sms: In-Depth Guide

Android Sms Gateway Server For Bulk Sms: In-Depth Guide. Long-tail article focused on exact query "android sms gateway server for bulk sms". Expand with examples, limits, FAQ, and links to hub F. Priced by devices and SMS send volume; BYO phone and operator credit. Developer Center owns live API parameters.

Mar 8, 202616 min
Read article
Information
android sms gateway server for otp verification

Android Sms Gateway Server For Otp Verification: In-Depth Guide

Android Sms Gateway Server For Otp Verification: In-Depth Guide. Long-tail article focused on exact query "android sms gateway server for otp verification". Expand with examples, limits, FAQ, and links to hub F. Priced by devices and SMS send volume; BYO phone and operator credit. Developer Center owns live API parameters.

May 26, 202616 min
Read article

Browse the full Android SMS gateway knowledge base or return to how an Android SMS gateway works.

Get started

Test the gateway on your own Android phone

Install the app, pair one device, and validate your API flow before choosing a paid plan.

You supply the phone, SIM, and operator SMS credit.