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

# Как создать первый ящик?

Ящик даёт агенту собственный адрес. Можно использовать домен по умолчанию `@agentinbox.space` или свой верифицированный домен.

## Установите SDK

**`TypeScript`**

```bash title="TypeScript"
npm install agentinbox
```

## Создайте ящик

**`TypeScript`**

```typescript title="TypeScript"
import { AgentinboxClient } from "agentinbox";

const client = new AgentinboxClient({ apiKey: "am_..." });

// Create an inbox with a random address on agentinbox.space
const inbox = await client.inboxes.create();
console.log(`Inbox created: ${inbox.inboxId}`);
```

У ящика появится уникальный адрес (например `randomname@agentinbox.space`) — сразу можно отправлять и принимать почту.

## Настройка ящика

Можно задать имя пользователя, домен и отображаемое имя:

**`TypeScript`**

```typescript title="TypeScript"
const inbox = await client.inboxes.create({
  username: "support",
  domain: "yourcompany.com",
  displayName: "Support Agent",
});

// inbox.inboxId will be support@yourcompany.com
console.log(`Inbox created: ${inbox.inboxId}`);
```

> **Note**
>
> Свой домен должен быть верифицирован. См. [Создание своих доменов](/custom-domains). Без домена используется `@agentinbox.space`.

## Идемпотентность через clientId

Если ящик создаётся программно (например при старте), используйте `clientId`, чтобы не плодить дубликаты — при совпадении вернётся существующий ящик:

**`TypeScript`**

```typescript title="TypeScript"
const inbox = await client.inboxes.create({
  username: "my-agent",
  clientId: "my-agent-inbox-v1",
  displayName: "My Agent",
});

// Safe to call multiple times: same inbox returned every time
```

## Первая отправка

**`TypeScript`**

```typescript title="TypeScript"
await client.inboxes.messages.send(inbox.inboxId, {
  to: "recipient@example.com",
  subject: "Hello from my agent!",
  text: "This is a plain text version.",
  html: "<p>This is an <strong>HTML</strong> version.</p>",
});
```

> **Note**
>
> Указывайте и `text`, и `html` — так письмо корректно отображается в клиентах и лучше доставляется.

## Список ящиков

**`TypeScript`**

```typescript title="TypeScript"
const inboxes = await client.inboxes.list();
console.log(`You have ${inboxes.count} inboxes.`);

for (const inbox of inboxes.inboxes) {
  console.log(`  ${inbox.inboxId}`);
}
```

## Дальше

* [Отправка и приём](/sending-receiving-email)
* [Webhooks](/webhook-setup)
* [Метки](/labels)