> 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.

# Быстрый старт

> Установите SDK, создайте ящик и отправьте первое письмо.

## Минимальный пример

**`Python`**

```bash title="Python"
pip install agentinbox
```

**`TypeScript`**

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

Получите API-ключ в [консоли](https://agentinbox-ru.vercel.app/) и задайте переменную окружения `AGENTINBOX_API_KEY`.

**`Python`**

```python title="Python"
from agentinbox import Agentinbox

client = Agentinbox(api_key="ai_live_...")
inbox = client.inboxes.create()
client.inboxes.messages.send(inbox.inbox_id, to="user@example.com", subject="Hello", text="Hello from my agent!")
```

**`TypeScript`**

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

(async () => {
  const client = new AgentinboxClient({ apiKey: "ai_live_..." });
  const inbox = await client.inboxes.create();
  await client.inboxes.messages.send(inbox.inboxId, { to: "user@example.com", subject: "Hello", text: "Hello from my agent!" });
})();
```

## Шаблон для Cursor / Claude

Скопируйте один из блоков ниже в Cursor или Claude: в нём есть настройка, ссылки на API, обработка ошибок, лимиты и идемпотентность.

**`Python`**

```python title="Python"
"""
Agent Inbox Python quickstart — copy into Cursor/Claude for instant setup.

Setup: pip install agentinbox python-dotenv. Set AGENTINBOX_API_KEY in .env.

Errors: SDK raises on 4xx/5xx. Inspect error.body.message or str(e).
Rate limit: 429 with Retry-After header. Implement exponential backoff for retries.
Idempotency: Pass client_id to inboxes.create() to safely retry without duplicates.
"""
import os
from dotenv import load_dotenv
from agentinbox import Agentinbox

load_dotenv()
client = Agentinbox(api_key=os.getenv("AGENTINBOX_API_KEY"))

inbox = client.inboxes.create(client_id="my-agent-inbox-v1")

try:
    client.inboxes.messages.send(
        inbox.inbox_id,
        to="recipient@example.com",
        subject="Hello from Agent Inbox",
        text="Plain text body",
        html="<p>HTML body</p>",
    )
except Exception as e:
    print(f"Send failed: {e}")
    raise

for msg in client.inboxes.messages.list(inbox.inbox_id, limit=10).messages:
    print(msg.subject, msg.extracted_text or msg.text)
```

**`TypeScript`**

```typescript title="TypeScript"
/**
 * Agent Inbox TypeScript quickstart — copy into Cursor/Claude for instant setup.
 *
 * Setup: npm install agentinbox dotenv. Set AGENTINBOX_API_KEY in .env.
 */
import { AgentinboxClient } from "agentinbox";
import "dotenv/config";

const client = new AgentinboxClient({
  apiKey: process.env.AGENTINBOX_API_KEY!,
});

async function main() {
  const inbox = await client.inboxes.create({
    clientId: "my-agent-inbox-v1",
  });

  try {
    await client.inboxes.messages.send(inbox.inboxId, {
      to: "recipient@example.com",
      subject: "Hello from Agent Inbox",
      text: "Plain text body",
      html: "<p>HTML body</p>",
    });
  } catch (error: unknown) {
    const msg = (error as { body?: { message?: string } })?.body?.message ?? String(error);
    throw new Error(`Send failed: ${msg}`);
  }

  const res = await client.inboxes.messages.list(inbox.inboxId, { limit: 10 });
  for (const msg of res.messages) {
    console.log(msg.subject, msg.extractedText ?? msg.text);
  }
}

main();
```

> **Tip**
>
> Во входящих письмах доступны поля `extracted_text` и `extracted_html` — текст ответа без цитируемой истории.

Ниже — пошаговая установка SDK, ключ и первый ящик.

#### Откройте консоль Agent Inbox

Управляйте аккаунтом и API-ключами в консоли.

#### [Открыть консоль](https://agentinbox-ru.vercel.app/)

Зарегистрируйтесь или войдите и создайте API-ключ в панели.

#### Создайте API-ключ

Перейдите в раздел API Keys, создайте ключ и сохраните его. Добавьте в `.env`, например: `AGENTINBOX_API_KEY=...`.

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

**`Python`**

```bash title="Python"
pip install agentinbox python-dotenv
```

**`Node`**

```bash title="Node"
npm install agentinbox dotenv
```

#### Создайте ящик и отправьте письмо

Создайте файл (например `quickstart.py` или `quickstart.ts`) по образцу ниже.

**`Python`**

```python title="Python"
import os
from dotenv import load_dotenv
from agentinbox import Agentinbox

load_dotenv()
api_key = os.getenv("AGENTINBOX_API_KEY")

client = Agentinbox(api_key=api_key)

print("Creating inbox...")
inbox = client.inboxes.create()
print("Inbox created successfully!")
print(inbox)

client.inboxes.messages.send(
  inbox.inbox_id,
  to="your-email@example.com",
  subject="Hello from Agent Inbox!",
  text="This is my first email sent with the Agent Inbox API.",
)

```

**`TypeScript`**

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

async function main() {
  const client = new AgentinboxClient({
    apiKey: process.env.AGENTINBOX_API_KEY,
  });

  console.log("Creating inbox...");
  const inbox = await client.inboxes.create();
  console.log("Inbox created successfully!");
  console.log(inbox);

  console.log("Sending email...");
  await client.inboxes.messages.send(inbox.inboxId, {
    to: "your-email@example.com",
    subject: "Hello from Agent Inbox!",
    text: "This is my first email sent with the Agent Inbox API.",
  });
  console.log("Email sent successfully!");
}

main().catch((error) => {
  console.error(error);
  process.exit(1);
});
```

> **Note**
>
> Параметр `domain` при создании ящика необязателен. Свои домены настройте в консоли перед продакшеном.

#### Запустите код

**`Python`**

```bash title="Python"
python quickstart.py
```

**`TypeScript`**

```bash title="TypeScript"
npx ts-node quickstart.ts
```

В консоли должны появиться данные созданного ящика.

## Дальше

Изучите автоответы, вложения, webhooks и WebSocket в остальной документации.

> **Note**
>
> Вопросы? Напишите на [info@patternautomation.com](mailto:info@patternautomation.com).