@rewritetoday/sdk, the official Node.js/TypeScript SDK for the Rewrite API.
It wraps authentication, typed REST calls, and resource helpers on top of @rewritetoday/rest and @rewritetoday/types.
Use your preferred package manager:
bun add @rewritetoday/sdk
# Or
npm install @rewritetoday/sdk
# Or
pnpm add @rewritetoday/sdkFirst, you need to create an API key in the Rewrite Dashboard and use it in the constructor.
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY);import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite({
secret: 'rw_...',
rest: {
timeout: 10_000,
headers: {
'User-Agent': 'StatusPage One (1.0.0)',
},
retry: {
max: 3,
delay(attempt) {
return attempt * 250;
},
},
},
});const { data, error } = await rewrite.messages.send({
to: '+551234567890',
content: 'Hey, Rewrite is here!',
});You can view in our documentation everything in you can use when sending a message.
Requests run through @rewritetoday/rest. HTTP failures can throw HTTPError.
import { HTTPError } from '@rewritetoday/rest';
try {
await rewrite.projects.get('invalid_id');
} catch (error) {
if (error instanceof HTTPError) {
console.error('HTTP Error:', error.status, error.method, error.url);
}
}Made with 🤍 by the Rewrite team.
SMS the way it should be.