> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.usebridge.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.usebridge.com/_mcp/server.

# TypeScript

Bridge provides a TypeScript client for interacting with the Bridge API. This SDK simplifies API integration by providing type-safe methods, automatic authentication handling, and built-in error handling.

## Features

* **Type Safety**: Full TypeScript support with generated types from our API specification
* **Authentication**: Automatic token management and refresh handling
* **Error Handling**: Comprehensive error handling with detailed error messages
* **Request/Response Validation**: Built-in validation for all API requests and responses
* **Modern JavaScript**: ES6+ features with async/await support

## Installation

Install the SDK from npm:

```bash
npm install @usebridge/api
```

Or using yarn:

```bash
yarn add @usebridge/api
```

## Quick Start

```typescript
import { BridgeApiClient, BridgeApiEnvironment } from "@usebridge/api"

// Initialize the client
const client = new BridgeApiClient({
  apiKey: "your-api-key",
  environment: BridgeApiEnvironment.Production, // or BridgeApiEnvironment.Sandbox (defaults to BridgeApiEnvironment.Production if not specified)
})

// Create a Patient
const patient = await client.patients.v2.createPatient({
  firstName: "Jane",
  lastName: "Smith",
  email: "patient@example.com",
  dateOfBirth: "2000-01-01",
})
```

## Resources

#### [NPM Package](https://www.npmjs.com/package/@usebridge/api)

#### [GitHub Repository](https://github.com/use-bridge/api-typescript)

#### [API Reference](/api)

#### [Testing Guide](/api/resources/testing)