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

# Connect a program

A program is a system of your organization that uses Basement from code: an integration, a script, a back-end service. It uses the same tools as an agent, with a key of its own, so the activity log shows the system by its name.

### Create a key for the program

In Basement, open **Agents** and click **Connect agent**. Select **Program**, give the system a name (for example "Billing system"), and select its access level.

Basement shows the key one time. Copy it now, and keep it in a secret store or an environment variable. Do not put it in your source code.

### Install the SDK

**`TypeScript`**

```bash title="TypeScript"
npm install @basementai/gateway
```

**`Python`**

```bash title="Python"
pip install basement-gateway
```

### Make the first call

**`TypeScript`**

```typescript title="TypeScript"
import { BasementGatewayClient } from "@basementai/gateway";

const basement = new BasementGatewayClient({
  apiKey: process.env.BASEMENT_API_KEY,
});

const me = await basement.whoami();
console.log(me.orgName);

const { docs } = await basement.docs.list();
const doc = await basement.docs.read({ docId: docs[0].id });
console.log(doc.title, doc.bodyMarkdown);
```

**`Python`**

```python title="Python"
import os
from basement_gateway import BasementGateway

basement = BasementGateway(api_key=os.environ["BASEMENT_API_KEY"])

me = basement.whoami()
print(me.org_name)

docs = basement.docs.list().docs
doc = basement.docs.read(doc_id=docs[0].id)
print(doc.title, doc.body_markdown)
```

**`HTTP`**

```bash title="HTTP"
curl -X POST https://mcp.basement.chat/v1/tools/whoami \
  -H "Authorization: Bearer $BASEMENT_API_KEY"

curl -X POST https://mcp.basement.chat/v1/tools/read_doc \
  -H "Authorization: Bearer $BASEMENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"docId": "the_document_id"}'
```

Both SDKs read the key from the `BASEMENT_API_KEY` environment variable when you do not give one.

## What happens next

* The program can call only what its access level allows. A call outside it answers `403`. See [Errors and limits](/sdks/errors-and-limits).
* Each call is in **Agents**, **Activity**, marked as a program, with the SDK and its version. See [Activity log](/concepts/activity-log).
* The full list of operations is in the [API Reference](/api-reference).