Node.js
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY!);
const { data, error } = await rewrite.otp.send({
to: '+5511999999999',
prefix: 'Rewrite',
expiresIn: 5,
idempotencyKey: 'otp:login:2026-03-20T14:22',
});
if (error) throw error;{
"ok": true,
"data": {
"id": "748395130237499120",
"to": "+5511999999999",
"prefix": "Rewrite",
"createdAt": "2026-03-20T14:22:31.562Z",
"expiresAt": "2026-03-20T14:27:31.562Z"
}
}OTP
Send an OTP code
Create and send an OTP SMS to a direct destination number or a saved contact.
POST
/
otp
Node.js
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY!);
const { data, error } = await rewrite.otp.send({
to: '+5511999999999',
prefix: 'Rewrite',
expiresIn: 5,
idempotencyKey: 'otp:login:2026-03-20T14:22',
});
if (error) throw error;{
"ok": true,
"data": {
"id": "748395130237499120",
"to": "+5511999999999",
"prefix": "Rewrite",
"createdAt": "2026-03-20T14:22:31.562Z",
"expiresAt": "2026-03-20T14:27:31.562Z"
}
}Autorizações
Send your API key as Authorization: Bearer rw_....
Required scope: message:write.
Cabeçalhos
Optional key used to safely retry the same create request without creating duplicates.
Required string length:
1 - 64Exemplo:
"msg:login-otp:2026-03-20T14:22"
Corpo
application/json
- With direct number
- With saved contact