Skip to content

SDK distribution (pull)

When you run generate, the client SDK is bundled into the server output and served over HTTP, so client apps can pull it directly from your running API.

The generator embeds the SDK as sdk-bundle.ts and exposes:

  • GET /_psdk/sdk/manifest — lists files and metadata
  • GET /_psdk/sdk/download — the complete bundle
  • GET /_psdk/sdk/files/:path — individual files
  • GET /_psdk/contract.md — the API contract as Markdown
  • GET /_psdk/contract.json — the API contract as JSON

The contract.md / contract.json endpoints are handy for agents that want the live schema contract straight from a running API.

Protect these endpoints by setting pullToken (use the env: form). If unset, they’re public.

Pull with flags:

Terminal window
bunx postgresdk@latest pull --from=https://api.myapp.com --output=./src/sdk

Or, recommended, configure pull in postgresdk.config.ts and run pull with no args:

// postgresdk.config.ts in the client app
export default {
pull: {
from: "https://api.myapp.com",
output: "./src/sdk",
pullToken: "env:POSTGRESDK_PULL_TOKEN", // if the server sets one
},
};
Terminal window
bunx postgresdk@latest pull

Then use it like any generated SDK:

import { SDK } from "./src/sdk";
const sdk = new SDK({ baseUrl: "https://api.myapp.com" });

See PullConfig for all options.

Both generate and pull remove files no longer part of the SDK. Interactive terminals prompt per deletion; pass --force (or -y) to skip prompts. In CI (non-interactive), stale files are skipped with a warning unless --force is given.