Code Examples

The same set of common operations, written three times: once with curl and shell tools, once in TypeScript and once in Python. Each page starts with a small helper that unwraps the response envelope and retries rate-limited requests; every later snippet builds on it and runs once you substitute the placeholders.

  • curl — shell and jq, plus openssl for webhook signatures
  • TypeScript — Node.js 18+ fetch and node:crypto, no dependencies
  • Python — Python 3.9+ with requests; the webhook receiver uses only the standard library

Every page covers:

Operation Endpoint Key scope
Check the API key GET /me any key
Send a transactional email with tags and metadata, schedule and cancel it POST /transactional/send, DELETE /transactional/{message_id} email:send
Send a batch of up to 100 transactional emails POST /transactional/send-batch email:send
Look up a message and list messages by tag GET /messages/{id}, GET /messages?tag= messages:read
Request and verify an OTP code POST /otp/request, POST /otp/verify otp:send, otp:verify
Create and launch a campaign, resolving same-day conflicts POST /campaigns, POST /campaigns/{id}/send campaigns:write, email:send
Create a webhook and verify delivery signatures POST /webhooks webhooks:write
Handle errors and retry on 429 rate_limited any —
Page through a list with meta.cursor GET /messages messages:read

All examples use the base URL https://emails.routeon.io/api/v1 and authenticate with Authorization: Bearer <API_KEY>; create keys in the customer portal at https://emails.routeon.io under "API keys". The placeholders stand for your own values:

Placeholder What to put there
<API_KEY> An API key with the scopes listed above
<DOMAIN_ID> A verified sending domain (Verify a sending domain)
<TRANSACTIONAL_TEMPLATE_ID> An active template of class transactional
<OTP_TEMPLATE_ID> An active template of class critical
<MARKETING_TEMPLATE_ID> An active template of class marketing, for campaigns
<SENDER_PROFILE_ID> A sender profile id from GET /senders (optional)
<LIST_ID> A contact list id from GET /lists
<MESSAGE_ID>, <CAMPAIGN_ID>, <OTP_ID> Ids returned by earlier calls
<FUTURE_ISO8601_TIMESTAMP> A time with an explicit UTC offset, later than now and at most 30 days ahead
<WEBHOOK_SECRET> The secret returned when the webhook was created
<CODE_FROM_USER> The digits the recipient typed

Templates are described in Templates; every code the examples branch on is listed in Errors, and the numbers behind the retry logic are in Limits.