# TypeScript SDK

The SDK is a fully typed client over the [REST API](/api): every method,
input, and output below is derived from the same contract that defines the
API itself.

```bash
npm install thinkbench
```

```ts
import { createThinkBench } from "thinkbench";

const tb = createThinkBench({ apiKey: process.env.THINKBENCH_API_KEY! });

const { item, markdown } = await tb.documents.read({
  documentId: "<documentId>",
});
```

## Configuration

| Option                 | Description                                                                                                                |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `apiKey`               | Required. An API key from **Settings → API keys**.                                                                         |
| `agent` _(optional)_   | Names the software making requests so its edits are attributed to it. Unnecessary for agent keys, which already carry one. |
| `baseUrl` _(optional)_ | Defaults to `https://app.thinkbench.com/api/v1`.                                                                                            |

## Behavior

- Payloads are plain JSON over the wire, so timestamps arrive as ISO
  strings.
- Failed calls throw an `ORPCError` carrying the API's
  [error envelope](/api#errors) — there are no silent empty results.

## Methods

| Method | Summary |
| --- | --- |
| [`tb.documents.read(input)`](/api/documents/read) | Read a ThinkBench document and return its current content as Markdown. |
| [`tb.driveItems.sharedWithMe(input)`](/api/drive-items/shared-with-me) | List items shared directly with the user via share grants. |
| [`tb.driveItems.get(input)`](/api/drive-items/get) | Read a drive item with its drive, children, visible ancestors, and shares. |
| [`tb.driveItems.rename(input)`](/api/drive-items/rename) | Rename a drive item. |
| [`tb.driveItems.move(input)`](/api/drive-items/move) | Move an item to another folder or drive. |
| [`tb.driveItems.createChild(input)`](/api/drive-items/create-child) | Create a folder or document inside a folder. |
| [`tb.driveItems.shareSuggestions(input)`](/api/drive-items/share-suggestions) | Organization members who could be given access to this item. |
| [`tb.driveItems.share(input)`](/api/drive-items/share) | Grant a person access to an item by email. |
| [`tb.driveItems.updateShare(input)`](/api/drive-items/update-share) | Change an existing share grant's permission. |
| [`tb.driveItems.removeShare(input)`](/api/drive-items/remove-share) | Revoke a share grant. |
| [`tb.driveItems.setPublication(input)`](/api/drive-items/set-publication) | Publish or unpublish a document to the web. |
| [`tb.drives.list(input)`](/api/drives/list) | List every drive the user can access, each with its items and members. |
| [`tb.drives.create(input)`](/api/drives/create) | Create a shared drive in the active organization. |
| [`tb.drives.rename(input)`](/api/drives/rename) | Rename a drive. |
| [`tb.drives.createItem(input)`](/api/drives/create-item) | Create a folder or document at the drive's root. |
| [`tb.drives.upsertMember(input)`](/api/drives/upsert-member) | Add an organization member to a shared drive or change their role. |
| [`tb.drives.removeMember(input)`](/api/drives/remove-member) | Remove a member from a shared drive. |
