Skip to Content
API ReferenceAgent API

API Reference

All authenticated routes live under /v1 and use database-backed API keys with scoped permissions.

X-API-Key: <your-api-key>

When USE_AUTH=true and the api_keys table is empty on first boot, core bootstraps an admin key from the GREENLIGHT_API_KEY environment variable. Create replacement keys via POST /v1/keys/new and revoke the bootstrap key.

Path verbs

VerbPathsMeaning
newPOST /v1/channels/new, POST /v1/prompts/new, POST /v1/keys/newCreate a durable resource
sendPOST /v1/messages/sendDeliver chat text on a MESSAGE channel

Scopes

Middleware checks any-of required scopes per route. The admin scope grants all permissions.

ScopeRoutes
status:readGET /v1/status
settings:readGET /v1/settings
settings:writePATCH /v1/settings
keys:readGET /v1/keys, GET /v1/keys/{id}
keys:writePOST /v1/keys/new, DELETE /v1/keys/{id}
channels:readGET /v1/channels
channels:writePOST /v1/channels/new, PATCH/DELETE /v1/channels/{id}
prompts:readGET /v1/prompts, GET /v1/prompts/{id}
prompts:writePOST /v1/prompts/new
messages:readGET /v1/messages, GET /v1/messages/{id}
messages:sendPOST /v1/messages/send
adminAll of the above

Presets (for POST /v1/keys/new):

  • admin['admin']
  • agent → channels, prompts, messages read+write (no settings/keys/status)
  • readonly → all *:read scopes including status:read

Endpoints

MethodPathScope(s)Description
GET/healthzHealth check (no auth)
GET/v1/statusstatus:readOperator status / dashboard
GET/v1/settingssettings:readRetention settings
PATCH/v1/settingssettings:writeUpdate retention settings
GET/v1/keyskeys:readList API keys
GET/v1/keys/{id}keys:readGet API key metadata
POST/v1/keys/newkeys:writeCreate API key (plaintext once)
DELETE/v1/keys/{id}keys:writeRevoke API key
POST/v1/prompts/newprompts:writeCreate a prompt (JSON or multipart)
GET/v1/promptsprompts:readList prompts (state filter)
GET/v1/prompts/{id}prompts:readGet prompt (%23123 for #123)
POST/v1/channels/newchannels:writeCreate a channel
GET/v1/channelschannels:readList channels (filters)
PATCH/v1/channels/{id}channels:writeUpdate a channel
DELETE/v1/channels/{id}channels:writeUnregister channel
GET/v1/messagesmessages:readList message history
GET/v1/messages/{id}messages:readGet message by UUID
POST/v1/messages/sendmessages:sendSend chat text on MESSAGE channel

Platforms: telegram, slack, teams, discord, gchat, whatsapp, messenger.

GET /v1/status

Deep health for operators and the Admin UI dashboard.

Response 200

{ "status": "ok", "database": "ok", "channels_active": 2, "prompts_pending": 1, "prompts_answered_24h": 4, "platforms": { "telegram": 1, "slack": 1 } }

GET /v1/settings / PATCH /v1/settings

Data retention configuration. PATCH body uses the same fields as the GET response (except updated_at is ignored). Days must be 1–3650 when the corresponding toggle is enabled.

POST /v1/keys/new

Request body

FieldTypeRequiredNotes
namestringYesDisplay name
presetstringNoadmin | agent | readonly
scopesstring[]NoCustom scopes (required if preset omitted)

Response 200

API key metadata plus key (plaintext, shown once).

POST /v1/prompts/new

Accepts application/json or multipart/form-data.

JSON body

FieldTypeRequiredNotes
textstringYesMax 4096
channel_idstringConditionalOr use DEFAULT_PROMPT_CHANNEL_ID
optionsstring[]NoMax 10 (3 on WhatsApp/Messenger)
allow_textbooleanNoDefault false
callback_urlstringNoValidated HTTP(S)
correlation_idstringNoMax 255
ttl_secintNoDefault 3600, max 604800
media_urlstringNoMutually exclusive media sources
media_pathstringNoUnder MEDIA_ALLOWED_DIR

Multipart form

Same fields as form parts. Send attachments as file. options may be a JSON string. Do not combine file and media_url.

Response 200

{ "prompt_id": "#123", "channel_id": "my-telegram-prompts", "message_id": 456 }

GET /v1/prompts

Query

ParamTypeDefaultNotes
statestringpendingpending | answered | expired | all
limitint501–200

POST /v1/channels/new

See Channels for the full schema and Platforms for credentials.

Response 201

{ "status": "Channel ops-slack registered." }

GET /v1/channels

Query

ParamTypeDefaultNotes
platformenumFilter by platform
channel_typeenumMESSAGE | PROMPT
limitint501–200

PATCH /v1/channels/{id}

Path id is the channel slug (channel_id from create).

Update target_chat_id, credentials, and/or callback_url. Reactivates a deactivated channel. platform and channel_type cannot be changed.

Response 200

{ "status": "Channel ops-slack updated." }

GET /v1/prompts/{id}

Returns prompt state including answer, timestamps, and options. Encode # as %23.

GET /v1/messages

Query

ParamTypeDefaultNotes
directionstringallinbound | outbound | all
channel_idstringFilter by channel
limitint501–200

Outbound messages include api_key_id when stored.

GET /v1/messages/{id}

Returns a single message record by UUID.

POST /v1/messages/send

Deliver plain chat text on a MESSAGE channel. When retention allows, returns the full stored message record (201). When zero retention is enabled, returns { "status": "sent", "stored": false, ... }.

Request body

FieldTypeRequiredNotes
channel_idstringYesMESSAGE channel
textstringYesMessage body

Common errors

Statusdetail example
400Validation / missing callback_url for MESSAGE
401Invalid or missing API key
403Missing required scope
404Prompt or channel not found
409Channel already exists
500Unexpected server error