# API и MCP для AI-агентов

> Подключите своего AI-агента к BotMarketing.pro: настройка компании, каталога, лояльности, расписания и автоматических сообщений через MCP или REST API.

BotMarketing.pro предоставляет MCP-сервер через Streamable HTTP и клиентский REST API. Агент получает доступ к вашей компании с предоставленными вами правами и может выполнять настройку бизнеса из совместимого чата или программы.

## Адреса подключения
- Защищённый MCP: https://botmarketing.pro/mcp
- Публичный MCP регистрации и справочников: https://botmarketing.pro/mcp/onboarding
- REST API: https://botmarketing.pro/api/v1
- Контракт OpenAPI: https://botmarketing.pro/api/v1/openapi.json
- Discovery ресурса MCP: https://botmarketing.pro/.well-known/oauth-protected-resource/mcp
- Discovery сервера OAuth: https://botmarketing.pro/.well-known/oauth-authorization-server
- Ключи и OAuth-подключения: https://botmarketing.pro/agents

## Что агент может настроить

Возможности настройки доступны в рамках текущего тарифа компании. Нового платного флага доступа к API/MCP нет.

- Профиль владельца без изменения учётных данных; контакты, реквизиты, валюта, часовой пояс, изображения и публичная карточка компании.
- Категории, товары и услуги: цены, остатки, параметры бронирования и доставки, порядок каталога, обложки и галереи.
- Программы и уровни лояльности, правила, изображения и активация.
- Рабочее время и доступность товаров и услуг.
- Telegram-бот, меню, приветствие, помощник и документы компании; автоматические напоминания и Instagram-правила ответов.
- Загрузка файлов, доступные тарифы, страны, города, валюты, часовые пояса и оставшиеся шаги настройки.

## Как подключить чат или собственного агента

Передайте агенту сообщение выше и опишите задачу. Агент сам использует инструкцию подключения, регистрацию и методы настройки. Чату нужна поддержка внешних подключений или выполнения авторизованных HTTP-запросов.

- Войдите в существующий аккаунт BotMarketing.pro, выберите нужные права на странице разрешения и подтвердите подключение. OAuth использует Authorization Code и PKCE S256.
- Собственный агент может использовать бессрочный ключ из дополнительного раздела «API и агенты» либо POST /api/v1/auth/token после подтверждения email. Ключ действует до отзыва. Передавайте его только в Authorization: Bearer; не размещайте в URL или публичном тексте.
- Для нового аккаунта публичный /mcp/onboarding предоставляет register_account и справочники. Подтвердите email на сайте, затем подключите защищённый MCP и создайте компанию. До подтверждения доступа к компании нет.
- DeepSeek используйте через собственного агента с вызовами функций или MCP-клиент. Прямое подключение в веб-чате DeepSeek не заявляется.
- После подключения вызовите get_setup_status: он сообщает права, доступные функции, лимиты и следующие шаги. Instagram подключается через существующую браузерную авторизацию.

## Права и выполнение изменений

Подключение разрешено подтверждённому владельцу. На аккаунт приходится одна собственная компания. Доступные права разделены на чтение и изменение компании, каталога, лояльности, расписания, сообщений и каналов.

- Владение, права и ограничения тарифа проверяются при каждом запросе. Сотрудник не может подключить компанию вместо владельца.
- Для создания передавайте устойчивый idempotency_key в MCP или заголовок Idempotency-Key в REST. Повтор с тем же ключом и телом не создаёт дубль; другое тело возвращает конфликт.
- Включение бота, напоминания или правила может запустить отправки. Агент должен активировать функцию только по запросу владельца.
- Отозвать ключ или OAuth-подключение можно в разделе «API и агенты».
- В API первой версии не входят операции CRM, обработка заказов и бронирований, управление персоналом, финансовые операции, изменение клиентских балансов, разовые рассылки и публикация Instagram-постов.

## Agent workflow

```json
{
    "discovery_url": "https://botmarketing.pro/llms.txt",
    "reference_url": "https://botmarketing.pro/en/developers/mcp.md",
    "mcp_url": "https://botmarketing.pro/mcp",
    "onboarding_mcp_url": "https://botmarketing.pro/mcp/onboarding",
    "api_url": "https://botmarketing.pro/api/v1",
    "openapi_url": "https://botmarketing.pro/api/v1/openapi.json",
    "authentication": {
        "preferred": "oauth_pkce",
        "metadata_url": "https://botmarketing.pro/.well-known/oauth-authorization-server",
        "api_key_expiration": null,
        "native_loopback_callbacks_supported": true
    },
    "steps": [
        {
            "action": "discover",
            "agent": "Read the reference and tool schemas. Configure the MCP connection yourself when your host permits it. If the host requires user setup, explain only that minimum connection step. Never claim a connection or mutation succeeded without a tool result."
        },
        {
            "action": "register_if_needed",
            "agent": "For a new account use public register_account or POST /api/v1/auth/register. Ask only for missing required information; do not create another account for an existing owner. Never request an existing password in a chat when OAuth is available."
        },
        {
            "action": "authorize",
            "owner": "Confirm email for a new account, then sign in and approve the agent connection on the website. These actions require the owner; public registration grants no company access."
        },
        {
            "action": "inspect",
            "agent": "On authenticated /mcp call get_setup_status. Use list_countries, list_cities, list_timezones, list_currencies, list_subscriptions and list_types for real IDs. Do not invent values."
        },
        {
            "action": "configure",
            "agent": "Create the owner company only if missing, then perform the requested catalog, loyalty, schedule and channel operations yourself. Do not ask the owner to fill business forms. Keep creation idempotency keys stable across retries. Preserve omitted fields and existing data. Respect scopes and subscription limits. Activate sending only when the owner requested it."
        },
        {
            "action": "verify",
            "agent": "Read back changed resources. Report what actually changed and any required owner action. If the host has no MCP or authenticated HTTP execution, explain the limitation instead of claiming completion."
        }
    ]
}
```

## OAuth scopes

company:read, company:write, catalog:read, catalog:write, loyalty:read, loyalty:write, schedule:read, schedule:write, messages:read, messages:write, channels:read, channels:write

## Каталог MCP-инструментов

### get_connection_guide

Start here when asked to register or configure a business. Read the agent-led workflow, endpoints, and the minimum owner actions for email confirmation and authorization. No account or credentials required.

### list_countries

List available countries. Use returned identifiers and enum values when configuring a company.

### list_cities

List available cities. Use returned identifiers and enum values when configuring a company.

### list_timezones

List available timezones. Use returned identifiers and enum values when configuring a company.

### list_currencies

List available currencies. Use returned identifiers and enum values when configuring a company.

### list_subscriptions

List available subscriptions. Use returned identifiers and enum values when configuring a company.

### list_types

List available types. Use returned identifiers and enum values when configuring a company.

### register_account

Register a new company owner using email and password. Email confirmation is required before connecting the protected /mcp server. Existing accounts must sign in; this tool never grants access to an existing account.

### get_setup_status

Read granted abilities, company setup steps, subscription features and remaining limits.

### get_channel_context

Read the company channel identifiers, connected Instagram accounts and cached Instagram media for targeting and automation configuration. Requires channels:read.

### list_categories

List categories in the connected owner company. Requires catalog:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### get_category

Get categories in the connected owner company. Requires catalog:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### create_category

Create categories in the connected owner company. Requires catalog:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### update_category

Update categories in the connected owner company. Requires catalog:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### delete_category

Delete categories in the connected owner company. Requires catalog:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### list_items

List items in the connected owner company. Requires catalog:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### get_item

Get items in the connected owner company. Requires catalog:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### create_item

Create items in the connected owner company. Requires catalog:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### update_item

Update items in the connected owner company. Requires catalog:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### delete_item

Delete items in the connected owner company. Requires catalog:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### list_schedules

List schedules in the connected owner company. Requires schedule:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### get_schedule

Get schedules in the connected owner company. Requires schedule:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### create_schedule

Create schedules in the connected owner company. Requires schedule:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### update_schedule

Update schedules in the connected owner company. Requires schedule:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### delete_schedule

Delete schedules in the connected owner company. Requires schedule:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### list_loyalty_programs

List loyalty-programs in the connected owner company. Requires loyalty:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### get_loyalty_program

Get loyalty-programs in the connected owner company. Requires loyalty:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### create_loyalty_program

Create loyalty-programs in the connected owner company. Requires loyalty:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### update_loyalty_program

Update loyalty-programs in the connected owner company. Requires loyalty:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### delete_loyalty_program

Delete loyalty-programs in the connected owner company. Requires loyalty:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### list_loyalty_levels

List loyalty-levels in the connected owner company. Requires loyalty:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### get_loyalty_level

Get loyalty-levels in the connected owner company. Requires loyalty:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### create_loyalty_level

Create loyalty-levels in the connected owner company. Requires loyalty:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### update_loyalty_level

Update loyalty-levels in the connected owner company. Requires loyalty:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### delete_loyalty_level

Delete loyalty-levels in the connected owner company. Requires loyalty:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### list_engagement_reminders

List engagement-reminders in the connected owner company. Requires messages:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### get_engagement_reminder

Get engagement-reminders in the connected owner company. Requires messages:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### create_engagement_reminder

Create engagement-reminders in the connected owner company. Requires messages:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### update_engagement_reminder

Update engagement-reminders in the connected owner company. Requires messages:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### delete_engagement_reminder

Delete engagement-reminders in the connected owner company. Requires messages:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### list_instagram_rules

List instagram-rules in the connected owner company. Requires messages:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### get_instagram_rule

Get instagram-rules in the connected owner company. Requires messages:read. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### create_instagram_rule

Create instagram-rules in the connected owner company. Requires messages:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### update_instagram_rule

Update instagram-rules in the connected owner company. Requires messages:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### delete_instagram_rule

Delete instagram-rules in the connected owner company. Requires messages:write. Existing subscription limits apply. PATCH keeps omitted fields. Creation requires a stable idempotency_key; reuse it after an interrupted response.

### remove_categories_file

Remove a file attached to this company resource. Requires write access to its area.

### remove_items_file

Remove a file attached to this company resource. Requires write access to its area.

### remove_loyalty_programs_file

Remove a file attached to this company resource. Requires write access to its area.

### remove_engagement_reminders_file

Remove a file attached to this company resource. Requires write access to its area.

### remove_instagram_rules_file

Remove a file attached to this company resource. Requires write access to its area.

### get_company

Read the connected owner company. Requires company:read.

### create_company

Create the owner company after email confirmation. One company per account. Requires company:write.

### update_company

Update the public company card, contacts, location and settings. Requires company:write.

### get_profile

Read profile configuration without secret credentials.

### update_profile

Update profile configuration. Requires company:write.

### get_bot

Read bot configuration without secret credentials.

### update_bot

Update bot configuration. Requires channels:write. Changes can activate Telegram automation; subscription features apply.

### get_settings

Read settings configuration without secret credentials.

### update_settings

Update settings configuration. Requires channels:write. Changes can activate Telegram automation; subscription features apply.

### get_assistant

Read assistant configuration without secret credentials.

### update_assistant

Update assistant configuration. Requires channels:write. Changes can activate Telegram automation; subscription features apply.

### get_menu

Read menu configuration without secret credentials.

### update_menu

Update menu configuration. Requires channels:write. Changes can activate Telegram automation; subscription features apply.

### upload_file

Upload a file from base64 or a public HTTPS URL. Maximum 20 MiB; redirects and private networks are rejected. Requires write permission for the declared area. Use the returned ID in cover_file_id, image_file_ids or another file field.

### reorder_items

Reorder the visible catalog page using the order_version from list_items. Requires catalog:write. Concurrent catalog changes return a conflict.
