REST API v1 · Разработчикам · Справочник API
Справочник API: Сценарии
Все 3 эндпоинта раздела «Сценарии» в REST API BotGG v1: права, параметры, поля, ошибки и готовые примеры на curl, JavaScript и Python.
Документация для разработчиков
На этой странице
Эндпоинты
Пути указаны относительно https://console.botgg.app/api/v1. Передавайте API-ключ в заголовке Authorization: Bearer botgg_…; ID — строки.
| Эндпоинт | Право | Описание |
|---|---|---|
GET/guilds/{guildId}/flows | flows:read | List flows |
GET/guilds/{guildId}/flows/runs/{executionId} | flows:read | Get a flow run |
POST/guilds/{guildId}/flows/{workflowId}/runs | flows:run | Run a flow |
Кроме собственных ошибок (см. ниже), любой эндпоинт может вернуть эти общие:
List flows
GET/guilds/{guildId}/flows
На сервере должен быть включён модуль: Сценарии
| Имя | Где | Тип | Обязательное | Описание |
|---|---|---|---|---|
guildId | путь | string | Да | ID вашего сервера · Discord ID (строка) |
Ответ
| Поле | Тип | Обязательное | Описание |
|---|---|---|---|
items | array of object | Да | |
items[].id | integer | Да | |
items[].name | string | Да | |
items[].description | string | null | Да | |
items[].enabled | boolean | Да | |
items[].triggerType | string | null | Да | e.g. trigger.manual, trigger.webhook, trigger.discord.messageCreated |
items[].runnable | boolean | Да | Can be run with POST …/runs (enabled + Manual or Webhook trigger) |
items[].updatedAt | string | null | Да |
{
"items": [
{
"id": 98765,
"name": "Example",
"description": "example",
"enabled": true,
"triggerType": "example",
"runnable": true,
"updatedAt": "2026-10-07T12:00:00.000Z"
}
]
}Примеры
curl -s "https://console.botgg.app/api/v1/guilds/123456789012345678/flows" \
-H "Authorization: Bearer $BOTGG_API_KEY"// Node.js 18+ (built-in fetch) — on your server, never in a browser
const res = await fetch('https://console.botgg.app/api/v1/guilds/123456789012345678/flows', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.BOTGG_API_KEY}`,
},
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`);
console.log(data);import os
import requests
res = requests.get(
"https://console.botgg.app/api/v1/guilds/123456789012345678/flows",
headers={
"Authorization": f"Bearer {os.environ['BOTGG_API_KEY']}",
},
timeout=10,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {data['error']}: {data['message']}")
print(data)Ошибки
| HTTP | Коды |
|---|---|
| 409 | FEATURE_DISABLED |
| 503 | SERVICE_UNAVAILABLE |
Get a flow run
GET/guilds/{guildId}/flows/runs/{executionId}
Status of a run (any run of this server’s flows); output is the last node’s output once it finished.
На сервере должен быть включён модуль: Сценарии
| Имя | Где | Тип | Обязательное | Описание |
|---|---|---|---|---|
guildId | путь | string | Да | ID вашего сервера · Discord ID (строка) |
executionId | путь | string | Да |
Ответ
| Поле | Тип | Обязательное | Описание |
|---|---|---|---|
executionId | integer | Да | |
workflowId | integer | Да | |
status | string | Да | running | success | error | stopped | cancelled |
output | any | null | Да | The last node’s output (finished runs only) |
error | string | null | Да | |
startedAt | string | null | Да | |
finishedAt | string | null | Да | |
durationMs | integer | null | Да |
{
"executionId": 98765,
"workflowId": 98765,
"status": "example",
"output": null,
"error": "example",
"startedAt": "2026-10-07T12:00:00.000Z",
"finishedAt": "2026-10-07T12:00:00.000Z",
"durationMs": 10
}Примеры
curl -s "https://console.botgg.app/api/v1/guilds/123456789012345678/flows/runs/234567890123456789" \
-H "Authorization: Bearer $BOTGG_API_KEY"// Node.js 18+ (built-in fetch) — on your server, never in a browser
const res = await fetch('https://console.botgg.app/api/v1/guilds/123456789012345678/flows/runs/234567890123456789', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.BOTGG_API_KEY}`,
},
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`);
console.log(data);import os
import requests
res = requests.get(
"https://console.botgg.app/api/v1/guilds/123456789012345678/flows/runs/234567890123456789",
headers={
"Authorization": f"Bearer {os.environ['BOTGG_API_KEY']}",
},
timeout=10,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {data['error']}: {data['message']}")
print(data)Ошибки
| HTTP | Коды |
|---|---|
| 404 | FLOW_EXECUTION_NOT_FOUND |
| 409 | FEATURE_DISABLED |
| 503 | SERVICE_UNAVAILABLE |
Run a flow
POST/guilds/{guildId}/flows/{workflowId}/runs
Only enabled flows with a Manual or Webhook trigger. A Webhook flow runs as if its webhook URL was called with input as the JSON body. Counts toward the plan’s daily runs. 202 { executionId, status: "running" }, or with wait: true 200 with the final status and output (202 when it is still running after the timeout — poll GET …/flows/runs/{executionId}).
На сервере должен быть включён модуль: Сценарии
| Имя | Где | Тип | Обязательное | Описание |
|---|---|---|---|---|
guildId | путь | string | Да | ID вашего сервера · Discord ID (строка) |
workflowId | путь | string | Да | |
Idempotency-Key | заголовок | string | Нет | Необязательно. Передайте уникальное значение (UUID) и повторяйте его при ретраях — операция выполнится один раз. Как это работает |
Тело запроса
| Поле | Тип | Обязательное | Описание |
|---|---|---|---|
input | any | Нет | Trigger data (any JSON): $trigger for Manual flows, $trigger.body for Webhook flows |
wait | boolean | Нет | Wait for the run to finish (default false → 202 right after it started) |
timeoutSeconds | integer | Нет | Longest wait; default = the flow timeout + 5 s 1–120 |
Ответ
| Поле | Тип | Обязательное | Описание |
|---|---|---|---|
executionId | integer | Да | |
workflowId | integer | Да | |
status | string | Да | running | success | error | stopped | cancelled |
output | any | null | Да | The last node’s output (finished runs only) |
error | string | null | Да | |
startedAt | string | null | Да | |
finishedAt | string | null | Да | |
durationMs | integer | null | Да |
{
"executionId": 98765,
"workflowId": 98765,
"status": "example",
"output": null,
"error": "example",
"startedAt": "2026-10-07T12:00:00.000Z",
"finishedAt": "2026-10-07T12:00:00.000Z",
"durationMs": 10
}Примеры
curl -s -X POST "https://console.botgg.app/api/v1/guilds/123456789012345678/flows/234567890123456789/runs" \
-H "Authorization: Bearer $BOTGG_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"input":null,"wait":true,"timeoutSeconds":3600}'// Node.js 18+ (built-in fetch) — on your server, never in a browser
const res = await fetch('https://console.botgg.app/api/v1/guilds/123456789012345678/flows/234567890123456789/runs', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.BOTGG_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(), // reuse it when you retry this request
},
body: JSON.stringify({
input: null,
wait: true,
timeoutSeconds: 3600,
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`);
console.log(data);import os, uuid
import requests
res = requests.post(
"https://console.botgg.app/api/v1/guilds/123456789012345678/flows/234567890123456789/runs",
headers={
"Authorization": f"Bearer {os.environ['BOTGG_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()), # reuse it when you retry this request
},
json={
"input": None,
"wait": True,
"timeoutSeconds": 3600,
},
timeout=10,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {data['error']}: {data['message']}")
print(data)Ошибки
| HTTP | Коды |
|---|---|
| 400 | INVALID_JSON |
| 402 | PLAN_LIMIT |
| 404 | FLOW_NOT_FOUND |
| 409 | FEATURE_DISABLED, FLOW_NOT_RUNNABLE, FLOW_DISABLED |
| 413 | PAYLOAD_TOO_LARGE |
| 415 | UNSUPPORTED_MEDIA_TYPE |
| 422 | IDEMPOTENCY_KEY_REUSED |
| 503 | SERVICE_UNAVAILABLE |