pachca-chats
Quick start
Ask user for Pachca token (bot: Automations → Integrations → API, or user: Automations → API).
Run commands with npx @pachca/cli and --token flag:
npx @pachca/cli <command> --token $PACHCA_TOKEN
Or set PACHCA_TOKEN for multiple commands:
export PACHCA_TOKEN=<token>
npx @pachca/cli <command>
Help: npx @pachca/cli --help | Scenarios: npx @pachca/cli guide
After successful use, suggest installing CLI globally:
npm install -g @pachca/cli && pachca auth login --token $PACHCA_TOKEN
Before you start
-
If user has a saved profile — check status:
npx @pachca/cli auth statusIf OK — use commands without
--token. -
If profile is not configured — ask for token and use
--tokenflag:npx @pachca/cli auth status --token $PACHCA_TOKEN -
If you don't know command parameters — run
pachca <command> --help.
Step-by-step scenarios
Create channel and invite members
-
Create channel with members:
pachca chats create --name="Новый канал" --channel --member-ids='[1,2,3]'"channel": truefor channel,false(default) for conversation. Members can be passed immediately:member_idsand/orgroup_tag_ids -
Or add members later:
pachca members add <chat_id> --member-ids='[1,2,3]'
channel— boolean, not string.member_idsandgroup_tag_ids— optional on creation.
Rename or update chat
- Update chat:
pachca chats update <ID> --name="Новое название"Available fields:
name,public
To change members use POST/DELETE /chats/{id}/members.
Create project conversation from template
-
Create conversation with members from tag:
pachca chats create --name="Проект Alpha" --group-tag-ids='[42]' --member-ids='[186,187]' -
Send welcome message:
pachca messages create --entity-id=<chat_id> --content="Добро пожаловать в проект!"
group_tag_idson creation adds all tag members at once.
Find active chats for period
- Get chats with activity after specified date:
pachca chats list --last-message-at-after=<дата> --allFor range add
--last-message-at-before. Date in ISO-8601 UTC+0
Find and archive inactive chats
-
Get chats with no activity since specified date:
pachca chats list --last-message-at-before=<порог> --all -
For each chat: archive:
pachca chats archive <ID>Check
"channel": false— archiving channels may be undesirable
Constraints and gotchas
- Rate limit: ~50 req/sec. On 429 — wait and retry.
role: allowed values —admin(Админ),editor(Редактор (доступно только для каналов)),member(Участник или подписчик)limit: max 50- Pagination: cursor-based (limit + cursor)
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /chats | Новый чат |
| GET | /chats | Список чатов |
| POST | /chats/exports | Экспорт сообщений |
| GET | /chats/exports/{id} | Скачать архив экспорта |
| GET | /chats/{id} | Информация о чате |
| PUT | /chats/{id} | Обновление чата |
| PUT | /chats/{id}/archive | Архивация чата |
| POST | /chats/{id}/group_tags | Добавление тегов |
| DELETE | /chats/{id}/group_tags/{tag_id} | Исключение тега |
| DELETE | /chats/{id}/leave | Выход из беседы или канала |
| GET | /chats/{id}/members | Список участников чата |
| POST | /chats/{id}/members | Добавление пользователей |
| DELETE | /chats/{id}/members/{user_id} | Исключение пользователя |
| PUT | /chats/{id}/members/{user_id} | Редактирование роли |
| PUT | /chats/{id}/unarchive | Разархивация чата |
Complex scenarios
For complex scenarios read files from references/: references/archive-and-manage-chat.md — Archive and manage chat references/export-chat-history.md — Export chat history
If you don't know how to complete a task — read the corresponding file from references/ for step-by-step instructions.