---
title: "TypeScript"
description: "The TypeScript client for typeship's own API. Generated by typeship from its own spec, so it is also a sample of what your users get."
url: https://typeship.dev/docs/sdks/typescript
markdown: https://typeship.dev/docs/sdks/typescript.md
section: "Get started"
---
> ## Documentation index
> Fetch the complete documentation index at https://typeship.dev/llms.txt (every page, one line each) or the full text at https://typeship.dev/llms-full.txt.
> Append .md to any docs URL, or send Accept: text/markdown, for the markdown twin of that page.

# TypeScript

The TypeScript client for typeship's own API. Generated by typeship from its own spec, so it is also a sample of what your users get.

`typeship-ax` on npm is the TypeScript SDK for the typeship API, generated by typeship from [its own OpenAPI spec](https://typeship.dev/openapi.yaml). It has the same shape as every SDK typeship generates: zero runtime dependencies, typed results, typed error unions, auto-pagination, retries. If you want to see what your users will get before you generate anything, read this package.

The package also carries the [typeship CLI](https://typeship.dev/docs/cli) and the [typeship MCP server](https://typeship.dev/docs/typeship-api/mcp).

## Install

```bash
npm install typeship-ax
```

Node 18 or newer. ESM only.

## Create a client

```ts
import { TypeshipClient } from "typeship-ax";

const client = new TypeshipClient({ bearerToken: process.env.TYPESHIP_TOKEN! });
```

The key comes from the console under **api keys**. Pass it explicitly. The typeship SDK does not read environment variables for credentials. `TypeshipClient` takes the same options as any generated client: `baseUrl`, `timeoutMs`, `maxRetries`, `defaultHeaders`, `fetch`, `onRequest`, `onResponse`, `onError`, `debug`, and `validate`. See [Client options](https://typeship.dev/docs/platforms/sdk#client-options).

## Generate a package

`generate.run` runs the generator on a spec and returns the files. Nothing is stored. The free plan generates the first 25 operations; paid plans generate the whole spec:

```ts
const result = await client.generate.run({
  spec: { url: "https://api.acme.example.com/openapi.json" },
  platforms: ["sdk", "cli"],
  language: "typescript",
});

if (result.ok) {
  for (const file of result.data.files) {
    await fs.writeFile(path.join("out", file.path), file.content);
  }
  console.log(result.data.meta.operation_count, "operations");
}
```

## Work with projects

```ts
import { TypeshipClient, unwrap } from "typeship-ax";

const client = new TypeshipClient({ bearerToken: process.env.TYPESHIP_TOKEN! });

const project = unwrap(await client.projects.create({
  name: "Acme API",
  spec_url: "https://api.acme.example.com/openapi.json",
  platforms: ["sdk", "cli", "mcp"],
  languages: ["typescript", "python"],
  destinations: {
    typescript: { repo: "acme/acme-node" },
    python: { repo: "acme/acme-python" },
  },
  auto_regen: true,
}));

// Regenerate on demand and read every language's files.
const generations = unwrap(await client.projects.generate(project.id));
for (const generation of generations.data) {
  if (generation.status !== "succeeded") continue;
  console.log(generation.language, generation.meta.file_count);
}

// Walk history.
for await (const generation of client.projects.listGenerations(project.id)) {
  console.log(generation.created_at, generation.trigger, generation.status);
}
```

## Every method

| Resource       | Methods                                                                                                                      |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `generate`     | `run(body)`                                                                                                                  |
| `projects`     | `list(params?)`, `create(body)`, `get(id)`, `update(id, body)`, `delete(id)`, `generate(id)`, `listGenerations(id, params?)` |
| `generations`  | `get(id)`, `getFile(id, { path })`                                                                                           |
| `specVersions` | `list(projectId, params?)`, `get(id)`, `getContent(id)`                                                                      |
| `account`      | `me()`                                                                                                                       |
| `usage`        | `retrieve()`                                                                                                                 |
| `apiKeys`      | `list(params?)`, `revoke(id)`                                                                                                |

Bodies and responses use the API's `snake_case` names. `api.md` inside the package is the complete reference, and the [API reference](https://typeship.dev/docs/api) has every schema.

## Errors

Every call returns `ApiResult`. The error union for each operation lists exactly what the API documents for it, plus `UnexpectedApiError`, `TransportError`, and `ValidationError`:

```ts
import { NotFoundError, PaymentRequiredError } from "typeship-ax";

const result = await client.projects.generate("prj_...");
if (!result.ok) {
  if (result.error instanceof PaymentRequiredError) {
    // free plan allowance used up; result.error.body.errors[0].message says so
  }
  if (result.error instanceof NotFoundError) {
    // no such project on this account
  }
}
```

See [Errors](https://typeship.dev/docs/typeship-api/api/errors) for the envelope and codes.

## Sitemap

[Every page of these docs](https://typeship.dev/llms.txt)
