ZTS Docs

TypeScript SDK

Generated REST client (@zts/sdk) for integrations and workers.

@zts/sdk is a generated TypeScript client for the REST API at /api/rest. It does not speak MCP — agents use the MCP endpoint instead.

Use the SDK for integrations, background workers, and serverless functions. First-party web, mobile, and extension apps should use tRPC directly.

Install

Inside the monorepo:

"@zts/sdk": "workspace:*"

In an external project:

pnpm add @zts/sdk

Configure

import { configure, Users, Images } from "@zts/sdk";
 
configure({
  apiKey: process.env.ZTS_API_KEY!,
  baseUrl: "https://demo.zerotoshipped.com/api/rest", // optional
});

Or from environment variables:

import { initializeFromEnv } from "@zts/sdk";
 
initializeFromEnv(); // ZTS_API_KEY, optional ZTS_BASE_URL
VariablePurpose
ZTS_API_KEYzts_… API key (required)
ZTS_BASE_URLFull REST prefix, e.g. https://demo.zerotoshipped.com/api/rest

Defaults baseUrl to http://localhost:3000/api/rest when omitted.

Usage

The generated client exposes two API classes: Users and Images.

import { configure, Users, Images } from "@zts/sdk";
 
configure({ apiKey: process.env.ZTS_API_KEY! });
 
const { data: me } = await Users.userGetCurrentUser({ body: {} });
 
const { data: prefs } = await Users.userGetPreferences({ body: {} });
 
await Users.userUpdateProfile({
  body: { name: "Ada", username: "ada", bio: "", timezone: "UTC" },
});
 
await Images.utImageDelete({ path: { id: "image-id" } });

Available methods

Users

  • userGetCurrentUser
  • userGetUserForEditingProfile
  • userUpdateProfile
  • userGetPreferences
  • userGetSinglePreference
  • userUpdatePreference
  • userMarkUserAsOnboarded
  • userResetUserOnboarding

Images

  • utImageDelete

All POST-style methods expect a body object (use {} when the procedure has no input).

Regenerate after API changes

When you add or change procedures with apiExposure():

pnpm sdk:build

This runs:

  1. @zts/trpc generate:openapipackages/sdk/openapi.json
  2. @hey-api/openapi-ts codegen → packages/sdk/src/client/
  3. tsc compile

The committed openapi.json should stay in sync with what /api/openapi.json serves in production.

  • REST API — auth, OpenAPI, CLI
  • MCP — IDE agent tools (separate transport)
  • Product repo: packages/sdk/README.md

On this page