@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.
You can use this package with your favorite package manager
bun add @rewritejs/types
# Or
npm install @rewritejs/types
# Or
pnpm install @rewritejs/types
# Or
yarn add @rewritejs/types-
Prefix
API*Represents general API structures (returned objects, internal models, etc.). -
Prefix
REST<HTTPMethod>*Types used in direct API requests.-
Suffix Body → request body payload E.g.:
RESTPostCreateTemplateBody -
Suffix
QueryParams→ query string parameters E.g.:RESTGetListWebhooksQueryParams -
Suffix
Data→ data returned by the API E.g.:RESTGetListWebhooksData
-
import { REST } from '@rewritejs/rest';
import { Routes, type RESTGetProjectData } from '@rewritejs/types/v1';
const rest = new REST(process.env.REWRITE_API_KEY);
// Return type: Promise<RESTGetWebhooksData>
async function fetchWebhooks(projectId: string) {
const data = await rest.get<RESTGetWebhooksData>(Routes.webhooks.list(projectId));
return data
}import { API_BASE_URL, Routes } from '@rewritejs/types/v1';
const projectId = '123';
const webhookId = '999';
// https://api.rewritetoday.com/v1/projects/123/webhooks/999
const url = `${API_BASE_URL}/v1${Routes.webhooks.get(projectId, webhookId)}`;Made with 🤍 by the Rewrite team.
SMS the way it should be.