Send SMS With Rewrite
Implement outbound SMS against the current public Rewrite API contract.
Workflow
- Install client dependencies from
references/installation.md.
- Choose one target shape:
- direct number:
to
- stored contact:
contact as contact ID or exact contact name
- Choose one content shape:
- inline body: target plus
content
- template body: target plus
templateId plus variables
- Use
/contacts when recipients need stable metadata such as name, channel, or per-contact tags.
- Use
/segments and /segments/:id/contacts to maintain reusable audiences. There is no direct segment-send endpoint; list the segment contacts, then call /messages or /messages/batch.
- Add optional
tags, scheduledAt, and segmentation only when required by the flow.
- Attach
Idempotency-Key to every create/send action.
- Persist the accepted message ID plus the returned
analysis.
- Register webhooks before production rollout and treat delivery as asynchronous.
- Use batch sends only for 1 to 100 messages per request.
Delivery Design Rules
- Use Brazilian
+55 E.164 numbers on the public API unless the project explicitly supports international numbers.
- Prefer
contact over raw to when the same recipient will be reused, tagged, or segmented.
- If you target
contact by name, keep the name unique and stable per project because lookup is exact.
- Sending with raw
to still ensures a Rewrite contact exists for that phone number.
- Prefer templates for repeated or locale-aware flows.
- Keep OTP and transactional content short and watch segmentation counts.
- Retry only
429 and transient 5xx.
- Treat
400, 401, and commercial 403 blocks as non-retryable until fixed.
- Do not require
message.delivered for critical workflows; it is still WIP in the public docs.
Quick Example
Single SMS send via REST:
curl -X POST https://api.rewritetoday.com/v1/messages \
-H "Authorization: Bearer $REWRITE_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"to": "+5511999999999", "content": "Your code is 4821"}'
Resource Map
- Install, SDK selection, CLI, and ecosystem packages:
references/installation.md
- Contacts, segments, and audience orchestration:
references/contacts-and-segments.md
- Single-send implementation patterns:
references/single-sms-examples.md
- Batch and queue patterns:
references/batch-sms-examples.md
- Template i18n rules:
references/template-i18n.md
- Delivery and webhook lifecycle:
references/delivery-lifecycle.md
- Production guardrails:
references/best-practices.md
Output Contract
Persist or return the accepted response. Expected shape:
{
"id": "msg_abc123",
"status": "accepted",
"to": "+5511999999999",
"createdAt": "2026-04-06T12:00:00Z",
"analysis": { "encoding": "GSM-7", "characters": 22, "segments": 1 },
"idempotencyKey": "550e8400-e29b-41d4-a716-446655440000",
"tags": []
}
1---2name: send-sms3description: Production SMS delivery workflow for Rewrite. Use when the agent needs to send transactional or campaign SMS, manage Rewrite contacts or segments, implement batching, enforce idempotency, use templates and scheduling, and integrate the official Rewrite SDKs, REST client, CLI, or ecosystem packages.4---56# Send SMS With Rewrite78Implement outbound SMS against the current public Rewrite API contract.910## Workflow11121. Install client dependencies from `references/installation.md`.132. Choose one target shape:14- direct number: `to`15- stored contact: `contact` as contact ID or exact contact name163. Choose one content shape:17- inline body: target plus `content`18- template body: target plus `templateId` plus `variables`194. Use `/contacts` when recipients need stable metadata such as `name`, `channel`, or per-contact `tags`.205. Use `/segments` and `/segments/:id/contacts` to maintain reusable audiences. There is no direct segment-send endpoint; list the segment contacts, then call `/messages` or `/messages/batch`.216. Add optional `tags`, `scheduledAt`, and `segmentation` only when required by the flow.227. Attach `Idempotency-Key` to every create/send action.238. Persist the accepted message ID plus the returned `analysis`.249. Register webhooks before production rollout and treat delivery as asynchronous.2510. Use batch sends only for 1 to 100 messages per request.2627## Delivery Design Rules2829- Use Brazilian `+55` E.164 numbers on the public API unless the project explicitly supports international numbers.30- Prefer `contact` over raw `to` when the same recipient will be reused, tagged, or segmented.31- If you target `contact` by name, keep the name unique and stable per project because lookup is exact.32- Sending with raw `to` still ensures a Rewrite contact exists for that phone number.33- Prefer templates for repeated or locale-aware flows.34- Keep OTP and transactional content short and watch segmentation counts.35- Retry only `429` and transient `5xx`.36- Treat `400`, `401`, and commercial `403` blocks as non-retryable until fixed.37- Do not require `message.delivered` for critical workflows; it is still WIP in the public docs.3839## Quick Example4041Single SMS send via REST:4243```bash44curl -X POST https://api.rewritetoday.com/v1/messages \45 -H "Authorization: Bearer $REWRITE_API_KEY" \46 -H "Idempotency-Key: $(uuidgen)" \47 -H "Content-Type: application/json" \48 -d '{"to": "+5511999999999", "content": "Your code is 4821"}'49```5051## Resource Map5253- Install, SDK selection, CLI, and ecosystem packages: `references/installation.md`54- Contacts, segments, and audience orchestration: `references/contacts-and-segments.md`55- Single-send implementation patterns: `references/single-sms-examples.md`56- Batch and queue patterns: `references/batch-sms-examples.md`57- Template i18n rules: `references/template-i18n.md`58- Delivery and webhook lifecycle: `references/delivery-lifecycle.md`59- Production guardrails: `references/best-practices.md`6061## Output Contract6263Persist or return the accepted response. Expected shape:6465```json66{67 "id": "msg_abc123",68 "status": "accepted",69 "to": "+5511999999999",70 "createdAt": "2026-04-06T12:00:00Z",71 "analysis": { "encoding": "GSM-7", "characters": 22, "segments": 1 },72 "idempotencyKey": "550e8400-e29b-41d4-a716-446655440000",73 "tags": []74}