import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY!);
const { data, error } = await rewrite.messages.send({
to: '+5511999999999',
content: 'Rewrite: seu codigo e 478201',
tags: { flow: 'login', origin: 'checkout' },
});
if (error) throw error;{
"ok": true,
"data": {
"id": "748395130237498412",
"createdAt": "2026-03-20T14:22:31.562Z",
"analysis": {
"characters": 28,
"encoding": "gsm7",
"segments": {
"concat": 153,
"count": 1,
"reason": "fits",
"single": 160
}
},
"sandbox": false
}
}Send a message
Send one SMS with inline content or by rendering a saved template. You can target either a direct E.164 number in to or a saved project contact in contact. Projects with international numbers enabled can send beyond the default +55 traffic profile.
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY!);
const { data, error } = await rewrite.messages.send({
to: '+5511999999999',
content: 'Rewrite: seu codigo e 478201',
tags: { flow: 'login', origin: 'checkout' },
});
if (error) throw error;{
"ok": true,
"data": {
"id": "748395130237498412",
"createdAt": "2026-03-20T14:22:31.562Z",
"analysis": {
"characters": 28,
"encoding": "gsm7",
"segments": {
"concat": 153,
"count": 1,
"reason": "fits",
"single": 160
}
},
"sandbox": false
}
}Authorizations
Send your API key as Authorization: Bearer rw_....
Required scope: message:write.
Headers
Optional key used to safely retry the same create request without creating duplicates.
1 - 64"msg:login-otp:2026-03-20T14:22"
Body
- With content and direct number
- With content and saved contact
- Using templates and direct number
- Using templates and saved contact
Destination number in E.164 format.
"+5511999999999"
Rendered SMS content to send.
1 - 1600"Rewrite: seu codigo e 478201"
Optional metadata stored with the message.
{ "flow": "login", "origin": "checkout" }
When provided, Rewrite schedules the message for later delivery.
"2026-03-20T14:30:00.000Z"
Optional segmentation rules for long SMS bodies.
Show child attributes
Show child attributes