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}/flowsflows:readList flows
GET/guilds/{guildId}/flows/runs/{executionId}flows:readGet a flow run
POST/guilds/{guildId}/flows/{workflowId}/runsflows:runRun a flow

Кроме собственных ошибок (см. ниже), любой эндпоинт может вернуть эти общие:

List flows

GET/guilds/{guildId}/flows

Право: flows:read

На сервере должен быть включён модуль: Сценарии

Параметры
ИмяГдеТипОбязательноеОписание
guildIdпутьstringДаID вашего сервера · Discord ID (строка)

Ответ

Поля ответа · 200
ПолеТипОбязательноеОписание
itemsarray of objectДа
items[].idintegerДа
items[].namestringДа
items[].descriptionstring | nullДа
items[].enabledbooleanДа
items[].triggerTypestring | nullДаe.g. trigger.manual, trigger.webhook, trigger.discord.messageCreated
items[].runnablebooleanДаCan be run with POST …/runs (enabled + Manual or Webhook trigger)
items[].updatedAtstring | nullДа
Ответ · 200
{
  "items": [
    {
      "id": 98765,
      "name": "Example",
      "description": "example",
      "enabled": true,
      "triggerType": "example",
      "runnable": true,
      "updatedAt": "2026-10-07T12:00:00.000Z"
    }
  ]
}

Примеры

curl
curl -s "https://console.botgg.app/api/v1/guilds/123456789012345678/flows" \
  -H "Authorization: Bearer $BOTGG_API_KEY"
JavaScript (fetch)
// 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);
Python (requests)
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Коды
409FEATURE_DISABLED
503SERVICE_UNAVAILABLE

Get a flow run

GET/guilds/{guildId}/flows/runs/{executionId}

Право: flows:read

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Да

Ответ

Поля ответа · 200
ПолеТипОбязательноеОписание
executionIdintegerДа
workflowIdintegerДа
statusstringДаrunning | success | error | stopped | cancelled
outputany | nullДаThe last node’s output (finished runs only)
errorstring | nullДа
startedAtstring | nullДа
finishedAtstring | nullДа
durationMsinteger | nullДа
Ответ · 200
{
  "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
curl -s "https://console.botgg.app/api/v1/guilds/123456789012345678/flows/runs/234567890123456789" \
  -H "Authorization: Bearer $BOTGG_API_KEY"
JavaScript (fetch)
// 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);
Python (requests)
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)

Ошибки

Run a flow

POST/guilds/{guildId}/flows/{workflowId}/runs

Право: flows:runЧувствительноеIdempotency-Key

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) и повторяйте его при ретраях — операция выполнится один раз. Как это работает

Тело запроса

Тело запроса
ПолеТипОбязательноеОписание
inputanyНетTrigger data (any JSON): $trigger for Manual flows, $trigger.body for Webhook flows
waitbooleanНетWait for the run to finish (default false → 202 right after it started)
timeoutSecondsintegerНетLongest wait; default = the flow timeout + 5 s
1–120

Ответ

Поля ответа · 202
ПолеТипОбязательноеОписание
executionIdintegerДа
workflowIdintegerДа
statusstringДаrunning | success | error | stopped | cancelled
outputany | nullДаThe last node’s output (finished runs only)
errorstring | nullДа
startedAtstring | nullДа
finishedAtstring | nullДа
durationMsinteger | nullДа
Ответ · 202
{
  "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
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}'
JavaScript (fetch)
// 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);
Python (requests)
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)

Ошибки

Готовы прокачать свой сервер?

Добавьте BotGG бесплатно и включайте нужные функции в веб-консоли.