To receive an SMS reply, expose an HTTPS endpoint, give its URL to your messaging provider as a webhook, and answer with a 200 as soon as you've stored the event. Do the real work after you respond. Express and Flask both handle this in about twenty lines.

The part people get wrong isn't parsing the request. It's everything around it: checking the call is genuine, surviving the same event arriving twice, and not letting a slow database turn into a retry storm. The general model is in our post on receiving SMS through inbound webhooks. This one is the code. We make Ready, and the docs list the exact webhook fields, so the handlers below treat the payload as JSON and leave field names to you.

Express

import express from 'express';
const app = express();

app.post('/webhooks/sms', express.raw({ type: 'application/json' }), async (req, res) => {
  // 1. Verify the call is from your provider (see the signing post) using req.body as raw bytes.
  // 2. Store the raw event, then answer.
  await db.events.insertIfNew(req.body);   // unique key makes repeats harmless
  res.sendStatus(200);
  queue.add('handle-inbound-sms');          // real work happens after the response
});

app.listen(3000);

Use the raw body for signature checks. If a JSON parser runs first, the bytes change and the check fails.

Flask

from flask import Flask, request

app = Flask(__name__)

@app.post("/webhooks/sms")
def inbound_sms():
    raw = request.get_data()              # raw bytes for the signature check
    # verify the signature here, then store
    inserted = db.events.insert_if_new(raw)
    if inserted:
        enqueue("handle_inbound_sms")
    return "", 200

The four rules that matter

  1. Answer fast. Store, respond, process later. A handler that waits on a CRM call will time out under load and invite retries.
  2. Make repeats harmless. Webhooks are delivered at least once. A unique key on the event ID means a second delivery changes nothing. See webhook deduplication.
  3. Verify before trusting. Anyone can post to a public URL. Authentication and webhook signing covers the check.
  4. Handle STOP as a fact, not a message. Ready already honors a STOP and blocks that number. Your handler should update your own records, not decide whether to send again.

Testing locally

Run the server, expose it with a tunnel, and send yourself a reply from a phone. The local webhook testing guide covers tunnels and replaying saved events. A received reply is billed at $0.0075 per segment plus the lower $0.003 received carrier fee, so test with a handful, not a loop.

Frequently asked questions

Should I return 200 even if my processing fails? Return 200 once the event is safely stored. Processing failures belong in your queue's retry, not the webhook response.

What if my endpoint is down? Providers retry for a while, but don't rely on it. Have a way to backfill by reading messages with GET /v1/messages, which pages with before_id.

Do I need separate endpoints for replies and delivery reports? Not required. Many teams use one endpoint and branch on event type. See delivery reports over webhooks.

Next step

Deploy the handler, point your webhook at it, text your number from your own phone and check the event lands once. The API quickstart shows where to set the webhook.

Accounts opened before November 12, 2026 keep their signup prices, shown under Billing.