Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.

Rewrite Types

@rewritetoday/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

bun add @rewritetoday/types
# Or
npm install @rewritetoday/types
# Or
pnpm install @rewritetoday/types
# Or
yarn add @rewritetoday/types

Using

How we document our 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

  • Prefix Webhook* Represents any data that come from a webhook.

Typing API Responses

import{REST}from'@rewritetoday/rest';import{Routes,typeRESTGetProjectData}from'@rewritetoday/types/v1';constrest=newREST(process.env.REWRITE_API_KEY);// Return type: Promise<RESTGetWebhooksData>asyncfunctionfetchHooks(){constdata=awaitrest.get<RESTGetWebhooksData>(Routes.webhooks.list());returndata}

Typing webhook events

We are using Bun here as example, but you can use it however you want.

import{typeWebhookEvent,WebhookEventType}from'@rewritetoday/types/v1';constserver=Bun.serve({port: 3000,routes: {async'/webhooks/rewrite'(request){constevent: WebhookEvent=awaitrequest.json();switch(event.type){caseWebhookEventType.MessageSent:
console.log('Hey, a new message!');returnResponse.json({});case ...
}},},});

Using Route Builders

import{API_VERSIONAPI_BASE_URL,Routes}from'@rewritetoday/types/v1';// https://api.rewritetoday.com/v1/templatesconstCREATE_TEMPLATE_URL=`${API_BASE_URL}/${API_VERSION}/${Routes.templates.create()}`;

Made with 🤍 by the Rewrite team.
SMS the way it should be.

About

Official Rewrite API typings that are always up to date

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages