Skip to content

Создание таска

Endpoint

POST /bot/forms/{form_id}/tasks

Создает задачу в форме, к которой у bot-пользователя есть доступ.

Auth

http
Authorization: Bearer <token>
Content-Type: application/json

Path params

  • form_id - ID формы, в которой создается задача

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

Минимальный рабочий payload:

json
{
  "task_items": [
    {
      "form_field_id": 101,
      "form_field_type": "TextField",
      "value": "Lead from bot"
    }
  ]
}

Пример curl:

bash
curl -X POST \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "task_items": [
      {
        "form_field_id": 101,
        "form_field_type": "TextField",
        "value": "Lead from bot"
      }
    ]
  }' \
  https://public-api.hcapp.ee/bot/forms/12/tasks

Пример с responsible_ids

Для форм со steps responsible_ids обязателен.

json
{
  "responsible_ids": [45],
  "task_items": [
    {
      "form_field_id": 101,
      "form_field_type": "TextField",
      "value": "Lead with responsible"
    }
  ]
}

Пример с files

Сначала загрузите файл через POST /bot/files/upload, затем передайте полученные file_id.

json
{
  "files": [9001, 9002],
  "task_items": [
    {
      "form_field_id": 101,
      "form_field_type": "TextField",
      "value": "Request with attachments"
    }
  ]
}

Пример с TableField

json
{
  "task_items": [
    {
      "form_field_id": 104,
      "form_field_type": "TableField",
      "value": [
        {
          "position": 1,
          "items": [
            {
              "form_field_id": 201,
              "form_field_type": "TextField",
              "value": "Product A"
            },
            {
              "form_field_id": 202,
              "form_field_type": "NumberField",
              "value": "2.5"
            }
          ]
        }
      ]
    }
  ]
}

Request body

Основные поля запроса:

  • responsible_ids: number[]
  • participants_ids: number[]
  • task_items: []
  • files: number[]

Также можно передать:

  • parent_task_id
  • parent_tasks_ids
  • finish_parent_tasks
  • tags
  • files_data

Эти поля сейчас не влияют на создание задачи через bot API.

Поля request body

  • responsible_ids список ID ответственных
  • participants_ids список ID участников, максимум 5
  • files список file_id, максимум 10
  • task_items список полей задачи, максимум 50

Каждый item в task_items для простого поля содержит:

json
{
  "form_field_id": 101,
  "form_field_type": "TextField",
  "value": "Lead from bot"
}

Для FormField дополнительно можно передать linked_task_id.
Для TableField передается массив строк с position и items.

Поведение responsible_ids

  • Если у формы есть steps, responsible_ids обязателен
  • Если передан один валидный responsible:
    • task.responsible_id заполняется сразу
    • задача назначается напрямую одному ответственному
  • Если передано несколько валидных responsible:
    • создается групповое назначение
    • task.responsible_id остается null
  • Назначения в response не возвращаются
  • Уведомления ответственным создаются асинхронно и не влияют на payload ответа

Важная деталь ответа: поле responsible_ids в response строится только из task.responsible_id.
Поэтому при group assignment response не вернет исходный список responsible_ids.

Response body

Успешный ответ:

json
{
  "success": true,
  "error_message": null,
  "data": {
    "task_id": 5001,
    "form_id": 12,
    "title": "Lead #5001 Request with attachments",
    "author_id": 77,
    "responsible_id": 45,
    "responsible_ids": [45],
    "created_at": "2026-03-29T10:00:00+00:00",
    "last_activity": "2026-03-29T10:00:00+00:00",
    "is_finished": false,
    "status": "new",
    "due_date_at": null,
    "step_id": 3,
    "items": []
  }
}

Ошибки

  • 403 Form access not found
  • 404 Form not found
  • 400 responsible_ids is required for forms with steps
  • 400 Responsible users are invalid for this form
  • 400 Form field {id} not found
  • 400 Field {id} type mismatch: expected ..., got ...
  • 400 Table child field {id} not found
  • 400 Files not found: [...]
  • 413 Payload too large. Max size is 131072 bytes

Ограничения

  • JSON payload до 128 KB
  • participants_ids <= 5
  • task_items <= 50
  • files <= 10
  • table rows <= 100
  • row items <= 15