CapyDB Docs
Reference

TypeScript SDK

@capydb/sdk - fully typed client for the control plane, generated from the OpenAPI document.

What it is

@capydb/sdk is the official TypeScript SDK for the CapyDB control plane — projects, preview databases, backups & PITR restores, imports, Studio SQL, webhooks, and deployment integrations.

It is generated from the control plane's OpenAPI document (GET https://capydb.dev/api/capydb/v1/openapi.json) with @hey-api/openapi-ts, so every operation and model is fully typed and always in lockstep with the API. The generated sources are committed to the package repo, so you can audit exactly what ships.

Install

pnpm add @capydb/sdk

Usage

import { createCapyDB } from "@capydb/sdk";

const capydb = createCapyDB({ apiKey: process.env.CAPYDB_API_KEY! });

// List projects
const projects = await capydb.listProjects();

// Create a preview database for a branch and wait on its job
const preview = await capydb.createPreviewDatabase({
  path: { projectID: "prj_..." },
  body: { name: "pr-42", mode: "clone", ttl_hours: 72 },
});

// Fetch connection strings
const connections = await capydb.getPreviewDatabaseConnections({
  path: { previewID: preview.data!.preview.id },
});

Operation names match the OpenAPI operationIds, so the per-tag API pages double as SDK documentation: every endpoint there is a method here.

Async jobs

Lifecycle calls return 202 with a job — same contract as the raw API. Poll getJob until completed/failed, or lean on webhooks for push-based completion.

Key scoping

Use a project-scoped API key (Dashboard → Settings → API keys, with a project_id) for CI and integrations: it can only touch the one project it was minted for. See Authentication.