Skip to main content
@rewritetoday/zod provides official Zod schemas for the Rewrite API so you can validate requests, responses, reusable resources, and webhook payloads at runtime. Repository: github.com/RewriteToday/zod

When to use it

  • You want runtime validation in addition to TypeScript types.
  • You receive external input before calling Rewrite endpoints.
  • You need to validate webhook payloads before handling them.
  • You want versioned schemas that stay aligned with Rewrite API models.

Key capabilities

Versioned schemas

Import schemas from namespaces such as @rewritetoday/zod/v1.

REST contracts

Validate endpoint-specific bodies and responses with REST<Method>* schemas.

Reusable API models

Parse shared API* resources independently from a single endpoint.

Webhook safety

Use WebhookEvent.safeParse(...) to guard webhook handling at the boundary.

Install

Request validation example

Webhook validation example

Best practices

Parse external input before it reaches your business logic so invalid payloads fail fast and predictably.
Import from a specific API namespace such as @rewritetoday/zod/v1 so upgrades stay deliberate.
Combine @rewritetoday/zod with @rewritetoday/rest and @rewritetoday/types for validation, routing, and transport in one stack.

Types library

Shared contracts and route builders that complement runtime validation.

REST library

Low-level transport client for sending the payloads you validate with Zod.