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

# Как использовать метки для состояния?

Метки — строковые теги на сообщениях и тредах: классификация, фильтрация и состояние процесса.

## Метки при отправке

**`Python`**

```python title="Python"
client.inboxes.messages.send(
    inbox_id="agent@yourdomain.com",
    to=["prospect@example.com"],
    subject="Quick question",
    text="Hi, I wanted to ask about...",
    html="<p>Hi, I wanted to ask about...</p>",
    labels=["outreach", "first-touch", "tech-vertical"]
)
```

## Обновление меток

**`Python`**

```python title="Python"
client.inboxes.messages.update(
    inbox_id="agent@yourdomain.com",
    message_id=msg.message_id,
    add_labels=["processed", "positive-sentiment"],
    remove_labels=["unread"]
)
```

## Фильтрация

**`Python`**

```python title="Python"
unread = client.inboxes.messages.list(
    inbox_id="agent@yourdomain.com",
    labels=["unread"]
)

follow_ups = client.inboxes.threads.list(
    inbox_id="agent@yourdomain.com",
    labels=["q4-campaign", "needs-response"]
)

escalations = client.inboxes.messages.list(
    inbox_id="agent@yourdomain.com",
    labels=["escalation", "needs-human-review"]
)
```

## Типовые метки

| Метка                   | Назначение            |
| ----------------------- | --------------------- |
| `unread` / `read`       | Просмотрено агентом   |
| `unreplied` / `replied` | Нужен ответ           |
| `outreach` / `inbound`  | Направление           |
| `needs-human-review`    | На проверку человеку  |
| `escalation`            | Приоритет / эскалация |
| `processed`             | Обработано            |
| `positive` / `negative` | Тональность           |
| `campaign-{name}`       | Кампания              |

Имена произвольные — держите единый стиль.

## Пример workflow

**`Python`**

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

client = Agentinbox()

unreplied = client.inboxes.threads.list(
    inbox_id="support@yourdomain.com",
    labels=["unreplied"]
)

for thread_item in unreplied.threads:
    thread = client.threads.get(thread_id=thread_item.thread_id)
    last_message = thread.messages[-1]
    
    category = classify(last_message.extracted_text or last_message.text)
    
    if category == "needs-human":
        client.inboxes.messages.update(
            inbox_id="support@yourdomain.com",
            message_id=last_message.message_id,
            add_labels=["needs-human-review", "escalation"],
            remove_labels=["unreplied"]
        )
    else:
        reply_text = generate_reply(last_message, category)
        client.inboxes.messages.reply(
            inbox_id="support@yourdomain.com",
            message_id=last_message.message_id,
            text=reply_text
        )
        client.inboxes.messages.update(
            inbox_id="support@yourdomain.com",
            message_id=last_message.message_id,
            add_labels=["replied", "processed", category],
            remove_labels=["unreplied"]
        )
```

## Практика

* Единое соглашение (например `kebab-case`)
* Префиксы: `status-pending`, `priority-high`
* Не перегружайте одно письмо десятками меток
* Совмещайте с фильтром тредов по меткам

См. [Метки](/labels).