API reference
Automation, AI and Telegram
Webhooks and automation rules, the AI assistant and the Telegram bot.
Automation
Outgoing webhooks, automation rules and their logs.
/api/automation/event-types
List event and action types
Returns the catalogue of panel event types (for webhook filters and rule triggers) and the supported rule action types.
- Token or session
- Admin
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- site.down, site.up and ssl.expiring are listed but no code in apps/api/src currently emits them.
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/automation/event-types" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"events": [
"deploy.succeeded",
"deploy.failed",
"site.down",
"site.up",
"ssl.expiring",
"billing.invoice_paid",
"billing.suspended",
"billing.restored",
"fleet.alert",
"fleet.alert_resolved"
],
"actions": [
"notify",
"telegram",
"webhook"
]
}
/api/automation/webhooks
List outbound webhooks
Lists outbound webhooks, newest first. Secrets are never returned; hasSecret tells whether one is set.
- Token or session
- Admin
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- events is the parsed filter array ([] = all events).
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/automation/webhooks" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"webhooks": [
{
"id": 4,
"name": "Ops channel",
"url": "https://hooks.example.com/orchestrator",
"events": [
"deploy.failed",
"billing.suspended"
],
"active": true,
"hasSecret": true,
"createdAt": "2026-11-27T10:00:00.000Z"
}
]
}
/api/automation/webhooks
Create an outbound webhook
Creates an outbound webhook. While active, the panel POSTs every matching event as JSON { event, data, at } with headers x-orchestrator-event and, when a secret is set, x-orchestrator-signature: sha256=<hex HMAC-SHA256 of the raw body>. Inactive by default.
- Token or session
- Admin
- Audit:
webhook.created
Body
namestringrequired- Display name.1β100 chars
urlstringrequired- Endpoint the panel POSTs events to.1β2000 chars; must start with http:// or https://
secretstring- HMAC-SHA256 signing key (write-only; encrypted at rest, never returned β responses only show hasSecret).max 200 chars
eventsarray- Event types to deliver; [] (default) = all events.array of strings, max 50 items; values are not checked against the event catalogue
activeboolean- Deliveries only happen while active.default false
Errors
- 400
URL must start with http:// or https://url has another scheme.- 400
body must have required property 'url'Schema validation failure (FST_ERR_VALIDATION; message varies).- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- Deliveries are fire-and-forget with a 10-second timeout and no retries; each attempt is logged (newest 100 kept per webhook).
- Unknown body fields are removed silently (additionalProperties: false).
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X POST "https://panel.example.com/api/automation/webhooks" \
-H "Authorization: Bearer $ORCH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Ops channel",
"url": "https://hooks.example.com/orchestrator",
"secret": "example-signing-secret",
"events": [
"deploy.failed",
"billing.suspended"
],
"active": true
}'{
"id": 4,
"name": "Ops channel",
"url": "https://hooks.example.com/orchestrator",
"events": [
"deploy.failed",
"billing.suspended"
],
"active": true,
"hasSecret": true,
"createdAt": "2026-11-27T10:00:00.000Z"
}
/api/automation/webhooks/{id}
Update an outbound webhook
Updates the given webhook fields only. Sending secret replaces the signing key; an empty string removes it.
- Token or session
- Admin
- Audit:
webhook.updated
Path parameters
idintegerrequired- Webhook id.not validated (Number(...) of the path segment)
Body
namestring- Display name.1β100 chars
urlstring- Endpoint the panel POSTs events to.1β2000 chars; must start with http:// or https://
secretstring- HMAC-SHA256 signing key (write-only; encrypted at rest, never returned β responses only show hasSecret). An empty string removes the secret.max 200 chars
eventsarray- Event types to deliver; [] (default) = all events.array of strings, max 50 items; values are not checked against the event catalogue
activeboolean- Deliveries only happen while active.
Errors
- 400
URL must start with http:// or https://url given with another scheme.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Webhook not foundNo webhook with this id (any update failure is reported as 404).
- Unknown body fields are removed silently (additionalProperties: false).
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X PATCH "https://panel.example.com/api/automation/webhooks/3" \
-H "Authorization: Bearer $ORCH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"active": false,
"events": []
}'{
"id": 4,
"name": "Ops channel",
"url": "https://hooks.example.com/orchestrator",
"events": [],
"active": false,
"hasSecret": true,
"createdAt": "2026-11-27T10:00:00.000Z"
}
/api/automation/webhooks/{id}
Delete an outbound webhook
Deletes a webhook and its delivery log.
- Token or session
- Admin
- Audit:
webhook.deleted
Path parameters
idintegerrequired- Webhook id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- Returns { ok: true } (and writes the audit entry) even when no webhook has this id.
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X DELETE "https://panel.example.com/api/automation/webhooks/3" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true
}
/api/automation/webhooks/{id}/deliveries
List webhook deliveries
Returns the newest 50 delivery attempts of a webhook, including test pings.
- Token or session
- Admin
Path parameters
idintegerrequired- Webhook id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- statusCode is null and error holds the exception message when the request failed or timed out. An unknown webhook id returns an empty list.
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/automation/webhooks/3/deliveries" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"deliveries": [
{
"id": 310,
"webhookId": 4,
"event": "deploy.failed",
"success": false,
"statusCode": 500,
"error": "HTTP 500",
"createdAt": "2026-11-27T10:00:00.000Z"
}
]
}
/api/automation/webhooks/{id}/test
Send a test delivery
Immediately POSTs a test.ping event to the webhook URL (even if the webhook is inactive), signed like a real delivery, waits up to 10 seconds, logs the attempt and reports the outcome.
- Token or session
- Admin
Path parameters
idintegerrequired- Webhook id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Webhook not foundNo webhook with this id.- 502
<network or timeout error message>The request could not be sent or timed out after 10 s; body is { ok: false, error: <message> }.
- Sent body: { "event": "test.ping", "data": { "message": "Orchestrator test delivery" }, "at": <ISO time> } with headers content-type: application/json, x-orchestrator-event: test.ping and, when a secret is set, x-orchestrator-signature: sha256=<hex HMAC-SHA256 of the body>.
- A non-2xx answer from the endpoint still returns HTTP 200 here, with ok: false and its statusCode.
- No audit entry is written. The test route itself does not prune the delivery log (real deliveries keep the newest 100).
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X POST "https://panel.example.com/api/automation/webhooks/3/test" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true,
"statusCode": 200
}
/api/automation/rules
List automation rules
Lists automation rules, newest first, with conditions and actionConfig parsed from JSON.
- Token or session
- Admin
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- Rules run asynchronously (fire-and-forget) when the panel emits an event whose type equals trigger, and only while enabled. Each evaluation is logged as an AutomationRun (newest 100 kept per rule); with dryRun the run records actionTaken "would <actionType>".
- Actions: notify creates a panel notification; telegram sends via the configured notification channel; webhook POSTs { event, data: <payload>, at } as JSON to actionConfig.url with a 10-second timeout. No action can change a hosted site.
- Event payload fields usable in conditions/placeholders: deploy.succeeded / deploy.failed β siteId, domain, branch, commit, status, testsPassed, testsFailed, testsTotal; billing.invoice_paid β invoiceId, number, currency, fullyPaid, restored; billing.suspended β siteId, domain, level; billing.restored β invoiceId, subscriptionId; fleet.alert β eventId, serverId, serverName, kind, ruleId, message, value; fleet.alert_resolved β eventId, serverId, serverName, kind, ruleId, message.
- site.down, site.up and ssl.expiring are in the event catalogue but no code in apps/api/src currently emits them.
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/automation/rules" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"rules": [
{
"id": 2,
"name": "Alert on failed deploys",
"trigger": "deploy.failed",
"conditions": [
{
"field": "domain",
"op": "contains",
"value": "shop"
}
],
"actionType": "notify",
"actionConfig": {
"title": "Deploy failed on {{domain}}",
"body": "Branch {{branch}} at {{commit}}",
"level": "critical"
},
"enabled": true,
"dryRun": false,
"lastFiredAt": "2026-11-27T10:00:00.000Z",
"createdAt": "2026-11-27T10:00:00.000Z",
"updatedAt": "2026-11-27T10:00:00.000Z"
}
]
}
/api/automation/rules
Create an automation rule
Creates a rule that reacts to a panel event: when an event of type trigger is emitted and all conditions match, the action runs. New rules are disabled and in dry-run mode unless enabled/dryRun say otherwise.
- Token or session
- Admin
- Audit:
automation.rule_created
Body
namestringrequired- Rule name.1β100 chars
triggerstringrequired- Event type that fires the rule (exact match).1β64 chars; not checked against the event catalogue
conditionsarray- Conditions, all of which must match (AND). [] = always matches.max 20 items; items not validated; default []
conditions[].fieldstring- Dotted path into the event payload, e.g. domain or testsFailed.not validated
conditions[].opstring- Comparison operator. eq/neq compare as strings; gt/gte/lt/lte compare as numbers; contains is a case-insensitive substring test. Any other value never matches.one of: eq, neq, gt, gte, lt, lte, contains (not validated)
conditions[].valuestring- Value to compare with.not validated; any JSON value
actionTypestringrequired- What to do when the rule matches.one of: notify, telegram, webhook
actionConfigobject- Action parameters (keys depend on actionType; see notes). title/body/message support {{field}} placeholders from the event payload.object; keys not validated; default {}
actionConfig.titlestring- notify: notification title (default "Automation: <event>"); telegram: message title (default the event type).not validated
actionConfig.bodystring- notify: notification body.not validated
actionConfig.messagestring- telegram: message text.not validated
actionConfig.levelstring- notify: notification level (default info). telegram: "critical" sends as a failure, anything else as a warning.notify: info, success, warning, critical (not validated)
actionConfig.urlstring- webhook: URL to POST the event to (required for that action at run time; no placeholders, no signature).not validated
enabledboolean- Rules only run while enabled.default false
dryRunboolean- Record what would happen without performing the action.default true
Errors
- 400
body/actionType must be equal to one of the allowed valuesSchema validation failure (FST_ERR_VALIDATION; message varies).- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- Unlike GET /rules, the response returns conditions and actionConfig as raw JSON strings.
- Unknown body fields are removed silently (additionalProperties: false).
- Rules run asynchronously (fire-and-forget) when the panel emits an event whose type equals trigger, and only while enabled. Each evaluation is logged as an AutomationRun (newest 100 kept per rule); with dryRun the run records actionTaken "would <actionType>".
- Actions: notify creates a panel notification; telegram sends via the configured notification channel; webhook POSTs { event, data: <payload>, at } as JSON to actionConfig.url with a 10-second timeout. No action can change a hosted site.
- Event payload fields usable in conditions/placeholders: deploy.succeeded / deploy.failed β siteId, domain, branch, commit, status, testsPassed, testsFailed, testsTotal; billing.invoice_paid β invoiceId, number, currency, fullyPaid, restored; billing.suspended β siteId, domain, level; billing.restored β invoiceId, subscriptionId; fleet.alert β eventId, serverId, serverName, kind, ruleId, message, value; fleet.alert_resolved β eventId, serverId, serverName, kind, ruleId, message.
- site.down, site.up and ssl.expiring are in the event catalogue but no code in apps/api/src currently emits them.
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X POST "https://panel.example.com/api/automation/rules" \
-H "Authorization: Bearer $ORCH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Alert on failed deploys",
"trigger": "deploy.failed",
"conditions": [
{
"field": "domain",
"op": "contains",
"value": "shop"
}
],
"actionType": "notify",
"actionConfig": {
"title": "Deploy failed on {{domain}}",
"body": "Branch {{branch}} at {{commit}}",
"level": "critical"
},
"enabled": false,
"dryRun": true
}'{
"id": 2,
"name": "Alert on failed deploys",
"trigger": "deploy.failed",
"conditions": "[{\"field\":\"domain\",\"op\":\"contains\",\"value\":\"shop\"}]",
"actionType": "notify",
"actionConfig": "{\"title\":\"Deploy failed on {{domain}}\",\"body\":\"Branch {{branch}} at {{commit}}\",\"level\":\"critical\"}",
"enabled": false,
"dryRun": true,
"lastFiredAt": null,
"createdAt": "2026-11-27T10:00:00.000Z",
"updatedAt": "2026-11-27T10:00:00.000Z"
}
/api/automation/rules/{id}
Update an automation rule
Updates the given rule fields only (e.g. enable it or switch dry-run off).
- Token or session
- Admin
- Audit:
automation.rule_updated
Path parameters
idintegerrequired- Rule id.not validated (Number(...) of the path segment)
Body
namestring- Rule name.1β100 chars
triggerstring- Event type that fires the rule (exact match).1β64 chars; not checked against the event catalogue
conditionsarray- Conditions, all of which must match (AND). [] = always matches.max 20 items; items not validated
conditions[].fieldstring- Dotted path into the event payload, e.g. domain or testsFailed.not validated
conditions[].opstring- Comparison operator. eq/neq compare as strings; gt/gte/lt/lte compare as numbers; contains is a case-insensitive substring test. Any other value never matches.one of: eq, neq, gt, gte, lt, lte, contains (not validated)
conditions[].valuestring- Value to compare with.not validated; any JSON value
actionTypestring- What to do when the rule matches.one of: notify, telegram, webhook
actionConfigobject- Action parameters (keys depend on actionType; see notes). title/body/message support {{field}} placeholders from the event payload.object; keys not validated
actionConfig.titlestring- notify: notification title (default "Automation: <event>"); telegram: message title (default the event type).not validated
actionConfig.bodystring- notify: notification body.not validated
actionConfig.messagestring- telegram: message text.not validated
actionConfig.levelstring- notify: notification level (default info). telegram: "critical" sends as a failure, anything else as a warning.notify: info, success, warning, critical (not validated)
actionConfig.urlstring- webhook: URL to POST the event to (required for that action at run time; no placeholders, no signature).not validated
enabledboolean- Rules only run while enabled.
dryRunboolean- Record what would happen without performing the action.
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Rule not foundNo rule with this id (any update failure is reported as 404).
- The response returns conditions and actionConfig as raw JSON strings.
- Unknown body fields are removed silently (additionalProperties: false).
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X PATCH "https://panel.example.com/api/automation/rules/3" \
-H "Authorization: Bearer $ORCH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"enabled": true,
"dryRun": false
}'{
"id": 2,
"name": "Alert on failed deploys",
"trigger": "deploy.failed",
"conditions": "[{\"field\":\"domain\",\"op\":\"contains\",\"value\":\"shop\"}]",
"actionType": "notify",
"actionConfig": "{\"title\":\"Deploy failed on {{domain}}\",\"body\":\"Branch {{branch}} at {{commit}}\",\"level\":\"critical\"}",
"enabled": true,
"dryRun": false,
"lastFiredAt": "2026-11-27T10:00:00.000Z",
"createdAt": "2026-11-27T10:00:00.000Z",
"updatedAt": "2026-11-27T10:00:00.000Z"
}
/api/automation/rules/{id}
Delete an automation rule
Deletes a rule and its run log.
- Token or session
- Admin
- Audit:
automation.rule_deleted
Path parameters
idintegerrequired- Rule id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- Returns { ok: true } (and writes the audit entry) even when no rule has this id.
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X DELETE "https://panel.example.com/api/automation/rules/3" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true
}
/api/automation/rules/{id}/runs
List rule runs
Returns the newest 50 evaluations of a rule: whether its conditions matched, whether it was a dry run, and what action was taken.
- Token or session
- Admin
Path parameters
idintegerrequired- Rule id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- actionTaken: the action type when executed, "would <type>" in dry run, "error" when the action threw (detail = error message), null when conditions did not match. detail examples: "notification created", "telegram sent", "POST <url> β 200", or in dry run "notify: <title>" / "telegram: <message>" / "POST <url>".
- An unknown rule id returns an empty list.
- All /api/automation routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/automation/rules/3/runs" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"runs": [
{
"id": 77,
"ruleId": 2,
"event": "deploy.failed",
"matched": true,
"dryRun": false,
"actionTaken": "notify",
"detail": "notification created",
"createdAt": "2026-11-27T10:00:00.000Z"
}
]
}
AI assistant
AI configuration, chat, explanations and history.
/api/ai/config
Get AI configuration
Returns the AI assistant configuration and today's usage. The API key is never returned; configured tells whether one is stored.
- Token or session
- Admin
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- model is the effective model (the provider's default model when none is set, e.g. gpt-4o-mini for openai); baseUrl is the raw stored value ("" = provider default https://api.anthropic.com or https://api.openai.com/v1).
- provider is openai unless the stored value is anthropic. usageToday counts provider requests for the current UTC date; dailyLimit 0 = unlimited.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/ai/config" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"enabled": true,
"provider": "openai",
"model": "gpt-4o-mini",
"baseUrl": "",
"configured": true,
"usageToday": 14,
"dailyLimit": 100
}
/api/ai/config
Update AI configuration
Updates the AI provider settings; only the fields sent are changed. The API key is write-only and stored encrypted.
- Token or session
- Admin
- Audit:
ai.config
Body
enabledboolean- Turn the assistant on or off.
providerstring- Provider API style. openai covers any OpenAI-compatible endpoint (Ollama, LocalAI, groqβ¦).one of: openai, anthropic
modelstring- Model name; "" = provider default.max 100 chars
baseUrlstring- API base URL; "" = provider default. Trailing slashes are removed when used.max 300 chars; format not checked
apiKeystring- Provider API key (write-only, encrypted at rest).max 300 chars; an empty string is ignored (the stored key is kept)
dailyLimitinteger- Max provider requests per UTC day; 0 = unlimited.0β100000
Errors
- 400
body/provider must be equal to one of the allowed valuesSchema validation failure (FST_ERR_VALIDATION; message varies).- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- The stored API key cannot be cleared through this endpoint (empty strings are ignored).
- Unknown body fields are removed silently (additionalProperties: false).
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X PATCH "https://panel.example.com/api/ai/config" \
-H "Authorization: Bearer $ORCH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"enabled": true,
"provider": "openai",
"model": "gpt-4o-mini",
"apiKey": "sk-ant-example-key",
"dailyLimit": 100
}'{
"ok": true
}
/api/ai/test
Test the AI connection
Sends a tiny prompt ("Reply with the single word: OK", max 5 tokens) to the configured provider to check connectivity and the API key. The attempt is stored in the AI history as kind test.
- Token or session
- Admin
Errors
- 400
AI assistant is disabled. Enable it in Settings β Integrations.The assistant is not enabled.- 400
No AI API key configured.No API key is stored.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 502
<provider error message>The provider call failed: its own error message, "AI request failed (<status>)", or "AI request timed out." after 45 s.- 502
Daily AI request limit reached (100). Raise it in Settings β Integrations.The daily limit is exceeded β this route maps it to 502, not 429.
- Every provider request counts toward the daily limit (dailyLimit; 0 = unlimited) per UTC day; the counter is incremented before the check, so refused requests count too.
- No body is read. No audit entry is written.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X POST "https://panel.example.com/api/ai/test" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true,
"reply": "OK"
}
/api/ai/chat
Chat with the assistant
Asks the read-only assistant a question, optionally grounded in a site's context (PHP version, status, last deploy and up to 5 unresolved errors, redacted). Conversations are stored server-side per user: omit conversationId to start a new one, pass it to continue (the last 8 answered turns are replayed). Secrets and email addresses are redacted before anything is sent to the provider.
- Token or session
- Admin
- Audit:
ai.chat
Body
messagestringrequired- The question.1β4000 chars
siteIdinteger- Site to use as context (an unknown id is ignored).
conversationIdinteger- Your existing conversation to continue.must belong to the caller
historyarray- Legacy: client-side transcript, only used when no stored conversation is continued (last 10 items).max 20 items
history[].rolestringrequired- Speaker.one of: user, assistant
history[].contentstringrequired- Message text.max 4000 chars
Errors
- 400
AI assistant is disabled. Enable it in Settings β Integrations.The assistant is not enabled.- 400
No AI API key configured.No API key is stored.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Conversation not foundconversationId does not exist or belongs to another user.- 429
Daily AI request limit reached (100). Raise it in Settings β Integrations.The daily limit is exceeded.- 502
<provider error message>The provider call failed: its own error message, "AI request failed (<status>)", or "AI request timed out." after 45 s. The body then also carries conversationId and interactionId of the stored failed turn.
- Error bodies: pre-flight refusals (disabled / no key / limit) for a NEW conversation return { error } and the just-created conversation is deleted again; otherwise errors return { error, conversationId, interactionId } (interactionId null when nothing reached the provider).
- conversationId in the reply is null only when the conversation could not be stored (the answer is still valid); interactionId is null when the history row could not be written. title is the conversation title (first ~80 chars of the first question by default).
- The answer is capped at 900 tokens; the provider call times out after 45 s. Every provider request counts toward the daily limit (dailyLimit; 0 = unlimited) per UTC day; the counter is incremented before the check, so refused requests count too.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X POST "https://panel.example.com/api/ai/chat" \
-H "Authorization: Bearer $ORCH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": "Why is the queue on shop.example.com backing up?",
"siteId": 7,
"conversationId": 31
}'{
"reply": "Check whether the queue worker is running: supervisorctl statusβ¦",
"conversationId": 31,
"title": "Why is the queue on shop.example.com backing up?",
"interactionId": 512,
"model": "gpt-4o-mini"
}
/api/ai/conversations
List my conversations
Lists the caller's own chat conversations (up to 200), most recently updated first, with the number of stored turns.
- Token or session
- Admin
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- Only conversations whose userId is the caller are returned (works the same with a personal access token, which acts as its owner).
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/ai/conversations" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"conversations": [
{
"id": 31,
"title": "Why is the queue on shop.example.com backing up?",
"siteId": 7,
"createdAt": "2026-11-27T10:00:00.000Z",
"updatedAt": "2026-11-27T10:00:00.000Z",
"messages": 4
}
]
}
/api/ai/conversations/{id}
Get a conversation
Returns one of the caller's conversations with its turns, oldest first (the newest 200 turns at most).
- Token or session
- Admin
Path parameters
idintegerrequired- Conversation id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Conversation not foundNo such conversation or it belongs to another user.
- question is the redacted question without the site-context prefix; a failed turn has response null and error set.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/ai/conversations/14" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"id": 31,
"title": "Why is the queue on shop.example.com backing up?",
"siteId": 7,
"createdAt": "2026-11-27T10:00:00.000Z",
"updatedAt": "2026-11-27T10:00:00.000Z",
"turns": [
{
"id": 512,
"createdAt": "2026-11-27T10:00:00.000Z",
"question": "Why is the queue on shop.example.com backing up?",
"response": "Check whether the queue worker is runningβ¦",
"error": null,
"model": "gpt-4o-mini",
"siteId": 7,
"siteDomain": "shop.example.com"
}
]
}
/api/ai/conversations/{id}
Rename a conversation
Renames one of the caller's conversations. Whitespace runs are collapsed and the title is trimmed.
- Token or session
- Admin
Path parameters
idintegerrequired- Conversation id.not validated (Number(...) of the path segment)
Body
titlestringrequired- New title.1β120 chars
Errors
- 400
Title is requiredThe title is only whitespace.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Conversation not foundNo such conversation or it belongs to another user.
- No audit entry is written.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X PATCH "https://panel.example.com/api/ai/conversations/14" \
-H "Authorization: Bearer $ORCH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Queue backlog on shop"
}'{
"ok": true,
"title": "Queue backlog on shop"
}
/api/ai/conversations/{id}
Delete a conversation
Removes one of the caller's conversations from the chat list. Its questions and answers stay in the AI history (detached from the conversation).
- Token or session
- Admin
- Audit:
ai.conversation_deleted
Path parameters
idintegerrequired- Conversation id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Conversation not foundNo such conversation or it belongs to another user.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X DELETE "https://panel.example.com/api/ai/conversations/14" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true
}
/api/ai/explain-error/{id}
Get stored error explanations
Returns what the AI has already said about a grouped log error β the cached explanation and every stored explanation (newest first, up to 100) β without calling the provider.
- Token or session
- Admin
Path parameters
idintegerrequired- Grouped log error id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Error not foundNo log error with this id.
- explanation is null when the error was never explained. A history read failure yields an empty history rather than an error.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/ai/explain-error/14" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"explanation": "Likely cause: the queue worker cannot reach Redisβ¦",
"history": [
{
"id": 120,
"kind": "explain_error",
"createdAt": "2026-11-27T10:00:00.000Z",
"userEmail": "[email protected]",
"provider": "openai",
"model": "gpt-4o-mini",
"durationMs": 4210,
"response": "Likely cause: the queue worker cannot reach Redisβ¦",
"error": null
}
]
}
/api/ai/explain-error/{id}
Explain a log error
Asks the AI to explain a grouped log error (level, exception class, count, redacted message and sample line) and caches the answer on the error. Returns the cached explanation without calling the provider unless force=1.
- Token or session
- Admin
- Audit:
ai.explain_error
Path parameters
idintegerrequired- Grouped log error id.not validated (Number(...) of the path segment)
Query parameters
forcestring- Set to 1 to regenerate even when an explanation is cached.only the exact value "1" forces
Errors
- 400
AI assistant is disabled. Enable it in Settings β Integrations.The assistant is not enabled.- 400
No AI API key configured.No API key is stored.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Error not foundNo log error with this id.- 502
<provider error message>The provider call failed: its own error message, "AI request failed (<status>)", or "AI request timed out." after 45 s.- 502
Daily AI request limit reached (100). Raise it in Settings β Integrations.The daily limit is exceeded β this route maps it to 502, not 429.
- Cached response: { explanation, cached: true, history } (no interactionId, no provider call, no audit). No body is read.
- Every provider request counts toward the daily limit (dailyLimit; 0 = unlimited) per UTC day; the counter is incremented before the check, so refused requests count too.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X POST "https://panel.example.com/api/ai/explain-error/14" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"explanation": "Likely cause: the queue worker cannot reach Redisβ¦",
"cached": false,
"interactionId": 120,
"history": [
{
"id": 120,
"kind": "explain_error",
"createdAt": "2026-11-27T10:00:00.000Z",
"userEmail": "[email protected]",
"provider": "openai",
"model": "gpt-4o-mini",
"durationMs": 4210,
"response": "Likely cause: the queue worker cannot reach Redisβ¦",
"error": null
}
]
}
/api/ai/explain-deploy/{deploymentId}
Get stored deploy diagnoses
Returns the stored AI diagnoses of a deployment (newest first, up to 100) and the latest successful one, without calling the provider.
- Token or session
- Admin
Path parameters
deploymentIdintegerrequired- Deployment id.not validated
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- explanation is null when there is no successful diagnosis. An unknown deployment id returns { explanation: null, history: [] } (no 404).
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/ai/explain-deploy/318" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"explanation": "The build failed because composer could not resolveβ¦",
"history": [
{
"id": 121,
"kind": "explain_deploy",
"createdAt": "2026-11-27T10:00:00.000Z",
"userEmail": "[email protected]",
"provider": "openai",
"model": "gpt-4o-mini",
"durationMs": 4210,
"response": "The build failed because composer could not resolveβ¦",
"error": null
}
]
}
/api/ai/explain-deploy/{deploymentId}
Diagnose a deployment
Asks the AI to diagnose a deployment from the redacted tail of its log (last 6000 chars) plus site, status, branch and commit. Returns the latest stored diagnosis without calling the provider unless force=1.
- Token or session
- Admin
- Audit:
ai.explain_deploy
Path parameters
deploymentIdintegerrequired- Deployment id.not validated
Query parameters
forcestring- Set to 1 to diagnose again even when a diagnosis is stored.only the exact value "1" forces
Errors
- 400
AI assistant is disabled. Enable it in Settings β Integrations.The assistant is not enabled.- 400
No AI API key configured.No API key is stored.- 400
This deployment has no log to analyse.A new diagnosis is needed and the deployment has no log.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
Deployment not foundNo deployment with this id.- 502
<provider error message>The provider call failed: its own error message, "AI request failed (<status>)", or "AI request timed out." after 45 s.- 502
Daily AI request limit reached (100). Raise it in Settings β Integrations.The daily limit is exceeded β this route maps it to 502, not 429.
- Cached response: { explanation, cached: true, interactionId: <id of the stored answer>, history } with no provider call and no audit. The answer is capped at 800 tokens. No body is read.
- Every provider request counts toward the daily limit (dailyLimit; 0 = unlimited) per UTC day; the counter is incremented before the check, so refused requests count too.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X POST "https://panel.example.com/api/ai/explain-deploy/318" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"explanation": "The build failed because composer could not resolveβ¦",
"cached": false,
"interactionId": 121,
"history": [
{
"id": 121,
"kind": "explain_deploy",
"createdAt": "2026-11-27T10:00:00.000Z",
"userEmail": "[email protected]",
"provider": "openai",
"model": "gpt-4o-mini",
"durationMs": 4210,
"response": "The build failed because composer could not resolveβ¦",
"error": null
}
]
}
/api/ai/history
List AI history
Lists everything the AI was asked across the panel, by any user, newest first, with cursor pagination. Each item carries a short title and a preview of the answer.
- Token or session
- Admin
Query parameters
kindstring- Only this kind of interaction.one of: chat, explain_error, explain_deploy, test
siteIdinteger- Only interactions about this site.digits only; other values are ignored
qstring- Text search in title, prompt, response, site domain and error.trimmed, first 200 chars used
logErrorIdinteger- Only explanations of this log error.digits only; other values are ignored
deploymentIdinteger- Only diagnoses of this deployment.digits only; other values are ignored
cursorinteger- nextCursor from the previous page: returns entries with an id lower than this.digits only; other values are ignored
limitinteger- Page size.default 30, min 1, max 100 (clamped)
Errors
- 400
Unknown history kindkind is not one of chat, explain_error, explain_deploy, test.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.
- nextCursor is the id of the last item when more entries exist, otherwise null. Pass it as cursor to get the next page.
- preview is the first 220 chars of the response (null when the call failed; then failed is true); error is also truncated to 220 chars; title falls back to the first 120 chars of the question/prompt.
- All admins see every user's entries. Only the newest ~5000 interactions are retained. The first call per process also backfills explanations created before the history existed.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/ai/history" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"items": [
{
"id": 512,
"kind": "chat",
"createdAt": "2026-11-27T10:00:00.000Z",
"userEmail": "[email protected]",
"siteId": 7,
"siteDomain": "shop.example.com",
"logErrorId": null,
"deploymentId": null,
"conversationId": 31,
"title": "Why is the queue on shop.example.com backing up?",
"preview": "Check whether the queue worker is runningβ¦",
"failed": false,
"error": null,
"provider": "openai",
"model": "gpt-4o-mini",
"durationMs": 3920
}
],
"nextCursor": 512
}
/api/ai/history/{id}
Get an AI history entry
Returns one stored AI interaction in full (prompt as sent, response or error), plus whether the site, error, deployment and conversation it refers to still exist.
- Token or session
- Admin
Path parameters
idintegerrequired- Interaction id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 404
History entry not foundNo interaction with this id.
- conversationOpenable is true only when the conversation still exists and belongs to the caller. prompt is stored already redacted.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl "https://panel.example.com/api/ai/history/14" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"id": 512,
"kind": "chat",
"createdAt": "2026-11-27T10:00:00.000Z",
"userEmail": "[email protected]",
"siteId": 7,
"siteDomain": "shop.example.com",
"logErrorId": null,
"deploymentId": null,
"conversationId": 31,
"title": "Why is the queue on shop.example.com backing up?",
"prompt": "CONTEXT β site shop.example.com (PHP 8.3), status active. β¦\n\nQuestion: Why is the queue on shop.example.com backing up?",
"response": "Check whether the queue worker is runningβ¦",
"error": null,
"provider": "openai",
"model": "gpt-4o-mini",
"durationMs": 3920,
"siteExists": true,
"errorExists": false,
"deploymentExists": false,
"conversationTitle": "Why is the queue on shop.example.com backing up?",
"conversationOpenable": true
}
/api/ai/history/{id}
Delete an AI history entry
Permanently deletes one stored AI interaction. Chat entries can only be deleted by the user who asked. Deleting the explanation currently cached on a log error replaces that cache with the newest remaining explanation (or clears it).
- Token or session
- Admin
- Audit:
ai.history_deleted
Path parameters
idintegerrequired- Interaction id.not validated (Number(...) of the path segment)
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleYour role may not call this endpoint.- 403
Only the person who asked can delete a chat entry.The entry is a chat turn of another user.- 404
History entry not foundNo interaction with this id.
- All /api/ai routes are admin-only (file-level preHandler hooks: authenticate + requireRole(['admin'])).
curl -X DELETE "https://panel.example.com/api/ai/history/14" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true
}
Telegram
Telegram bot connection and account linking.
/api/telegram/webhook/{secret}
Receive Telegram bot updates
Webhook called by Telegram's Bot API with bot updates (messages and button presses). The secret in the path is the credential. The update is acknowledged immediately and processed in the background by the panel's Telegram bot.
- Secret in URL
Path parameters
secretstringrequired- Webhook secret generated by POST /api/telegram/setup.48 hex chars
Headers
X-Telegram-Bot-Api-Secret-Tokenstring- Secret token Telegram sends with each update. If present it must equal the webhook secret.
Body
messageobject- Telegram Update.message; handled when it has text (commands such as /start <link code>).not validated
callback_queryobject- Telegram Update.callback_query (inline keyboard button press).not validated
Errors
- 404
No webhook secret is configured, the path secret is wrong, or the header token is present and does not match. The body is empty.
- Intended for Telegram only; it is not meant to be called by API clients.
- Processing errors are never reported to the caller. Updates are ignored when no bot token is configured; other update types are ignored.
- Sending /start <code> to the bot with a code from POST /api/telegram/link-code links the Telegram account to the panel user.
curl -X POST "https://panel.example.com/api/telegram/webhook/value" \
-H "Content-Type: application/json" \
-d '{
"update_id": 100000001,
"message": {
"message_id": 7,
"from": {
"id": 555000111,
"username": "ada_example"
},
"chat": {
"id": 555000111,
"type": "private"
},
"date": 1795773600,
"text": "/start 1a2b3c4d"
}
}'{
"ok": true
}
/api/telegram/me
Get Telegram link status
Returns whether the caller's Telegram account is linked, and whether the panel's Telegram bot and webhook are configured.
- Token or session
- Any role
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.
- When a bot token is set, the handler calls Telegram's getMe to read botUsername; it is an empty string when that call fails or no token is set.
- webhookConfigured only means a webhook secret has been generated; it stays true after POST /api/telegram/remove-webhook.
curl "https://panel.example.com/api/telegram/me" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"linked": true,
"username": "ada_example",
"linkedAt": "2026-11-27T10:00:00.000Z",
"botConfigured": true,
"botUsername": "orchestrator_example_bot",
"webhookConfigured": true
}
/api/telegram/link-code
Create a Telegram link code
Issues a one-time code, valid for 10 minutes, that links the caller's panel account to a Telegram account. Open the deep link (or send /start <code> to the bot) in Telegram to complete linking.
- Token or session
- Any role
Errors
- 400
Configure the Telegram bot token in Settings β Notifications first.No Telegram bot token is configured.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.
- The code is 8 hex characters. Requesting a new code replaces the previous one.
- deepLink is null (and botUsername empty) when Telegram's getMe call fails.
- Linking needs the webhook to be set up (POST /api/telegram/setup) so the bot receives the /start message.
curl -X POST "https://panel.example.com/api/telegram/link-code" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"code": "1a2b3c4d",
"botUsername": "orchestrator_example_bot",
"deepLink": "https://t.me/orchestrator_example_bot?start=1a2b3c4d",
"expiresAt": "2026-11-27T10:10:00.000Z"
}
/api/telegram/unlink
Unlink your Telegram account
Detaches the caller's Telegram account and clears any pending link code.
- Token or session
- Any role
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.
- Always returns {"ok": true}, also when nothing was linked.
curl -X POST "https://panel.example.com/api/telegram/unlink" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true
}
/api/telegram/setup
Register the Telegram webhook
Registers the panel's webhook URL with Telegram so the bot receives messages. Generates the webhook secret on first use and reuses it afterwards. Admin only.
- Token or session
- Admin
- Audit:
telegram.webhook_set
Errors
- 400
Set the Panel URL in Settings β General first (needed for the webhook URL).The panel_url setting is empty.- 400
Set the Telegram bot token in Settings β Notifications first.No Telegram bot token is configured.- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleThe caller is not an admin.
- ok is always true; check result.ok for Telegram's verdict. result is null when Telegram could not be reached.
- The webhook is registered for message and callback_query updates only.
- The returned url contains the webhook secret, and the same url is stored in the audit entry's meta.
curl -X POST "https://panel.example.com/api/telegram/setup" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true,
"url": "https://panel.example.com/api/telegram/webhook/3f1c0000000000000000000000000000000000000000a9e2",
"result": {
"ok": true,
"result": true,
"description": "Webhook was set"
}
}
/api/telegram/remove-webhook
Remove the Telegram webhook
Asks Telegram to stop sending updates to the panel (deleteWebhook). Admin only.
- Token or session
- Admin
- Audit:
telegram.webhook_removed
Errors
- 401
Invalid or expired access tokenThe personal access token is unknown, revoked or expired.- 401
UnauthorizedNo token, or an invalid session.- 403
Forbidden: insufficient roleThe caller is not an admin.
- Returns ok even when no bot token is set or Telegram's answer is an error (the answer is not returned).
- The stored webhook secret is not deleted: the webhook endpoint keeps accepting requests with the old secret, and GET /api/telegram/me still reports webhookConfigured: true.
curl -X POST "https://panel.example.com/api/telegram/remove-webhook" \
-H "Authorization: Bearer $ORCH_TOKEN"{
"ok": true
}