Прочитати запити на погодження й вирішити їх

Отримайте список запитів на погодження, на які чекають виконання, і схваліть або відхиліть запит.

Погодження — це запит рішення людини, на яке чекає виконання. Його створює вузол Потрібне схвалення, а також вузол AI-модель, чия політика перевитрати просить людину. Операції цієї сторінки перелічують запити й вирішують їх. Консоль показує ті самі запити на Погодження.

Хто читає і хто вирішує

Читання запитів потребує дозволу management:read. Рішення потребує management:write, бо рішення дозволяє виконанню витрачати гроші. Журнал аудиту записує кожне рішення.

Ключ читає й вирішує запити свого проєкту. Запит іншого проєкту або неіснуючий відповідає 404 з кодом approval_not_found.

Список іде від нових до старих і читається сторінка за сторінкою, як описує стаття Запити. Надішліть status=pending, щоб читати лише запити, які ще чекають.

Що робить рішення

  • Тіло необов’язкове. Його reason довжиною до 500 символів зберігається з погодженням і видно в трасуванні виконання.

  • Відповідь — погодження з новим status і decided_at. Рішення, ухвалене API-ключем, називає ключ у decided_by. Рішення, ухвалене в консолі, називає людину в decided_by_user_id і decided_by_name.

  • Запит не рухає виконання. Виконання продовжується протягом хвилини: через порт Схвалено після схвалення і через Відхилено після відхилення.

  • Запит від вузла моделі вирішується так само. Схвалення дозволяє виклику моделі продовжитися з новим холдом, а відхилення відмовляє в ньому з overrun_stopped — стаття Погодження каже, що далі.

  • Slen надсилає подію вебхука approval.decided з рішенням.

Запит, який більше не можна вирішити

Запит чекає до expires_at. Автор вузла Потрібне схвалення задає час на вузлі, а запит від вузла моделі чекає 24 години. Коли ніхто не вирішив вчасно, запит протягом хвилини стає expired, а approval.decided каже expired. Далі все йде так само, як після відхилення: з вузла Потрібне схвалення виконання виходить через Відхилено, а виклику вузла моделі відмовлено з overrun_stopped.

  • Запит, який більше не pending, відповідає 409 з кодом approval_already_decided: його хтось вирішив, або його строк минув.

  • Запит, який ще pending, коли його час минув, відповідає 409 з кодом approval_expired. Його одразу закривають як expired, ніби ніхто не вирішив, і виконання йде далі так само, як після відхилення.

  • Запит, виконання якого закінчилося й більше не чекає, відповідає тим самим approval_expired. Його закривають як expired, нічого не продовжується, і подія вебхука не надсилається.

Операції

Описи операцій і полів подано англійською.

Погодження, на які чекають виконання

GET /v1/approvals

  • Дозвіл: management:read

Параметри

ПараметрОпис
limit необовʼязково

queryinteger

Page size (default 30).

  • Мінімум: 1
  • Максимум: 100
cursor необовʼязково

querystring

  • Максимальна довжина: 32
status необовʼязково

queryApprovalStatus

  • Одне з: pending, approved, rejected, expired
project необовʼязково

querystring

current narrows the list to the active project — an API key's own, a person's as switched on POST /api/auth/me/project — plus the organization's rows where the resource has them. A literal, never an id: anything else is 422. Without it the list is everything within the caller's reach.

  • Одне з: current

Відповіді

200

One cursor page of approvals

application/json
{
  "data": [
    {
      "approval_id": "74438200973594624",
      "project_id": "74438200973594624",
      "execution_id": "74438200973594624",
      "flow_id": "74438200973594624",
      "node_key": "string",
      "operation_code": "generate_email",
      "note": "string",
      "status": "pending",
      "decided_by": "string",
      "decided_by_user_id": "74438200973594624",
      "decided_by_name": "string",
      "reason": "string",
      "expires_at": "2026-10-02T09:30:00Z",
      "created_at": "2026-10-02T09:30:00Z",
      "decided_at": "2026-10-02T09:30:00Z"
    }
  ],
  "meta": {
    "limit": 1,
    "next_cursor": "string"
  }
}

Помилки

СтатусКодиКоли
401

No credential, or one that is not valid

403

Authenticated, but not allowed: scope (insufficient_scope), policy or tenant (not_a_member); a blocked end customer (customer_blocked); an act only a signed-in person may take (session_required); the role rule on members and invitations (member_forbidden, invite_forbidden); a write to the organization's own rows, or a read of the audit journal, by a caller that does not reach every project (project_access_restricted)

422

Validation failure or a semantically impossible request. Field-level validation from the framework answers {"message", "errors"}; domain refusals answer the standard error envelope. An Idempotency-Key longer than 190 characters is invalid_request in that envelope.

Заголовки

  • X-Request-Id

Тіло кожної помилки — конверт помилки.

Схвалити виконання

POST /v1/approvals/{id}/approve

  • Дозвіл: management:write

A person's verdict names them (decided_by_user_id, decided_by_name); a key's names the key in decided_by, as before.

409 approval_already_decided — the request has left pending: somebody decided it, its deadline passed, or its execution ended. 409 approval_expired — this very call found the request past its expires_at, or found that the execution it belongs to is no longer waiting (it failed, was lost or ran into its parked ceiling); the request is closed as expired and nothing is continued.

A verdict that is accepted is announced to webhook subscribers as approval.decided (see createWebhookEndpoint), and the node that asked leaves {status, reason, approval_id, decided_at} in its output: a refusal and a deadline nobody met both leave through rejected, and nodes.<key>.output.status (rejected / expired) tells them apart.

Параметри

ПараметрОпис
id обовʼязково

pathId

Snowflake identifier, as a string.

  • Шаблон: ^\d+$
  • Приклад: 74438200973594624

Тіло запиту необовʼязково

application/json
{
  "reason": "string"
}

Відповіді

200

The decided approval

application/json
{
  "data": {
    "approval_id": "74438200973594624",
    "project_id": "74438200973594624",
    "execution_id": "74438200973594624",
    "flow_id": "74438200973594624",
    "node_key": "string",
    "operation_code": "generate_email",
    "note": "string",
    "status": "pending",
    "decided_by": "string",
    "decided_by_user_id": "74438200973594624",
    "decided_by_name": "string",
    "reason": "string",
    "expires_at": "2026-10-02T09:30:00Z",
    "created_at": "2026-10-02T09:30:00Z",
    "decided_at": "2026-10-02T09:30:00Z"
  }
}

Помилки

СтатусКодиКоли
401

No credential, or one that is not valid

403

Authenticated, but not allowed: scope (insufficient_scope), policy or tenant (not_a_member); a blocked end customer (customer_blocked); an act only a signed-in person may take (session_required); the role rule on members and invitations (member_forbidden, invite_forbidden); a write to the organization's own rows, or a read of the audit journal, by a caller that does not reach every project (project_access_restricted)

404

No such resource for this tenant. Somebody else's resource — and a resource of a project the caller does not reach — answers the same way on purpose: the two must not be distinguishable.

409

State conflict: idempotency clash, stale draft, illegal transition; the last owner of an organization (last_owner); the owned-organization limit (organization_limit_reached); an end customer with credit history that cannot be deleted (customer_has_history)

422

Validation failure or a semantically impossible request. Field-level validation from the framework answers {"message", "errors"}; domain refusals answer the standard error envelope. An Idempotency-Key longer than 190 characters is invalid_request in that envelope.

Заголовки

  • X-Request-Id

Тіло кожної помилки — конверт помилки.

Відхилити виконання

POST /v1/approvals/{id}/reject

  • Дозвіл: management:write

A person's verdict names them (decided_by_user_id, decided_by_name); a key's names the key in decided_by, as before.

409 approval_already_decided — the request has left pending: somebody decided it, its deadline passed, or its execution ended. 409 approval_expired — this very call found the request past its expires_at, or found that the execution it belongs to is no longer waiting (it failed, was lost or ran into its parked ceiling); the request is closed as expired and nothing is continued.

A verdict that is accepted is announced to webhook subscribers as approval.decided (see createWebhookEndpoint), and the node that asked leaves {status, reason, approval_id, decided_at} in its output: a refusal and a deadline nobody met both leave through rejected, and nodes.<key>.output.status (rejected / expired) tells them apart.

Параметри

ПараметрОпис
id обовʼязково

pathId

Snowflake identifier, as a string.

  • Шаблон: ^\d+$
  • Приклад: 74438200973594624

Тіло запиту необовʼязково

application/json
{
  "reason": "string"
}

Відповіді

200

The decided approval

application/json
{
  "data": {
    "approval_id": "74438200973594624",
    "project_id": "74438200973594624",
    "execution_id": "74438200973594624",
    "flow_id": "74438200973594624",
    "node_key": "string",
    "operation_code": "generate_email",
    "note": "string",
    "status": "pending",
    "decided_by": "string",
    "decided_by_user_id": "74438200973594624",
    "decided_by_name": "string",
    "reason": "string",
    "expires_at": "2026-10-02T09:30:00Z",
    "created_at": "2026-10-02T09:30:00Z",
    "decided_at": "2026-10-02T09:30:00Z"
  }
}

Помилки

СтатусКодиКоли
401

No credential, or one that is not valid

403

Authenticated, but not allowed: scope (insufficient_scope), policy or tenant (not_a_member); a blocked end customer (customer_blocked); an act only a signed-in person may take (session_required); the role rule on members and invitations (member_forbidden, invite_forbidden); a write to the organization's own rows, or a read of the audit journal, by a caller that does not reach every project (project_access_restricted)

404

No such resource for this tenant. Somebody else's resource — and a resource of a project the caller does not reach — answers the same way on purpose: the two must not be distinguishable.

409

State conflict: idempotency clash, stale draft, illegal transition; the last owner of an organization (last_owner); the owned-organization limit (organization_limit_reached); an end customer with credit history that cannot be deleted (customer_has_history)

422

Validation failure or a semantically impossible request. Field-level validation from the framework answers {"message", "errors"}; domain refusals answer the standard error envelope. An Idempotency-Key longer than 190 characters is invalid_request in that envelope.

Заголовки

  • X-Request-Id

Тіло кожної помилки — конверт помилки.

Приклади

Прочитати запити, які чекають

Одне виконання чекає на рішення біля свого вузла review. Нотатку залишив на вузлі автор флоу.

Terminal
curl "https://api.slen.ai/api/v1/approvals?status=pending" \
  -H "Authorization: Bearer $SLEN_API_KEY"
200 OK
{
  "data": [
    {
      "approval_id": "74443031076798464",
      "project_id": "74438200973594624",
      "execution_id": "74443028719599616",
      "flow_id": "74438623450128384",
      "node_key": "review",
      "operation_code": "generate_email",
      "note": "Check the tone before the email goes out.",
      "status": "pending",
      "decided_by": null,
      "decided_by_user_id": null,
      "decided_by_name": null,
      "reason": null,
      "expires_at": "2026-10-03T09:20:11+00:00",
      "created_at": "2026-10-02T09:20:11+00:00",
      "decided_at": null
    }
  ],
  "meta": {
    "limit": 30,
    "next_cursor": null
  }
}

Схвалити запит

Відповідь — погодження з рішенням і ключем, який його ухвалив.

Terminal
curl -X POST https://api.slen.ai/api/v1/approvals/74443031076798464/approve \
  -H "Authorization: Bearer $SLEN_API_KEY"
200 OK
{
  "data": {
    "approval_id": "74443031076798464",
    "project_id": "74438200973594624",
    "execution_id": "74443028719599616",
    "flow_id": "74438623450128384",
    "node_key": "review",
    "operation_code": "generate_email",
    "note": "Check the tone before the email goes out.",
    "status": "approved",
    "decided_by": "74438344587730944",
    "decided_by_user_id": null,
    "decided_by_name": null,
    "reason": null,
    "expires_at": "2026-10-03T09:20:11+00:00",
    "created_at": "2026-10-02T09:20:11+00:00",
    "decided_at": "2026-10-02T09:31:40+00:00"
  }
}

Відхилити запит

Причина зберігається з погодженням. Виконання виходить із вузла через Відхилено.

Terminal
curl https://api.slen.ai/api/v1/approvals/74443031076798464/reject \
  -H "Authorization: Bearer $SLEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "The customer asked us not to write again."
  }'
200 OK
{
  "data": {
    "approval_id": "74443031076798464",
    "project_id": "74438200973594624",
    "execution_id": "74443028719599616",
    "flow_id": "74438623450128384",
    "node_key": "review",
    "operation_code": "generate_email",
    "note": "Check the tone before the email goes out.",
    "status": "rejected",
    "decided_by": "74438344587730944",
    "decided_by_user_id": null,
    "decided_by_name": null,
    "reason": "The customer asked us not to write again.",
    "expires_at": "2026-10-03T09:20:11+00:00",
    "created_at": "2026-10-02T09:20:11+00:00",
    "decided_at": "2026-10-02T09:31:40+00:00"
  }
}

Що читати далі

Зібрано з openapi b070e1f, sdk contract 5cc7055, php ae4a53b, node 84bc62d