Dialx402
x402 pay-per-requestNo API keysProvider-agnostic

Paid SMS endpoints, enforced by 402.

Dial x402 is a minimal paywall primitive for route handlers: if a request isn’t paid, return 402 with the action + price. If it is, send the message and record a receipt.

No signup
client learns price via 402
1 header
x-payment (stub today)
Typed + modular
Next + pnpm + Turbo
Paid endpoint
POST /api/v1/messages/send
Quick start (local)
curl -X POST "http://localhost:3721/api/v1/messages/send" \
  -H "content-type: application/json" \
  --data-raw '{"from":"+1","to":"+1","body":"test"}'
Missing PAYMENT-SIGNATURE returns 402 + a PAYMENT-REQUIRED offer.

How it works

The same flow every time: learn price, pay, retry.

01
Return a priced 402

Unpaid requests get 402 with aPAYMENT-REQUIRED offer describing accepted payment options.

02
Execute the side effect

Send SMS to any phone number worldwide. Pay $0.01 USDC, get delivery confirmation. Next: provision numbers, inbound webhooks.

03
Persist receipts

Record request + payment receipt in Postgres (Drizzle). Upgrade from a stub header to verified x402 later.

Key features

Small pieces that map cleanly to production.

Priced 402 responses

Clients can discover pricing and retry with payment—no sessions, no API keys, no onboarding funnel.

Provider isolation

Keep provider logic isolated behind a thin adapter. Swap providers later without rewriting your API surface.

Monorepo velocity

Turbo + pnpm workspaces. Small packages, clean boundaries, fast iteration.

Production-shaped API

Next.js app router API routes, ready for Vercel. Add Postgres and webhooks when you need them.

Paid primitives

Same contract for everything: get a priced 402, pay, retry, receive a receipt.

Send SMS
Live
action: "send_sms"

Send text messages to any phone number worldwide for $0.01 USDC per message. The paywall contract stays the same.

Buy a number
Stub live
action: "buy_number"

Provision numbers via provider backends with x402 gating and a clean purchase receipt.

Order an eSIM
Stub live
action: "order_esim"

Guest checkout vibes: priced 402 → pay → receive activation/QR codes. Inspired by flows like Crypton’s guest eSIM API.

Verify a code
Stub live
action: "start_verification"

Pay per verification / rental with receipts, webhooks, and pagination-friendly list responses.

Example priced 402 payload
HTTP/1.1 402 Payment Required
content-type: application/json
payment-required: <base64-json-offer>

{
  "x402Version": 2,
  "error": "Payment required",
  "accepts": [ ... ]
}
Other live stubs (same contract)
# Buy a number (stub)
curl -X POST http://localhost:3721/api/v1/numbers/buy \
  -H "content-type: application/json" \
  -d '{"country":"US"}'

# eSIM checkout (stub)
curl -X POST http://localhost:3721/api/v1/esim/checkout \
  -H "content-type: application/json" \
  -d '{"packageId":"DE_1_7"}'

# Start verification (stub)
curl -X POST http://localhost:3721/api/v1/verifications/start \
  -H "content-type: application/json" \
  -d '{"service":"discord"}'

Quickstart

Try the endpoint. Get a priced 402. Retry with payment.

1) Expect a 402
curl -X POST http://localhost:3721/api/v1/messages/send \
  -H "content-type: application/json" \
  -d '{"from":"+1","to":"+1","body":"test"}'
2) Add payment (stub) to succeed
curl -X POST http://localhost:3721/api/v1/messages/send \
  -H "x-payment: fake" \
  -H "content-type: application/json" \
  -d '{"from":"+1","to":"+1","body":"test"}'