npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rewritetoday/typebox

v1.0.0

Published

Official Typebox schemas for the Rewrite API.

Readme

Rewrite Typebox

Official Typebox schemas for the Rewrite API — versioned, typed, and built for production. @rewritetoday/typebox 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

npm install @rewritetoday/typebox @sinclair/typebox
# Or
yarn add @rewritetoday/typebox @sinclair/typebox
# Or
bun add @rewritetoday/typebox @sinclair/typebox

Using the Typebox Schemas

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

import {
	RESTPostCreateTemplateBody,
	RESTGetListTemplatesData,
} from '@rewritetoday/typebox/v1';
import { Parse } from '@sinclair/typebox/value';

const data = Parse(RESTPostCreateTemplateBody, {
	name: 'order_shipped',
	content: 'Hi {{first_name}}, your order {{order_id}} is on the way.',
	description: 'Default shipping notification',
	variables: [
		{ name: 'first_name', fallback: 'customer' },
		{ name: 'order_id', fallback: '0000' },
	],
	i18n: {
		br: 'Oi {{first_name}}, seu pedido {{order_id}} esta a caminho.',
	},
});

console.log({
	data,
	url: '/templates',
	response: Parse(RESTGetListTemplatesData, {
		ok: true,
		data: [],
		cursor: {
			persist: false,
		},
	}),
});

API Models & REST Contracts

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

import {
	APIWebhook,
	RESTPostCreateWebhookBody,
	RESTGetListWebhooksData,
} from '@rewritetoday/typebox/v1';
import { Parse } from '@sinclair/typebox/value';

const webhook = Parse(APIWebhook, {
	id: '748395130237498700',
	name: 'Message lifecycle',
	secret: 'rewrite_webhook_secret',
	endpoint: 'https://example.com/webhooks/rewrite',
	events: ['message.queued', 'message.delivered'],
	status: 'ACTIVE',
	projectId: '748395130237498701',
	createdAt: '2026-02-19T16:05:00.000Z',
});

const body = Parse(RESTPostCreateWebhookBody, {
	name: 'Message lifecycle',
	endpoint: 'https://example.com/webhooks/rewrite',
	events: ['message.queued', 'message.delivered'],
	secret: 'rewrite_webhook_secret',
});

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

console.log({ body, data });

Handling Webhooks

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

import { WebhookEvent } from '@rewritetoday/typebox/v1';
import { Parse } from '@sinclair/typebox/value';

const data = Parse(WebhookEvent, {
	type: 'message.sent',
	id: '748395130237498799',
	createdAt: '2026-02-19T16:05:00.000Z',
	data: {
		id: '748395130237498800',
		projectId: '748395130237498701',
		createdAt: '748395130237498801',
		analysis: {
			characters: 24,
			encoding: 'gsm7',
			segments: {
				count: 1,
				single: 160,
				concat: 153,
				reason: 'fits',
			},
		},
		to: '+5511999999999',
		type: 'SMS',
		tags: [{ name: 'campaign', value: 'spring' }],
		status: 'SENT',
		country: 'br',
		content: 'Your code is 123456',
		encoding: 'GMS7',
		templateId: null,
		deliveredAt: null,
		scheduledAt: null,
		isPayAsYouGo: false,
	},
});

console.log({ data });

You can view our documentation going here. Thanks for building with Rewrite!