Example apps
Two small, complete apps live in the YASend repository under examples/. Each one:
- sends a one-time code through
POST /v1/messages?async=true(with anIdempotency-Keyand a 5-minute expiry); - receives the
message.sent/message.failedwebhook, verifyingX-YASend-Signature-V2.
| App | Run |
|---|---|
examples/otp-node (Node.js 18+, no dependencies) |
YASEND_KEY=… YASEND_SESSION_ID=… WEBHOOK_SECRET=… node send-otp.mjs 963912345678 |
examples/otp-python (Python 3.10+, requests) |
YASEND_KEY=… YASEND_SESSION_ID=… python send_otp.py 963912345678 |
Set YASEND_API_URL to point either app at a different server.
The Node app also starts a webhook receiver (--listen 8080), which prints each verified event. Make
it reachable from the internet, for example with a tunnel, and register its URL with
POST /v1/webhooks.
The same flow runs in YASend's own test suite on every change, so these samples are kept working.