Before you start
- You need to have Node.js installed on your machine.
- You need to have a Rewrite API key with the permissions.
Set up REWRITE_API_KEY environment variable
Set up your Rewrite API key in your environment variables.
.env
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Learn how to use the Node.js SDK to send SMS with the API.
npm install @rewritetoday/sdk
yarn add @rewritetoday/sdk
pnpm add @rewritetoday/sdk
bun install @rewritetoday/sdk
REWRITE_API_KEY=rw...
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY);
async function sendSms(to: string) {
const params = {
to,
content: 'Your OTP code is 478201',
};
const { data, error } = await rewrite.messages.send(params);
if (error) {
throw error;
}
return data;
}
async function main() {
const message = await sendSms('+1234567890');
console.log(message);
}
main().catch(console.error);