# TypeScript SDK

Install the sailfork package for Node, Bun, Deno or Workers, make a first call, and find the page for each part of the TypeScript SDK.

The `sailfork` package is the TypeScript client for the same operations the REST API, the CLI and the [MCP server](https://sailfork.com/docs/mcp) serve. It has no runtime dependencies and uses the global `fetch`. [SDKs for TypeScript and Python](https://sailfork.com/docs/sdk) is the short overview and the [SDK reference](https://sailfork.com/docs/sdk-reference) lists every method; the pages here go deeper.

## Install and requirements

```sh
bun add sailfork       # or npm install sailfork, pnpm add sailfork
```

| | |
| --- | --- |
| Runs on | Node 20 or later, Bun, Deno, Cloudflare Workers |
| Module formats | ESM and CommonJS, with types for both |
| Runtime dependencies | none |
| API version | every request sends `Sailfork-Version: 2026-12-01` |

The package has two entry points.

| Import path | What it holds |
| --- | --- |
| `sailfork` | The `Sailfork` client (default and named export), the handle classes, the error classes, `ERROR_CODES`, `detectAgent`, `detectSession`, `API_VERSION`, `VERSION`, and the `types` namespace |
| `sailfork/tools` | `anthropicTools`, `openaiTools`, `run` and the `AnthropicTool` and `OpenAITool` types |

```ts
import Sailfork, { NotFoundError, type RequestOptions, type types } from 'sailfork';
import { anthropicTools, openaiTools, run } from 'sailfork/tools';
```

From CommonJS, the class is both the `default` and the `Sailfork` property of the module:

```js
const { Sailfork, NotFoundError } = require('sailfork');
const sf = new Sailfork();
```

## Your first call

```ts
import Sailfork from 'sailfork';

const sf = new Sailfork(); // SAILFORK_TOKEN, SAILFORK_HOST, or the token `sailfork auth login` stored

const { pending } = await sf.held.mine(); // writes waiting for a person
console.log(pending.length);

const repo = sf.repo('acme/api');
const page = await repo.pulls.list({ state: 'open', limit: 10 });
for (const pull of page.items) console.log(pull.number, pull.title);
```

## In this section

| Page | What it covers |
| --- | --- |
| [Client and sign-in](https://sailfork.com/docs/sdk-typescript-client) | Every `ClientOptions` field, how the token and host are found, a custom `fetch`, agent naming and headers |
| [Operations and types](https://sailfork.com/docs/sdk-typescript-calls) | How operations become methods, input and output types, paging, streams and long operations |
| [Handles](https://sailfork.com/docs/sdk-typescript-handles) | `Repo`, `Org`, `PullRequest` and `Caisson`, and the methods that return the next one |
| [Agent workflow](https://sailfork.com/docs/sdk-typescript-workflow) | An issue to a merged pull request, including the held merge |
| [Held writes and waits](https://sailfork.com/docs/sdk-typescript-held-and-waits) | The `Result` type and `sf.wait` |
| [Errors and retries](https://sailfork.com/docs/sdk-typescript-errors) | Every error class and code, request options, retries and idempotency |
| [Tools for models](https://sailfork.com/docs/sdk-typescript-tools) | `anthropicTools`, `openaiTools` and `run`, with a tool-use loop for each |
| [Testing and runtimes](https://sailfork.com/docs/sdk-typescript-testing) | An injected `fetch`, and notes for Node, Bun, Deno, Workers and browsers |

The Python package has the same section, starting at [Python SDK](https://sailfork.com/docs/sdk-python).

---

Every docs page: https://sailfork.com/llms.txt
