Files
MAX/docs/max-api/02-methods.md
root 7cd3ccf21c MAX bot + n8n: webhook, нормализация, меню, доки, схемы БД
- register_max_webhook.py, fetch_schema.py
- n8n-code-node-max-normalize.js (max_id, callback из callback.user, contact из vcf_info)
- n8n-code-add-menu-buttons.js (меню с callback, request_contact, Главное меню)
- docs: max-webhook, max-curl-http-request, max-api (форматы, кнопки, контакт), clpr vs sprf
- README, SITUATION, схемы sprf_ и clpr_, .gitignore

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-16 09:23:51 +03:00

87 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Методы Max Bot API
## POST /messages — отправить сообщение
`POST https://platform-api.max.ru/messages?user_id={user_id}` или `?chat_id={chat_id}`
Заголовки: `Authorization: <token>`, `Content-Type: application/json`.
Query: user_id (int64) или chat_id (int64), опционально disable_link_preview (bool).
Тело (NewMessageBody): text (до 4000 символов), attachments, link, notify (по умолч. true), format (markdown | html).
Пример:
```bash
curl -X POST "https://platform-api.max.ru/messages?user_id=123" \
-H "Authorization: TOKEN" \
-H "Content-Type: application/json" \
-d '{"text": "Привет!", "format": "markdown"}'
```
Ответ: объект message (Message).
---
## GET /updates — Long Polling
`GET https://platform-api.max.ru/updates`
Параметры: limit (1-1000, по умолч. 100), timeout (0-90 сек, по умолч. 30), marker (int64), types (массив типов, напр. message_created, message_callback).
Ответ: updates (массив Update), marker для следующего запроса.
---
## POST /subscriptions — Webhook
`POST https://platform-api.max.ru/subscriptions`
Тело: url (обязательно https), update_types (массив), secret (5-256 символов, [a-zA-Z0-9_-]) — приходит в заголовке X-Max-Bot-Api-Secret.
Порты сервера: 80, 8080, 443, 8443, 16384-32383.
Пример:
```json
{
"url": "https://your-domain.com/webhook",
"update_types": ["message_created", "bot_started"],
"secret": "your_secret"
}
```
---
## POST /answers — ответ на нажатие кнопки
`POST https://platform-api.max.ru/answers?callback_id={callback_id}`
callback_id берётся из Update с типом message_callback.
Тело: message (NewMessageBody, опц.) — обновить сообщение; notification (string, опц.) — одноразовое уведомление.
---
## PUT /messages — редактировать сообщение
`PUT https://platform-api.max.ru/messages?message_id={message_id}`
Тело: text, attachments (null = не менять, [] = удалить все), link, notify, format.
**Ограничение:** редактировать можно только сообщения, отправленные **менее 24 часов назад**.
---
## DELETE /messages — удалить сообщение
`DELETE https://platform-api.max.ru/messages?message_id={message_id}`
**Ограничение:** удалять можно только сообщения, отправленные **менее 24 часов назад**.
---
## Остальные методы
GET /me — информация о боте. GET/PATCH/DELETE /chats, GET/POST/DELETE /chats/{chatId}/members, GET /subscriptions, DELETE /subscriptions, POST /uploads, GET/PUT/DELETE /messages, GET /messages/{messageId}, POST /chats/{chatId}/actions и др. — см. https://dev.max.ru/docs-api