open-index/open-npm huggingface dataset:
npm package: @rewritejs/rest
Description: A comprehensive REST client for Rewrite API
Latest version: 1.0.2

<div align="center">

# Rewrite REST

A **REST** client for the **Rewrite API** — fast, secure, and reliable.<br/>
[@rewritejs/rest](https://www.npmjs.com/package/@rewritejs/rest) is a lightweight, fully typed HTTP client designed to interact seamlessly with the **Rewrite API**.

Built for Node.js, Bun, and modern runtimes, it includes smart retries, timeout control, consistent error handling, and a clean developer experience for sending and managing SMS at scale.

## Installing

You can use your favorite package manager to install our package

</div>

```bash
npm install @rewritejs/rest
# Or
yarn add @rewritejs/rest
# Or
bun add @rewritejs/rest
```

<div align="center">

## Using the REST Client

You can use any route, any method, and any payload to interact with the Rewrite API.

</div>

```ts
import { REST } from '@rewritejs/rest';

const client = new REST(process.env.REWRITE_API_KEY);

const data = await client.post('/messages', {
	data: {
		to: '+1234567890',
		message: 'Hey, using REST here',
	},
});

console.log({ data });
```

<div align="center">

### Retry & Backoff (Delay)

By default, our **REST** client try 3 times with a Jitter delay between each attempt.<br/> But you can customize easily in the `retry` option.

</div>

```ts
const client = new REST({
	auth: process.env.REWRITE_API_KEY,
	retry: {
		max: 5,
		delay(attempt) {
			return attempt * 0.5;
		},
	},
	timeout: 3_000,
});
```

<div align="center">

You can also use callback function to execute **before** each request:

</div>

```ts
const client = new REST({
	auth: process.env.REWRITE_API_KEY,
	retry: {
		max: 7,
		async onRetry({ response }) {
			const { error } = await response.json();
			
			console.error({ error });
		},
	},
});
```

<div align="center">

## Handling Errors

Our **REST Client** handles errors gracefully and provides a consistent error handling experience.

</div>

```ts
import { REST, HTTPError } from '@rewritejs/rest';

const client = new REST(process.env.REWRITE_API_KEY);

try {
	const data = await client.get('/projects/invalid', {
		query: {
			...
		},
	});
} catch (error) {
	if (error instanceof HTTPError) {
		console.error({ error });
	}
}
```

<div align="center">

You can view our documentation going [here](https://docs.rewritetoday.com/en/api-reference/errors). Thanks for using our REST Client!

</div>
npm package: @rewritejs/types
Description: Official Rewrite API typings that are always up to date
Latest version: 1.0.0

<div align="center">

# Rewrite Types

[@rewritejs/types](https://www.npmjs.com/package/@rewritejs/types), an official **TypeScript types** for the **Rewrite API**.

This package provides shared resource models, request/response contracts, and route builders used by Rewrite SDKs and applications. It is designed to keep API integrations strongly typed and consistent across projects.

## Installation

You can use this package with your *favorite package manager*

</div>

```bash
bun add @rewritejs/types
```

<div align="center">

Or with npm:

</div>

```bash
npm install @rewritejs/types
```

<div align="center">

## Usage

### Importing v1 Types

</div>

```ts
import type {
	APIResponse,
	RESTGetProjectData,
	RESTPostCreateWebhookBody,
} from '@rewritejs/types/v1';
```

<div align="center">

### Typing API Responses

</div>

```ts
import type { RESTGetProjectData } from '@rewritejs/types/v1';

async function getProject(projectId: string): Promise<RESTGetProjectData> {
	// Your HTTP call here
	return {
		ok: true,
		data: {
			id: '123456789012345678',
			name: 'My Project',
			ownerId: '987654321098765432',
			icon: 'https://cdn.rewritetoday.com/users/123456789012345678/abc.webp',
		},
	};
}
```

<div align="center">

### Using Route Builders

</div>

```ts
import { API_BASE_URL, Routes } from '@rewritejs/types/v1';

const projectId = '123';
const webhookId = '999';

const url = `${API_BASE_URL}/v1${Routes.webhooks.get(projectId, webhookId)}`;
// https://api.rewritetoday.com/v1/projects/123/webhooks/999
```

<div align="center">

### Cursor Query Helper

</div>

```ts
import { createCursorQuery } from '@rewritejs/types/v1/utils';

const query = createCursorQuery({ limit: 20, after: '1000' }).toString();
// limit=20&after=1000
```

<div align="center">

Made with 🤍 by the Rewrite team. <br />
SMS the way it should be.

</div>
npm package: @rewritejs/zod
Description: Official Zod schemas for the Rewrite API.
Latest version: 1.0.0

<div align="center">

# Rewrite Zod

Official **Zod** schemas for the **Rewrite API** — versioned, typed, and built for production.<br/>
[@rewritejs/zod](https://www.npmjs.com/package/@rewritejs/zod) gives you first-class runtime validation for the public Rewrite API, including REST payloads, reusable resources, and webhook events.

Built for TypeScript, Node.js, Bun, and modern server runtimes, it keeps your integrations aligned with the Rewrite platform while delivering a clean developer experience from request validation to webhook handling.

## Installing

You can use your favorite package manager to install our package

</div>

```bash
npm install @rewritejs/zod zod
# Or
yarn add @rewritejs/zod zod
# Or
bun add @rewritejs/zod zod
```

<div align="center">

## Using the Zod Schemas

Import schemas from the API version you want to target and validate requests or responses with confidence.

</div>

```ts
import {
	RESTPostCreateTemplateBody,
	RESTGetListTemplatesData,
} from '@rewritejs/zod/v1';
import { REST } from '@rewritejs/rest';

const client = new REST(process.env.REWRITE_API_KEY);

const data = RESTPostCreateTemplateBody.parse({
	name: 'order_shipped',
	content: 'Hi {{first_name}}, your order {{order_id}} is on the way.',
	variables: [
		{ name: 'first_name', fallback: 'customer' },
		{ name: 'order_id', fallback: '0000' },
	],
});

const response = await client.post('/templates', {
	data,
});

console.log({ data, response });
```

<div align="center">

### API Models & REST Contracts

Use reusable `API*` resources and endpoint-focused `REST<Method>*` schemas side by side.

</div>

```ts
import {
	APIWebhook,
	RESTPostCreateWebhookBody,
	RESTGetListWebhooksData,
} from '@rewritejs/zod/v1';

const webhook = APIWebhook.parse({
	id: '748395130237498700',
	name: 'Delivery events',
	endpoint: 'https://example.com/webhooks/rewrite',
	events: ['sms.queued', 'sms.delivered'],
	status: 'ACTIVE',
	createdAt: '2026-02-19T16:05:00.000Z',
});

const body = RESTPostCreateWebhookBody.parse({
	name: 'Delivery events',
	endpoint: 'https://example.com/webhooks/rewrite',
	events: ['sms.queued', 'sms.delivered'],
});

const data = RESTGetListWebhooksData.parse({
	ok: true,
	data: [webhook],
	cursor: {
		persist: false,
	},
});

console.log({ body, data });
```

<div align="center">

### Handling Webhooks

Validate Rewrite webhook payloads with a discriminated union and branch safely by event type.

</div>

```ts
import { WebhookEvent } from '@rewritejs/zod/v1';

const result = WebhookEvent.safeParse(payload);

if (!result.success) {
	console.error({ error: result.error });

	return;
}

console.log({ data: result.data });
```

<div align="center">

You can view our documentation going [here](https://docs.rewritetoday.com/api-reference). Thanks for building with Rewrite!

</div>
npm package: @rewritetoday/edge
Description: Rewrite webhooks made simple for edge runtimes.
Latest version: 0.1.0

<div align="center">

# Rewrite Edge

Official integration of **Rewrite** with **edge runtimes** to receive **Webhooks** in a simple, secure and fully typed way.

[`@rewritetoday/edge`](https://www.npmjs.com/package/@rewritetoday/edge) is a **runtime-first** package, designed to work natively with the standard `Request` and `Response` APIs, focused on **DX**, **TypeScript first** and **good security practices**.

You can find the full Webhooks documentation [here](https://docs.rewritetoday.com).

## Instalação

Use with your favorite package manager:

</div>

```bash
npm install @rewritetoday/edge
# ou
pnpm add @rewritetoday/edge
# ou
bun add @rewritetoday/edge
```

<div align="center">

No extra dependencies are needed. The package is ready to use with the standard Web APIs available in edge runtimes.

## Basic usage

</div>

```ts
import { Webhooks } from '@rewritetoday/edge';

export default {
	fetch: Webhooks({
		secret: '...',
		onPayload({ id, type, data }) {
			console.log('Hey, a new webhook event:', type);
		},
	}),
};
```

<div align="center">

## Security by default

</div>

- Automatic webhook signature verification
- Secure webhook secret comparison
- Payload validated before reaching your handler
- No direct access to API key

<p align="center"><strong>Never expose your API key in webhooks.</strong><br/>
Always use environment variables.</p>

<div align="center">

## Event processing

You can handle specific events without boilerplate:

</div>

```ts
export default {
	fetch: Webhooks({
		secret: '...',
		onSMSOTP({ data }) {
			console.log({ data });
		},
		onMessageSent({ data }) {
			console.log({ data });
		},
		onMessageBatch({ data }) {
			console.log({ data });
		},
		onMessageQueued({ data }) {
			console.log({ data });
		},
		onMessageDelivered({ data }) {
			console.log({ data });
		},
		onMessageScheduled({ data }) {
			console.log({ data });
		},
		onMessageFailed({ data }) {
			console.error({ error: data.error });
		},
		onMessageCanceled({ data }) {
			console.log({ data });
		},
	}),
};
```

<p align="center">Or treat everything generically:</p>

```ts
export default {
	fetch: Webhooks({
		secret: '...',
		onPayload({ id, type, data }) {
			console.log({ id, type, data });
		},
	}),
};
```

<div align="center">

Made by the Rewrite team. <br/>
SMS the way it should be.

</div>
npm package: @rewritetoday/elysia
Description: Rewrite webhooks made simple with Elysia.
Latest version: 0.1.0

<div align="center">

# Rewrite Elysia

Official integration of **Rewrite** with **Elysia** to receive **Webhooks** in a simple, secure and fully typed way.

[`@rewritetoday/elysia`](https://www.npmjs.com/package/@rewritetoday/elysia) is a **framework-first** package, designed to work natively with Elysia, focused on **DX**, **TypeScript first** and **good security practices**.

You can find the full Webhooks documentation [here](https://docs.rewritetoday.com).

## Instalação

Use with your favorite package manager:

</div>

```bash
npm install @rewritetoday/elysia elysia
# ou
pnpm add @rewritetoday/elysia elysia
# ou
bun add @rewritetoday/elysia elysia
```

<div align="center">

No extra dependencies are needed. The package is ready to use with Elysia.

## Basic usage

</div>

```ts
import { Elysia } from 'elysia';
import { Webhooks } from '@rewritetoday/elysia';

const app = new Elysia();

app.post(
	'/webhooks/rewrite',
	Webhooks({
		secret: '...',
		onPayload({ id, type, data }) {
			console.log('Hey, a new webhook event:', type);
		},
	}),
);
```

<div align="center">

## Security by default

</div>

- Automatic webhook signature verification
- Secure webhook secret comparison
- Payload validated before reaching your handler
- No direct access to API key

<p align="center"><strong>Never expose your API key in webhooks.</strong><br/>
Always use environment variables.</p>

<div align="center">

## Event processing

You can handle specific events without boilerplate:

</div>

```ts
app.post(
	'/webhooks/rewrite',
	Webhooks({
		secret: '...',
		onSMSOTP({ data }) {
			console.log({ data });
		},
		onMessageSent({ data }) {
			console.log({ data });
		},
		onMessageBatch({ data }) {
			console.log({ data });
		},
		onMessageQueued({ data }) {
			console.log({ data });
		},
		onMessageDelivered({ data }) {
			console.log({ data });
		},
		onMessageScheduled({ data }) {
			console.log({ data });
		},
		onMessageFailed({ data }) {
			console.error({ error: data.error });
		},
		onMessageCanceled({ data }) {
			console.log({ data });
		},
	}),
);
```

<p align="center">Or treat everything generically:</p>

```ts
app.post(
	'/webhooks/rewrite',
	Webhooks({
		secret: '...',
		onPayload({ id, type, data }) {
			console.log({ id, type, data });
		},
	}),
);
```

<div align="center">

Made by the Rewrite team. <br/>
SMS the way it should be.

</div>
npm package: @rewritetoday/express
Description: Rewrite webhooks made simple with Express.
Latest version: 0.1.0

<div align="center">

# Rewrite Express

Official integration of **Rewrite** with **Express** to receive **Webhooks** in a simple, secure and fully typed way.

[`@rewritetoday/express`](https://www.npmjs.com/package/@rewritetoday/express) is a **framework-first** package, designed to work natively with Express, focused on **DX**, **TypeScript first** and **good security practices**.

You can find the full Webhooks documentation [here](https://docs.rewritetoday.com).

## Instalação

Use with your favorite package manager:

</div>

```bash
npm install @rewritetoday/express express
# ou
pnpm add @rewritetoday/express express
# ou
bun add @rewritetoday/express express
```

<div align="center">

No extra dependencies are needed. The package already handles the raw body middleware required by Express for webhook verification.

## Basic usage

</div>

```ts
import express from 'express';
import { Webhooks } from '@rewritetoday/express';

const app = express();

app.post(
	'/webhooks/rewrite',
	...Webhooks({
		secret: '...',
		onPayload({ id, type, data }) {
			console.log('Hey, a new webhook event:', type);
		},
	}),
);
```

<div align="center">

## Security by default

</div>

- Automatic webhook signature verification
- Secure webhook secret comparison
- Payload validated before reaching your handler
- No direct access to API key

<p align="center"><strong>Never expose your API key in webhooks.</strong><br/>
Always use environment variables.</p>

<div align="center">

## Event processing

You can handle specific events without boilerplate:

</div>

```ts
app.post(
	'/webhooks/rewrite',
	...Webhooks({
		secret: '...',
		onSMSOTP({ data }) {
			console.log({ data });
		},
		onMessageSent({ data }) {
			console.log({ data });
		},
		onMessageBatch({ data }) {
			console.log({ data });
		},
		onMessageQueued({ data }) {
			console.log({ data });
		},
		onMessageDelivered({ data }) {
			console.log({ data });
		},
		onMessageScheduled({ data }) {
			console.log({ data });
		},
		onMessageFailed({ data }) {
			console.error({ error: data.error });
		},
		onMessageCanceled({ data }) {
			console.log({ data });
		},
	}),
);
```

<p align="center">Or treat everything generically:</p>

```ts
app.post(
	'/webhooks/rewrite',
	...Webhooks({
		secret: '...',
		onPayload({ id, type, data }) {
			console.log({ id, type, data });
		},
	}),
);
```

<div align="center">

Made by the Rewrite team. <br/>
SMS the way it should be.

</div>
npm package: @rewritetoday/fastify
Description: Rewrite webhooks made simple with Fastify.
Latest version: 0.1.0

<div align="center">

# Rewrite Fastify

Official integration of **Rewrite** with **Fastify** to receive **Webhooks** in a simple, secure and fully typed way.

[`@rewritetoday/fastify`](https://www.npmjs.com/package/@rewritetoday/fastify) is a **framework-first** package, designed to work natively with Fastify, focused on **DX**, **TypeScript first** and **good security practices**.

You can find the full Webhooks documentation [here](https://docs.rewritetoday.com).

## Instalação

Use with your favorite package manager:

</div>

```bash
npm install @rewritetoday/fastify fastify
# ou
pnpm add @rewritetoday/fastify fastify
# ou
bun add @rewritetoday/fastify fastify
```

<div align="center">

No extra dependencies are needed. The package can register the JSON content parser required by Fastify for webhook verification.

## Basic usage

</div>

```ts
import Fastify from 'fastify';
import { Webhooks } from '@rewritetoday/fastify';

const app = Fastify();

await app.register(Webhooks, {
	path: '/webhooks/rewrite',
	secret: '...',
	onPayload({ id, type, data }) {
		console.log('Hey, a new webhook event:', type);
	},
});
```

<div align="center">

## Security by default

</div>

- Automatic webhook signature verification
- Secure webhook secret comparison
- Payload validated before reaching your handler
- No direct access to API key

<p align="center"><strong>Never expose your API key in webhooks.</strong><br/>
Always use environment variables.</p>

<div align="center">

## Event processing

You can handle specific events without boilerplate:

</div>

```ts
await app.register(Webhooks, {
	path: '/webhooks/rewrite',
	secret: '...',
	onSMSOTP({ data }) {
		console.log({ data });
	},
	onMessageSent({ data }) {
		console.log({ data });
	},
	onMessageBatch({ data }) {
		console.log({ data });
	},
	onMessageQueued({ data }) {
		console.log({ data });
	},
	onMessageDelivered({ data }) {
		console.log({ data });
	},
	onMessageScheduled({ data }) {
		console.log({ data });
	},
	onMessageFailed({ data }) {
		console.error({ error: data.error });
	},
	onMessageCanceled({ data }) {
		console.log({ data });
	},
});
```

<p align="center">Or treat everything generically:</p>

```ts
await app.register(Webhooks, {
	path: '/webhooks/rewrite',
	secret: '...',
	onPayload({ id, type, data }) {
		console.log({ id, type, data });
	},
});
```

<div align="center">

Made by the Rewrite team. <br/>
SMS the way it should be.

</div>
npm package: @rewritetoday/hono
Description: Rewrite webhooks made simple with Hono.
Latest version: 0.1.0

<div align="center">

# Rewrite Hono

Official integration of **Rewrite** with **Hono** to receive **Webhooks** in a simple, secure and fully typed way.

[`@rewritetoday/hono`](https://www.npmjs.com/package/@rewritetoday/hono) is a **framework-first** package, designed to work natively with Hono, focused on **DX**, **TypeScript first** and **good security practices**.

You can find the full Webhooks documentation [here](https://docs.rewritetoday.com).

## Instalação

Use with your favorite package manager:

</div>

```bash
npm install @rewritetoday/hono hono
# ou
pnpm add @rewritetoday/hono hono
# ou
bun add @rewritetoday/hono hono
```

<div align="center">

No extra dependencies are needed. The package is ready to use with Hono.

## Basic usage

</div>

```ts
import { Hono } from 'hono';
import { Webhooks } from '@rewritetoday/hono';

const app = new Hono();

app.post(
	'/webhooks/rewrite',
	Webhooks({
		secret: '...',
		onPayload({ id, type, data }) {
			console.log('Hey, a new webhook event:', type);
		},
	}),
);
```

<div align="center">

## Security by default

</div>

- Automatic webhook signature verification
- Secure webhook secret comparison
- Payload validated before reaching your handler
- No direct access to API key

<p align="center"><strong>Never expose your API key in webhooks.</strong><br/>
Always use environment variables.</p>

<div align="center">

## Event processing

You can handle specific events without boilerplate:

</div>

```ts
app.post(
	'/webhooks/rewrite',
	Webhooks({
		secret: '...',
		onSMSOTP({ data }) {
			console.log({ data });
		},
		onMessageSent({ data }) {
			console.log({ data });
		},
		onMessageBatch({ data }) {
			console.log({ data });
		},
		onMessageQueued({ data }) {
			console.log({ data });
		},
		onMessageDelivered({ data }) {
			console.log({ data });
		},
		onMessageScheduled({ data }) {
			console.log({ data });
		},
		onMessageFailed({ data }) {
			console.error({ error: data.error });
		},
		onMessageCanceled({ data }) {
			console.log({ data });
		},
	}),
);
```

<p align="center">Or treat everything generically:</p>

```ts
app.post(
	'/webhooks/rewrite',
	Webhooks({
		secret: '...',
		onPayload({ id, type, data }) {
			console.log({ id, type, data });
		},
	}),
);
```

<div align="center">

Made by the Rewrite team. <br/>
SMS the way it should be.

</div>
npm package: @rewritetoday/rest
Description: A comprehensive REST client for Rewrite API
Latest version: 1.0.1

<div align="center">

# Rewrite REST

A **REST** client for the **Rewrite API** — fast, secure, and reliable.<br/>
[@rewritetoday/rest](https://www.npmjs.com/package/@rewritetoday/rest) is a lightweight, fully typed HTTP client designed to interact seamlessly with the **Rewrite API**.

Built for Node.js, Bun, and modern runtimes, it includes smart retries, timeout control, consistent error handling, and a clean developer experience for sending and managing SMS at scale.

## Installing

You can use your favorite package manager to install our package

</div>

```bash
npm install @rewritetoday/rest
# Or
yarn add @rewritetoday/rest
# Or
bun add @rewritetoday/rest
```

<div align="center">

## Using the REST Client

You can use any route, any method, and any payload to interact with the Rewrite API.

</div>

```ts
import { REST } from '@rewritetoday/rest';

const client = new REST(process.env.REWRITE_API_KEY);

const { data, error } = await client.post('/messages', {
	data: {
		to: '+1234567890',
		message: 'Hey, using REST here',
	},
});

console.log({ data });
```

<div align="center">

### Retry & Backoff (Delay)

By default, our **REST** client try 3 times with a Jitter delay between each attempt.<br/> But you can customize easily in the `retry` option.

</div>

```ts
const client = new REST({
	timeout: 3_000,
	auth: process.env.REWRITE_API_KEY,
	retry: {
		max: 5,
		delay(attempt) {
			return attempt * 0.5;
		},
	},
});
```

<div align="center">

You can also use callback function to execute **before** each retry:

</div>

```ts
const client = new REST({
	auth: process.env.REWRITE_API_KEY,
	retry: {
		max: 7,
		async onRetry({ response }) {
			const { error } = await response.json();
			
			console.error({ error });
		},
	},
});
```

<div align="center">

## Handling Errors

Our **REST Client** handles errors gracefully and provides a consistent error handling experience.

</div>

```ts
import { REST, HTTPError } from '@rewritetoday/rest';

const client = new REST(process.env.REWRITE_API_KEY);

const { data, error } = await client.get('/message/1234567890');

if (error) {
	console.error({ error });
}

console.log({ data });
```

<div align="center">

You can view our documentation going [here](https://docs.rewritetoday.com/en/api-reference/errors). Thanks for using our REST Client!

</div>