Node.js
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY!);
const { data, error } = await rewrite.messages.batch(
[
{
to: '+5511999999999',
content: 'Rewrite: seu codigo e 478201',
},
{
to: '+5511888888888',
templateId: '748395130237498620',
variables: { code: '941205' },
},
],
{
idempotencyKey: 'msg:batch:login-otp:2026-03-20T14:22',
},
);
if (error) throw error;{
"ok": true,
"data": {
"ids": [
"748395130237498412",
"748395130237498413",
"748395130237498414"
]
}
}Messages
Send batch messages
Send between 1 and 100 SMS messages in one request. Each entry can target either a direct E.164 number or a saved project contact, and Rewrite returns only the accepted message IDs.
POST
/
messages
/
batch
Node.js
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY!);
const { data, error } = await rewrite.messages.batch(
[
{
to: '+5511999999999',
content: 'Rewrite: seu codigo e 478201',
},
{
to: '+5511888888888',
templateId: '748395130237498620',
variables: { code: '941205' },
},
],
{
idempotencyKey: 'msg:batch:login-otp:2026-03-20T14:22',
},
);
if (error) throw error;{
"ok": true,
"data": {
"ids": [
"748395130237498412",
"748395130237498413",
"748395130237498414"
]
}
}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.
Required string length:
1 - 64Example:
"msg:login-otp:2026-03-20T14:22"
Body
application/json
Required array length:
1 - 100 elements- 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.
Example:
"+5511999999999"
Rendered SMS content to send.
Required string length:
1 - 1600Example:
"Rewrite: seu codigo e 478201"
Optional metadata stored with the message.
Example:
{ "flow": "login", "origin": "checkout" }
When provided, Rewrite schedules the message for later delivery.
Example:
"2026-03-20T14:30:00.000Z"
Optional segmentation rules for long SMS bodies.
Show child attributes
Show child attributes