# @respira/sdk — TypeScript SDK for the WordPress CLI

> The TypeScript SDK powering Respira CLI. Typed read and write operations for Elementor, Divi, Bricks, WooCommerce, and more. Zod-validated, dual ESM/CJS output.

Source: https://www.respira.press/cli/docs/sdk

---

## Install

```
npm install @respira/sdk
```

## Usage

```
import { respira } from '@respira/sdk';

const sites = await respira.sites.list();
const page = await respira.read.page('mysite.com', 'about');
await respira.write.editElement('mysite.com', 'about', 'heading-123', {
  title: 'welcome',
});
```

## Custom configuration

```
import { createRespiraClient } from '@respira/sdk';

const client = createRespiraClient({
  apiKey: process.env.RESPIRA_API_KEY,
  baseUrl: 'https://respira.press/api/v1',
  timeoutMs: 30000,
});
```

## Anonymous mode

Skip the keychain lookup for public-only operations:

```
const client = createRespiraClient({ anonymous: true });
const ds = await client.read.designSystem('anywordpress.com');
```

## Types and validation

Every method has full TypeScript types. Runtime inputs and outputs are validated with [zod](https://zod.dev/) so bad responses surface as typed errors, not silent data corruption.

Full type surface:

- `auth`: whoami, status
- `sites`: list, info, health
- `read`: page, pages, post, posts, media, taxonomy, structure, designSystem, elementorFooter, diviModule, findElement
- `write`: createPage, editPage, editElement, createPost, updateDesignSystem, uploadMedia, deletePage
- `tools`: list, describe, search
- `docs`: get, search
- `snapshots`: list, restore, show

## Error handling

The SDK throws typed `RespiraError` instances with a stable `code` field:

```
import { isRespiraError } from '@respira/cli-core';

try {
  await respira.auth.whoami();
} catch (err) {
  if (isRespiraError(err) && err.code === 'AUTH_REQUIRED') {
    console.error('run: respira auth login');
  }
}
```
