API reference
OpenLegion's partner API: put AI agents inside your product. Your server holds an org key and creates a workspace per customer from your templates, connects your tools as connectors, sets each workspace's credit limits, runs its agents and reads their runs, actions and events (or receives them as signed webhooks). This document lists every route the API serves. The API sends no CORS headers: call it from a server, not from a browser page. Two routes, the terminal sign-in's device flow, take no key.
Base URL: https://api.openlegion.ai/platform/v1. API version: 2026-12-01 (send it as OpenLegion-Version, or leave it out for your key's default). Every POST takes an Idempotency-Key header: a retry with the same key answers what the first call did.
Keys
orgKey: An org key, olp_test_… or olp_live_…. Scopes: workspaces:read, workspaces:write, sessions, act_as, messages, approvals, inbound, templates, connectors, usage:read, limits:write, webhooks, data_rights, billing:write, vault, connections.sessionToken: A session token, ols_test_… or ols_live_… (POST /sessions): one of your users in one workspace, for at most an hour. Used by your server, or by a route on your own origin that forwards to the API: the API sends no CORS headers, so a browser page cannot call it directly.
Errors answer { error: { type, code, param, message, doc_url, request_id } }.
Workspaces
GET /workspaces
List workspaces, newest first.
Who: An org key, scope workspaces:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
external_ref | query | string | Exactly this external_ref. | |
status | query | one of: active, suspended, archived | active, suspended or archived. | |
template | query | string | A template slug: workspaces tracking it or pinned to any of its versions. | |
created[gte] | query | string | RFC 3339: created at or after. | |
created[lt] | query | string | RFC 3339: created before. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A ws_ id: the page after it. | |
ending_before | query | string | A ws_ id: the page before it. |
Returns:
200: A list of workspaces.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces
Create a workspace from a template (create-or-get on external_ref).
A real create returns 201. An external_ref that already exists in this org and mode returns 200 with that workspace, unchanged, whatever the body says. Seeds the template's agents and schedules; no assistant, home thread or onboarding.
Who: An org key, scope workspaces:write.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
external_ref | string | yes | Your customer id. Never a login, email or handle. |
name | string | yes | |
template | string | yes | "slug" tracks the promoted version; "slug@N" pins version N. |
time_zone | string | IANA, e.g. "Europe/London". Default UTC. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. | |
limits | object | The workspace's credit caps. Absent: the template version's default_limits. |
Returns:
200: Already existed: returned unchanged.201: Created.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /workspaces/{id}
Read a workspace.
Who: An org key, scope workspaces:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The workspace.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces/{id}
Update name, time_zone, metadata, template (track, or pin a version) or model_keys_allowed.
Changing template re-applies the version it names to the workspace's agents in place: same agents, new spec, from their next run.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ||
time_zone | string | IANA, e.g. "Europe/London". Default UTC. | |
metadata | object | Merged into the stored map; a key set to "" is removed. | |
template | string | "slug" tracks the promoted version; "slug@N" pins version N. | |
limits | any | Refused here: set limits with POST /workspaces/{id}/limits. | |
model_keys_allowed | boolean | Let this workspace's people save their own Anthropic or OpenAI key, and its agents run on it (BYOK). Off keeps a saved key, unused. |
Returns:
200: The workspace.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
DELETE /workspaces/{id}
Erase a workspace: its content is deleted, its float returns to the pool.
Async: 202 now, then workspace.erased once every row and file is gone (usually within minutes). From the 202 on the workspace is a 404, a second DELETE included, and its external_ref is free for a new workspace. Usage and billing records are the org's accounting: they stay, without content. If another write to the workspace hasn't finished after a few short retries (about a second), it answers 409 workspace_busy and nothing is erased: send the same DELETE again. Needs the data_rights scope.
Who: An org key, scope data_rights.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
202: Erasing.400:401:402:403:404:409:429:
Fields of the 202 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
external_ref | string or null | The external_ref it had. It is free for a new workspace from the moment of the DELETE. |
status | "deleted" | |
deleted | true | |
created | string or null | |
erased_at | string or null | When the erase finished: null in the DELETE's answer, set in workspace.erased. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces/{id}/suspend
Suspend a workspace (the kill switch).
A run that has started stops at its next step; schedules stop firing. Idempotent. Writes workspace.suspended with reason partner.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The workspace.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces/{id}/resume
Resume a workspace you suspended.
Lifts a partner suspension. A suspension OpenLegion made stays (refusal workspace_suspended); an archived workspace needs restore (refusal workspace_archived). Idempotent.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The workspace.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces/{id}/archive
Archive a workspace.
Stops schedules and runs and keeps the data until restore. Idempotent. Writes workspace.archived.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The workspace.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces/{id}/restore
Restore an archived workspace.
Brings an archived workspace back. Idempotent. Writes workspace.restored.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The workspace.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces/{id}/limits
Set a workspace's credit caps and period anchor (replaces them).
Within the org plan's ceiling, else refusal entitlement_denied. A hard period_credit_cap above 0 but below usage_period.run_credits_required, or a daily_credit_cap below it, would refuse every run, so it is parameter_invalid. A raised period_credit_cap takes effect on the next run; a new period_anchor at the next renewal, or now with period_restart: true, which starts a customer's month on the day they buy. Usage thresholds above the new usage ratio re-arm.
Who: An org key, scope limits:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
period_credit_cap | integer or null | yes | Credits per period. null takes the plan's ceiling (there is no unlimited). |
daily_credit_cap | integer or null | Credits per UTC day. null or absent: no daily cap below the plan's ceiling. | |
cap_mode | one of: hard, soft | hard (default) refuses at the cap; soft allows soft_overage_pct more and reports it as overage. | |
soft_overage_pct | integer | Soft caps only, within the plan's maximum. | |
period_anchor | string | RFC 3339. The period renews monthly from it; short months clamp to their last day. Default: the workspace's creation time. | |
period_restart | boolean | true: put the workspace's month on period_anchor's monthly cycle now, instead of at the next renewal. Start a customer's month on the day they buy: send the subscription's billing anchor with period_restart: true on every sync. The month starts there if it has not (the current period ends at the cycle's latest start and closes as at any renewal: its unused float goes back to the org pool, and a run in flight settles into the new month); if the workspace is already on that cycle, nothing changes. Either way the current period then ends where the anchor's cycle ends. period_anchor is required, kept to the whole second, and may not be after now. |
Returns:
200: The workspace, with its new limits and a fresh usage_period.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "workspace" | |
id | string | ws_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
external_ref | string | Your customer id: unique per org and mode. |
name | string | |
status | one of: active, suspended, archived | |
template | string or null | "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version this workspace's agents run now. |
time_zone | string | IANA. Template schedules run in it. |
active_runs | integer | |
limits | object or null | |
usage_period | object or null | |
model_keys_allowed | boolean | A person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /workspaces/{id}/credit_grants
List a workspace's credit grants, newest first.
Who: An org key, scope usage:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
limit | query | integer | 1–100, default 20. |
Returns:
200: A list of credit grants.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "credit_grant" | |
id | string | cgr_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
workspace | string | ws_… |
credits | integer | |
credits_remaining | integer | What is left now, after this period's live overage (rounded down). |
credits_remaining_micro | integer | |
expires_at | string or null | |
status | one of: active, expired, returned | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces/{id}/credit_grants
Grant a workspace one-off credits from the org pool.
Spent after the period allowance, oldest expiry first; what is left returns to the pool on expiry or archive. The cap is not changed. Refusal credits_exhausted when the pool cannot cover it.
Who: An org key, scope limits:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
credits | integer | yes | Credits to move from the org pool into the workspace. |
expires_at | string | RFC 3339. What is left then returns to the pool. Absent: never expires. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Returns:
201: The grant.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "credit_grant" | |
id | string | cgr_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
workspace | string | ws_… |
credits | integer | |
credits_remaining | integer | What is left now, after this period's live overage (rounded down). |
credits_remaining_micro | integer | |
expires_at | string or null | |
status | one of: active, expired, returned | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /workspaces/{id}/exports
List a workspace's exports, newest first, each ready one with a fresh link.
Who: An org key, scope data_rights.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
limit | query | integer | 1–100, default 20. |
Returns:
200: A list of exports.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "export" | |
id | string | exp_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
workspace | string | ws_… |
status | one of: pending, building, ready, failed, expired | |
include_audit_log | boolean | Whether the file holds the workspace's activity log: what you asked for, and once ready, whether the workspace's plan includes audit-log export. |
size_bytes | integer or null | The file's size in bytes, once ready. |
url | string or null | A download link, valid for an hour, minted when you read a ready export. Never in an event. |
url_expires_at | string or null | |
expires_at | string or null | When the file is deleted (7 days after it was ready). |
failure_code | one of: export_too_large, export_timeout, export_failed or null | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /workspaces/{id}/exports
Export a workspace's data.
Async: 201 now, then export.ready (or export.failed) when the file is built, usually within minutes. One export is in flight per workspace: while one is queued or building, this answers it with 200. Read the export to get its download link. Needs the data_rights scope.
Who: An org key, scope data_rights.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
include_audit_log | boolean | Include the activity log (default true). Plans without audit-log export leave it out, and the file's manifest says so. |
Returns:
200: An export already in flight.201: Queued.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "export" | |
id | string | exp_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
workspace | string | ws_… |
status | one of: pending, building, ready, failed, expired | |
include_audit_log | boolean | Whether the file holds the workspace's activity log: what you asked for, and once ready, whether the workspace's plan includes audit-log export. |
size_bytes | integer or null | The file's size in bytes, once ready. |
url | string or null | A download link, valid for an hour, minted when you read a ready export. Never in an event. |
url_expires_at | string or null | |
expires_at | string or null | When the file is deleted (7 days after it was ready). |
failure_code | one of: export_too_large, export_timeout, export_failed or null | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /workspaces/{id}/exports/{export_id}
Retrieve an export, with a fresh download link when it is ready.
Who: An org key, scope data_rights.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
export_id | path | string | yes |
Returns:
200: The export.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "export" | |
id | string | exp_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
workspace | string | ws_… |
status | one of: pending, building, ready, failed, expired | |
include_audit_log | boolean | Whether the file holds the workspace's activity log: what you asked for, and once ready, whether the workspace's plan includes audit-log export. |
size_bytes | integer or null | The file's size in bytes, once ready. |
url | string or null | A download link, valid for an hour, minted when you read a ready export. Never in an event. |
url_expires_at | string or null | |
expires_at | string or null | When the file is deleted (7 days after it was ready). |
failure_code | one of: export_too_large, export_timeout, export_failed or null | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Templates
GET /templates
List templates, newest first.
Who: An org key, scope templates.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A template slug: the page after it. | |
ending_before | query | string | A template slug: the page before it. |
Returns:
200: A list of templates.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "template" | |
id | string | The template's slug: templates are addressed by it. |
livemode | boolean | |
created | string | RFC 3339 UTC. |
slug | string | |
name | string | |
promoted_version | integer or null | What a tracking workspace runs. |
latest_version | integer or null | |
builtin | boolean | true for starter, which OpenLegion seeds into every org. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /templates
Create a template (a product line).
Who: An org key, scope templates.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
slug | string | yes | Your handle for the product line, e.g. social-manager. |
name | string | yes |
Returns:
201: The template.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "template" | |
id | string | The template's slug: templates are addressed by it. |
livemode | boolean | |
created | string | RFC 3339 UTC. |
slug | string | |
name | string | |
promoted_version | integer or null | What a tracking workspace runs. |
latest_version | integer or null | |
builtin | boolean | true for starter, which OpenLegion seeds into every org. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /templates/{slug}/versions
List a template's versions, newest first.
Who: An org key, scope templates.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
slug | path | string | yes | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A tplv_ id: the page after it. | |
ending_before | query | string | A tplv_ id: the page before it. |
Returns:
200: A list of versions.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "template_version" | |
id | string | tplv_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
template | string | The template's slug. |
version | integer | |
spec | object | The spec as stored (see /platform/v1/schemas/template.json). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /templates/{slug}/versions
Publish an immutable template version.
The body is the spec. Its JSON Schema is published at /platform/v1/schemas/template.json. The first version of a template is promoted automatically.
Who: An org key, scope templates.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
slug | path | string | yes |
Body (JSON):
A TemplateSpec.
Returns:
201: The new version.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "template_version" | |
id | string | tplv_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
template | string | The template's slug. |
version | integer | |
spec | object | The spec as stored (see /platform/v1/schemas/template.json). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /templates/{slug}/versions/{version}
Read one template version.
Who: An org key, scope templates.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
slug | path | string | yes | |
version | path | string | yes |
Returns:
200: The version.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "template_version" | |
id | string | tplv_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
template | string | The template's slug. |
version | integer | |
spec | object | The spec as stored (see /platform/v1/schemas/template.json). |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /templates/{slug}/promote
Promote a version: every tracking workspace runs it from its next run.
Re-applies the version to every workspace whose template is the bare slug, in one transaction. Pinned workspaces do not move. Rolling back is promoting an older version. Writes a template.promoted event. v0 refuses a promote that would move more than 500 workspaces. A version that removes a template agent which agents made with POST /agents still follow is refused (409 template_agent_in_use, naming the workspaces) and nothing moves.
Who: An org key, scope templates.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
slug | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
version | integer | yes |
Returns:
200: The template, now promoted.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "template" | |
id | string | The template's slug: templates are addressed by it. |
livemode | boolean | |
created | string | RFC 3339 UTC. |
slug | string | |
name | string | |
promoted_version | integer or null | What a tracking workspace runs. |
latest_version | integer or null | |
builtin | boolean | true for starter, which OpenLegion seeds into every org. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
workspaces_moved | integer |
Connectors
GET /connectors
List connectors, newest first.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A connector id: the page after it. |
Returns:
200: A list of connectors.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "connector" | |
id | string | con_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
name | string | |
slug | string | |
url | string or null | Your MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this connector now, or null. |
auth | object | |
header_names | array of string | Static extra headers. Names only; values are never returned. |
status | one of: active, disabled | |
pinned_at | string or null | Null until the first pin. |
last_test | object or null | |
tools | array of object | |
metadata | object |
POST /connectors
Register your MCP server: returns the connector secret once.
Lists your server's tools signed with the new secret before anything is saved. A server that checks signatures cannot know the secret yet, so the connector is usually created unpinned, with pin_error saying why: install the secret, then POST /connectors/{id}/pin.
Who: An org key, scope connectors.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
type | "mcp" | yes | v1.0: an MCP server. |
url | string | Your MCP endpoint. https in test mode too. Required unless transport is dev, which takes none. | |
transport | one of: https, dev | https (the default): OpenLegion calls url. dev, test mode only: reached through your dev session (npx openlegion dev), with no url and no headers. | |
auth | object | yes | v1.0: ol_signed. |
name | string | yes | |
slug | string | Names the tools: mcp... ^[a-z][a-z0-9]{1,15}$. Derived from name when left out. | |
headers | object | Static extra headers, e.g. x-vercel-protection-bypass. At most 8. |
Returns:
201: Created.secretis shown this once.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "connector" | |
id | string | con_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
name | string | |
slug | string | |
url | string or null | Your MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this connector now, or null. |
auth | object | |
header_names | array of string | Static extra headers. Names only; values are never returned. |
status | one of: active, disabled | |
pinned_at | string or null | Null until the first pin. |
last_test | object or null | |
tools | array of object | |
metadata | object | |
secret | string or null | olcs_test_… or olcs_live_…, shown this once. null on an idempotent replay: the secret is not stored outside the broker, so mint a new one with rotate_secret if this response was lost. |
pin_error | object or null |
GET /connectors/{id}
Retrieve a connector and its pinned tools.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The connector.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connector" | |
id | string | con_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
name | string | |
slug | string | |
url | string or null | Your MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this connector now, or null. |
auth | object | |
header_names | array of string | Static extra headers. Names only; values are never returned. |
status | one of: active, disabled | |
pinned_at | string or null | Null until the first pin. |
last_test | object or null | |
tools | array of object | |
metadata | object |
POST /connectors/{id}/pin
Re-read your server's tools and pin them (run it from CI after a deploy).
Lists your server's tools and diffs them against the pins. With dry_run nothing changes. Without it the new pins replace the old in one step: every tool active again, every drift flag cleared, new tools pinned, removed tools gone.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
dry_run | boolean | Return the diff and change nothing. |
Returns:
200: The connector, the diff, and whether it was applied.400:401:402:403:404:409:422:429:502: api_error connector_unreachable: your server could not be reached or did not answer the list. (A refused signature is a 400 connector_auth_rejected.)
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connector" | |
id | string | con_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
name | string | |
slug | string | |
url | string or null | Your MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this connector now, or null. |
auth | object | |
header_names | array of string | Static extra headers. Names only; values are never returned. |
status | one of: active, disabled | |
pinned_at | string or null | Null until the first pin. |
last_test | object or null | |
tools | array of object | |
metadata | object | |
diff | object | |
applied | boolean |
POST /connectors/{id}/test
Test connection: a signed list, then one mis-signed call that must get 401.
The verdict is data: a failing test is still a 200, with ok: false. The result is kept on the connector as last_test.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The test result.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connector_test" | |
connector | string | con_… |
ok | boolean | The signed list worked AND the mis-signed one was refused with 401. |
at | string | RFC 3339 UTC. |
signed_list | object | {ok, tools[{name, digest, change, pinnable}], removed, matches_pins}, or {ok: false, code, status}. |
unsigned_rejected | boolean | |
unsigned_status | integer or null | What the mis-signed request got: 401 passes. |
POST /connectors/{id}/rotate_secret
Mint a new connector secret: returned once; the previous one keeps verifying for a while.
At most two secrets are live; while both are, every request carries a v1= signature for each.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
expires_in_seconds | integer | How long the previous secret keeps verifying, in seconds: 0–259,200 (72 hours), default 86,400. |
Returns:
200: The connector, the new secret (shown this once) and when the previous one stops verifying.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connector" | |
id | string | con_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
name | string | |
slug | string | |
url | string or null | Your MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this connector now, or null. |
auth | object | |
header_names | array of string | Static extra headers. Names only; values are never returned. |
status | one of: active, disabled | |
pinned_at | string or null | Null until the first pin. |
last_test | object or null | |
tools | array of object | |
metadata | object | |
secret | string or null | olcs_test_… or olcs_live_…, shown this once. null on an idempotent replay: the secret is not stored outside the broker, so mint a new one with rotate_secret if this response was lost. |
previous_secret_expires_at | string | RFC 3339 UTC. |
GET /connectors/{id}/calls
The last 7 days of calls through this connector, across the org's workspaces in this mode.
Tool, action, workspace, external_ref, status, refusal code and latency. Arguments and results are never returned.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An action id (act_…): the page after it. |
Returns:
200: A list of calls, newest first.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "connector_call" | |
id | string | act_…: the action's id. One call is one action: GET /actions/{id} in its workspace reads the same call. |
tool | string | |
workspace | string | ws_… |
external_ref | string or null | |
run | string or null | run_…: the run that made the call. |
status | one of: requires_approval, approved, executing, completed, failed, rejected, expired | The action's status, as GET /actions/{id} reads it: a tool that answered with an error is failed. |
outcome | one of: succeeded, failed, refused, unknown or null | succeeded, failed, refused or unknown, as on the action. Null while it is open. |
error | object or null | Why it failed, was refused or has an unknown outcome, as on the action (message is the end user's sentence; partner_message is yours). |
refusal_code | string or null | Why OpenLegion refused the call before or instead of reaching your server, a tool-level code (the list may grow): policy_denied, approval_required, insufficient_credits, admission_refused, tainted_argument, unsafe_url, unknown_tool, invalid_args, deadline, credential_missing, credential_not_allowed, not_configured, not_available, provider_error. Null when it was not refused. |
tool_refusal_code | string or null | Your tool's own refusal code: the code in refuse(message, code), when the call ran and your tool refused it. Null otherwise. |
latency_ms | integer or null | |
created | string | RFC 3339 UTC. |
POST /connectors/{id}/pull_template
Read your app's template definition through this connector, with OpenLegion's own signed call.
OpenLegion POSTs {connector: {id, slug}}, ol_signed, to {basePath}/template beside the connector's {basePath}/mcp URL (same origin; never a redirect; 15 s; 1 MiB), and checks the answer. Nothing is written: publish the version with POST /templates/{slug}/versions. A dev connector's template is read by npx openlegion dev.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The template definition, checked.400:401:402:403:404:409:422:429:502: api_error connector_unreachable: your server could not be reached, or did not answer in time.
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "template_definition" | |
connector | string | con_…: the connector it was pulled through. |
slug | string | The template's slug: where npx openlegion templates push publishes it. |
name | string | |
version | object | The template version, ready for POST /templates/{slug}/versions: the kit's template.toTemplateSpec for this connector. |
tools | array of object | Per tool, sha256 of what the model reads (title and description) and of its input schema. |
hash | string | sha256 of version as canonical JSON: a different hash is a different template version. |
Balance
GET /balance
The org's credit pool in this mode.
Who: An org key, scope usage:read.
Returns:
200: The balance.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "balance" | |
livemode | boolean | |
available | integer | Credits that can be spent now (rounded down): the pool, less any bank payment still held. In test mode, plus what the billing account's monthly test allowance still holds: it is drawn on demand and shared by the account's orgs. A run spends from its workspace's float, not from the pool, so this falls when credits move into a workspace (a refill of up to 10 runs' holds, or a grant), not as runs spend, and rises when a float comes back. |
available_micro | integer | |
pending | integer | Credits on their way: top-ups opened and not yet paid, and bank (ACH) payments received but held until they become spendable. |
pending_micro | integer | |
in_workspaces | integer | Float out in this mode's workspaces: what moved in and is not spent yet. Informative: what is unspent comes back when the workspace's period ends, when it has started no run for 8 days, when it is archived, and at once when another workspace needs them and this one has started no run for 15 minutes, before a run is refused, an auto-reload is charged, or a grace buffer lends (only on an account OpenLegion has given one). Open holds and unspent grants stay with their workspace. |
in_workspaces_micro | integer | |
credit_limit | integer | Live mode: a grace buffer OpenLegion has set for the billing account, shared by its orgs (rounded down). 0 unless OpenLegion sets one for the account: a verified card gives none. Also 0 in test mode, while live charges are off, or until a card on the account is verified. Above 0, a refill the pool cannot cover borrows from it, and the next top-up or auto-reload pays it back first. |
owed | integer | Credits this org's pool has borrowed from a grace buffer OpenLegion set for the account and not yet paid back (rounded up). 0 without one. Not part of available. |
owed_micro | integer | |
currency | "credits" | |
topups_blocked | boolean | A refund or dispute the pool could not cover paused top-ups; OpenLegion support lifts it. |
Balance transactions
GET /balance_transactions
The pool's ledger postings, newest first.
Who: An org key, scope usage:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A txn_ id: the page after it. | |
ending_before | query | string | A txn_ id: the page before it. |
Returns:
200: A list of balance transactions.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "balance_transaction" | |
id | string | txn_… |
type | one of: topup, reload, refill, return, grant, grant_return, test_allowance, refund, fee, repayment, adjustment | reload: an auto-reload's charge, credited. repayment: a grace buffer's loan paid back from the pool (only on an account OpenLegion has given a buffer). fee: a platform fee line, at the monthly close or paid later. |
amount | integer | Credits, signed from the pool's side (a top-up is positive, a refill negative), toward zero. |
amount_micro | integer | |
workspace | string or null | ws_… for a refill, return, grant or fee (the workspace the month's line is for); null for a top-up. |
created | string | RFC 3339 UTC. |
description | string |
Usage
GET /usage
Usage in a window, grouped by workspace, agent, template or day.
From the ledger, never a rollup. The window is [from, to); the default is the current UTC month. At most 366 days.
Who: An org key, scope usage:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
group_by | query | one of: workspace, agent, template, day | workspace (default), agent, template or day. | |
from | query | string | RFC 3339 or YYYY-MM-DD (UTC). Default: the start of this UTC month. | |
to | query | string | RFC 3339 or YYYY-MM-DD (UTC), exclusive. Default: the start of next UTC month. |
Returns:
200: Usage rows.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string | |
group_by | one of: workspace, agent, template, day | |
from | string | RFC 3339 UTC. |
to | string | RFC 3339 UTC. |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "usage" | |
key | string or null | ws_… · agt_… · a template slug · YYYY-MM-DD (UTC), by group_by. null: spend no agent made. |
credits | integer | Net spend, rounded up. |
cost_micro | integer | |
runs | integer | |
actions_completed | integer | |
approvals | integer | |
refusals | integer | |
overage_credits | integer or null | Soft room used past the cap and grants. Workspace grouping only; null otherwise. |
run_credits_required | integer or null | The most one run of this workspace or agent may hold up front NOW (not over the window), as usage_period.run_credits_required. Workspace and agent grouping only; null otherwise, and for an agent that is archived or gone. |
Billing
GET /billing/preview
The org's bill for a month: active workspaces, their ranks, the run line.
Open month: computed now, the same way the month-end close computes it. Closed month: the frozen statement. Every amount is an estimate and null while amounts_hidden is true. Test mode is never charged.
Who: An org key, scope usage:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
month | query | string | YYYY-MM (UTC). Default: this month. |
Returns:
200: The bill preview.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "billing_preview" | |
livemode | boolean | |
month | string | YYYY-MM (UTC). |
status | one of: open, closed | open: computed now from this month's runs. closed: the frozen statement. |
computed_at | string | |
billing_account | string | bac_… |
amounts_hidden | boolean | true: every amount is null (prices are not published yet); counts and ranks are real. |
currency | "credits" | |
live_charges | boolean | Live mode: false means nothing is charged for this month, ever. Test mode never charges. |
explanation | string | |
pricing | object | |
account | object | |
active_workspaces | integer | |
free_workspaces | integer | |
paying_workspaces | integer | |
suspended_active_workspaces | integer | Active this month and suspended now: a suspended workspace stays on the month it ran in. |
runs | integer | |
overage_runs | integer | |
fee | integer or null | Credits (rounded up) for the active-workspace fee. |
fee_micro | integer or null | |
run_charge | integer or null | Credits (rounded up) for runs past the included number. |
run_charge_micro | integer or null | |
total | integer or null | |
total_micro | integer or null | |
projected | object or null | Open month: the same workspaces, their runs at the month-to-date rate. Null once closed. |
posted | integer or null | Closed: what the pool paid. |
posted_micro | integer or null | |
uncovered | integer or null | Closed: what the pool could not cover. |
uncovered_micro | integer or null | |
statement_status | one of: pending, posted, unpaid, waived, not_charged, nothing_due or null | |
workspaces_url | string |
GET /billing/preview/workspaces
The bill's workspaces by rank, each with why it counts.
Who: An org key, scope usage:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
month | query | string | YYYY-MM (UTC). Default: this month. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A ws_ id: the lines ranked after it. |
Returns:
200: The bill's lines, by rank.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string | |
month | string | |
status | one of: open, closed | |
amounts_hidden | boolean |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "billing_preview_line" | |
workspace | string | ws_… |
external_ref | string or null | |
workspace_status | string | |
rank | integer | |
band | one of: free, standard, volume, enterprise | |
why | string | |
first_run | object | |
runs | integer | |
runs_by_trigger | object | Runs this month by what started them, in a run's trigger values. |
included_runs | integer | |
overage_runs | integer | |
fee | integer or null | Credits (rounded up) for the active-workspace fee. |
fee_micro | integer or null | |
run_charge | integer or null | Credits (rounded up) for runs past the included number. |
run_charge_micro | integer or null | |
total | integer or null | |
total_micro | integer or null | |
projected_run_charge_micro | integer or null | |
status | one of: open, pending, posted, unpaid, waived, not_charged, nothing_due |
GET /billing/account
The org's billing account: who shares the free ranks and the test allowance.
How many organizations share it, never which. OpenLegion links organizations to one account; a partner cannot.
Who: An org key, scope usage:read.
Returns:
200: The billing account.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "billing_account" | |
id | string | bac_… |
organization_count | integer | How many organizations share it. Never which. |
business_verified | boolean | |
card_verified | boolean | A live card top-up on one of the account's orgs passed 3-D Secure. Until then a top-up asks for 3-D Secure every time. Verification gives no grace buffer: an account has one only if OpenLegion sets it. |
good_standing_since | string or null | RFC 3339: when the account's current run of good standing began — its card verification, reset by a failed auto-reload, a refund taken back or a debt older than 14 days. Null: not verified (a dispute clears it). |
credit | object | A grace buffer, only on an account OpenLegion has given one (none by default, and none for a verified card): a refill a pool cannot cover borrows from it, and the next top-up or auto-reload pays it back first. This org's own debt is owed on GET /balance. |
test_allowance | object | |
created | string |
GET /billing/auto_reload
The org's auto-reload setting (live mode).
Who: An org key, scope usage:read.
Returns:
200: The setting.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "auto_reload" | |
livemode | true | |
enabled | boolean | On: a saved card the admin consented to, and a reload is sent when the live pool falls below low_balance. |
amount | integer | Credits a reload buys, in whole cents (a multiple of 10), within the platform's bounds for a reload. |
amount_micro | integer | |
low_balance | integer | The live pool's low-balance line (the same one org.credits.low uses). |
low_balance_micro | integer | |
card | object or null | The saved card: never its id or fingerprint. Saved and removed in the org console only. |
consented_at | string or null | RFC 3339: when the card was saved, from an admin's card top-up that chose auto-reload. |
last_reload | object or null | |
live_charges | boolean | false: live billing isn't open, and nothing is charged. |
POST /billing/auto_reload
Turn auto-reload on or off and set its amount (live mode; replaces both).
Needs the opt-in billing:write scope. Turning it on needs a card an admin saved, with consent, on a live card top-up in the org console; a key can never save a card or record a consent. Card only: a bank-debit top-up stays manual.
Who: An org key, scope billing:write.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
enabled | boolean | yes | true needs a card saved with an admin's consent; else 409 no_saved_card. |
amount | integer | yes | Credits a reload buys: a multiple of 10 (whole cents), within the platform's bounds for a reload. Outside them it is 400 parameter_invalid, and the message says the bounds. |
Returns:
200: The setting.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "auto_reload" | |
livemode | true | |
enabled | boolean | On: a saved card the admin consented to, and a reload is sent when the live pool falls below low_balance. |
amount | integer | Credits a reload buys, in whole cents (a multiple of 10), within the platform's bounds for a reload. |
amount_micro | integer | |
low_balance | integer | The live pool's low-balance line (the same one org.credits.low uses). |
low_balance_micro | integer | |
card | object or null | The saved card: never its id or fingerprint. Saved and removed in the org console only. |
consented_at | string or null | RFC 3339: when the card was saved, from an admin's card top-up that chose auto-reload. |
last_reload | object or null | |
live_charges | boolean | false: live billing isn't open, and nothing is charged. |
Sessions
POST /sessions
Mint a session token for one of your users in one workspace.
The token acts as that member in that workspace only, for at most an hour, and can do only what this key can: a route that needs a scope this key lacks refuses the token too (insufficient_scope). Call again to refresh. A replay under the same Idempotency-Key answers the same session with token: null, because the token is never stored.
Who: An org key, scope sessions.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
workspace | string | yes | The workspace (ws_…) the session acts in. |
subject | string | yes | Your user's id. Never an email, a login or a handle. |
role | one of: owner, admin, member | yes | The role this user has in the workspace. It is written on every call: the role you last gave it. |
display_name | string or null | The user's name, shown in the workspace's history and audit trail and told to its agents. Send null to forget it; leave it out to keep the current one. | |
ttl_seconds | integer | Lifetime in seconds, 60–3600. Default 3600. |
Returns:
201: The session, with its token.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "session" | |
id | string | |
livemode | boolean | |
created | string | |
expires_at | string | |
workspace | string | |
subject | string | |
role | one of: owner, admin, member | |
token | string or null | Send as Authorization: Bearer ols_…. Shown this once. null on an idempotent replay: only its hash is stored, so mint a new session if this response was lost. |
metadata | object | Always empty: a session takes no metadata. |
Webhook endpoints
GET /webhook_endpoints
List webhook endpoints, newest first.
Every endpoint of this mode, on one page (at most 16).
Who: An org key, scope webhooks.
Returns:
200: A list of webhook endpoints.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "webhook_endpoint" | |
id | string | whe_… |
livemode | boolean | |
created | string | |
url | string or null | Where deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this endpoint now, or null. |
events | array of string | |
description | string or null | |
status | one of: enabled, disabled | |
disabled_reason | one of: failures, blocked, manual or null | failures: every attempt for 3 days failed (at least 20). blocked: the host resolved to a private or reserved address. manual: you disabled it. |
last_success_at | string or null | |
last_failure_at | string or null | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /webhook_endpoints
Add a webhook endpoint: returns its signing secret once.
At most 16 per mode. A test endpoint receives test-mode events only.
Who: An org key, scope webhooks.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
url | string | https only, port 443, a public host. Each delivery re-checks where it resolves. Required unless transport is dev, which takes none. | |
transport | one of: https, dev | https (the default): deliveries POST to url. dev, test mode only: each delivery goes to your dev session (npx openlegion dev), with no url. | |
events | array of string | yes | The types to receive, or ["*"] for all of them. Subscribable: run.completed, run.failed, run.cancelled, action.requires_approval, action.completed, action.failed, approval.requested, approval.decided, approval.expired, message.created, agent.paused, agent.resumed, agent.attention_needed, task.completed, task.failed, task.escalated, schedule.missed, workspace.cap_reached, usage.threshold_reached, org.credits.low, org.credits.exhausted, org.topup.reversed, org.statement.closed, org.billing_account.changed, org.credits.reloaded, org.credits.reload_failed, org.credits.buffer_used, org.topup.failed, connector.drifted, workspace.suspended, workspace.resumed, workspace.archived, workspace.restored, workspace.erased, export.ready, export.failed, template.promoted, connection.created, connection.updated, connection.needs_reauth, connection.revoked, computer.session_ended. |
description | string | ||
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Returns:
201: Created.secretis shown this once.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "webhook_endpoint" | |
id | string | whe_… |
livemode | boolean | |
created | string | |
url | string or null | Where deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this endpoint now, or null. |
events | array of string | |
description | string or null | |
status | one of: enabled, disabled | |
disabled_reason | one of: failures, blocked, manual or null | failures: every attempt for 3 days failed (at least 20). blocked: the host resolved to a private or reserved address. manual: you disabled it. |
last_success_at | string or null | |
last_failure_at | string or null | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
secret | string or null | whsec_…, shown this once: verify OpenLegion-Signature with it. null on an idempotent replay; rotate_secret mints a new one. |
GET /webhook_endpoints/{id}
Retrieve a webhook endpoint.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The endpoint.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "webhook_endpoint" | |
id | string | whe_… |
livemode | boolean | |
created | string | |
url | string or null | Where deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this endpoint now, or null. |
events | array of string | |
description | string or null | |
status | one of: enabled, disabled | |
disabled_reason | one of: failures, blocked, manual or null | failures: every attempt for 3 days failed (at least 20). blocked: the host resolved to a private or reserved address. manual: you disabled it. |
last_success_at | string or null | |
last_failure_at | string or null | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /webhook_endpoints/{id}
Update a webhook endpoint, or disable or re-enable it.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
url | string | ||
events | array of string | The types to receive, or ["*"] for all of them. Subscribable: run.completed, run.failed, run.cancelled, action.requires_approval, action.completed, action.failed, approval.requested, approval.decided, approval.expired, message.created, agent.paused, agent.resumed, agent.attention_needed, task.completed, task.failed, task.escalated, schedule.missed, workspace.cap_reached, usage.threshold_reached, org.credits.low, org.credits.exhausted, org.topup.reversed, org.statement.closed, org.billing_account.changed, org.credits.reloaded, org.credits.reload_failed, org.credits.buffer_used, org.topup.failed, connector.drifted, workspace.suspended, workspace.resumed, workspace.archived, workspace.restored, workspace.erased, export.ready, export.failed, template.promoted, connection.created, connection.updated, connection.needs_reauth, connection.revoked, computer.session_ended. | |
description | string or null | ||
disabled | boolean | true stops deliveries; false re-enables the endpoint and clears its failure count and failing time. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Returns:
200: The endpoint, updated.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "webhook_endpoint" | |
id | string | whe_… |
livemode | boolean | |
created | string | |
url | string or null | Where deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this endpoint now, or null. |
events | array of string | |
description | string or null | |
status | one of: enabled, disabled | |
disabled_reason | one of: failures, blocked, manual or null | failures: every attempt for 3 days failed (at least 20). blocked: the host resolved to a private or reserved address. manual: you disabled it. |
last_success_at | string or null | |
last_failure_at | string or null | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
DELETE /webhook_endpoints/{id}
Delete a webhook endpoint.
From now on it is a 404, receives nothing and no longer counts toward the 16. Its secrets are deleted and deliveries not yet attempted are dropped; what was already sent stays readable until each event's 30-day prune.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: Deleted.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "webhook_endpoint" | |
id | string | |
deleted | true |
POST /webhook_endpoints/{id}/rotate_secret
Rotate a webhook endpoint's signing secret: returns the new one once.
During the overlap every delivery carries one v1= signature per live secret, so you can switch without missing one.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
expires_in_seconds | integer | How long the current secret keeps signing beside the new one. Default 86400; 0 stops it now. |
Returns:
200: The endpoint, and the new secret shown this once.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "webhook_endpoint" | |
id | string | whe_… |
livemode | boolean | |
created | string | |
url | string or null | Where deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev). |
transport | one of: https, dev | https: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev). |
dev_session | string or null | des_…: the dev session holding this endpoint now, or null. |
events | array of string | |
description | string or null | |
status | one of: enabled, disabled | |
disabled_reason | one of: failures, blocked, manual or null | failures: every attempt for 3 days failed (at least 20). blocked: the host resolved to a private or reserved address. manual: you disabled it. |
last_success_at | string or null | |
last_failure_at | string or null | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
secret | string or null | whsec_…, shown this once: verify OpenLegion-Signature with it. null on an idempotent replay; rotate_secret mints a new one. |
previous_secret_expires_at | string |
POST /webhook_endpoints/{id}/test
Send a ping event to this endpoint only.
The ping is listed by GET /events and delivered, signed, like any event. A disabled endpoint is refused: re-enable it first.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The ping event.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "event" | |
id | string | evt_…: one id per event, the same on every endpoint and every retry. Dedupe on it. |
type | one of: run.completed, run.failed, run.cancelled, action.requires_approval, action.completed, action.failed, approval.requested, approval.decided, approval.expired, message.created, agent.paused, agent.resumed, agent.attention_needed, task.completed, task.failed, task.escalated, schedule.missed, workspace.cap_reached, usage.threshold_reached, org.credits.low, org.credits.exhausted, org.topup.reversed, org.statement.closed, org.billing_account.changed, org.credits.reloaded, org.credits.reload_failed, org.credits.buffer_used, org.topup.failed, connector.drifted, workspace.suspended, workspace.resumed, workspace.archived, workspace.restored, workspace.erased, export.ready, export.failed, template.promoted, connection.created, connection.updated, connection.needs_reauth, connection.revoked, computer.session_ended, ping | |
api_version | string | |
created | string | RFC 3339 UTC. |
livemode | boolean | |
workspace | string or null | ws_…, or null for an org-level event. |
external_ref | string or null | Your id for the workspace, as you set it. |
data | object |
GET /webhook_endpoints/{id}/deliveries
List an endpoint's deliveries, newest first, each with its attempts.
Kept as long as the event: 30 days. A disabled endpoint's are listed too; a deleted endpoint is a 404.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
status | query | one of: pending, succeeded, failed, skipped | Only deliveries in this status. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A whd_ id: the page after it. | |
ending_before | query | string | A whd_ id: the page before it. |
Returns:
200: A list of deliveries.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "webhook_delivery" | |
id | string | whd_…: also the OpenLegion-Delivery header your endpoint received. |
endpoint | string | whe_… |
event | string | evt_…: the event delivered, the receiver's dedupe key. |
event_type | string | |
livemode | boolean | |
status | one of: pending, succeeded, failed, skipped | pending: an attempt is due (next_attempt_at). succeeded: a 2xx came back. failed: the retries ran out. skipped: the endpoint was disabled or deleted before an attempt. |
created | string | |
next_attempt_at | string or null | When the next retry is due, after a failed attempt with retries left; null otherwise. |
finished_at | string or null | |
attempts | array of object | Every attempt, oldest first. The response body is never read, so it isn't here. |
POST /webhook_endpoints/{id}/deliveries/{delivery_id}/resend
Send a settled delivery again: one more attempt, now.
For a delivery that succeeded, failed or was skipped. Same event, same bytes, same whd_ id; a new signature. One attempt with no retries behind it. A delivery still being attempted is 409 webhook_delivery_pending; a disabled endpoint is 409 webhook_endpoint_disabled. At most 100 resends per endpoint per minute; past that, 429 rate_limited with Retry-After.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
delivery_id | path | string | yes |
Returns:
200: The delivery, queued for its one more attempt.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "webhook_delivery" | |
id | string | whd_…: also the OpenLegion-Delivery header your endpoint received. |
endpoint | string | whe_… |
event | string | evt_…: the event delivered, the receiver's dedupe key. |
event_type | string | |
livemode | boolean | |
status | one of: pending, succeeded, failed, skipped | pending: an attempt is due (next_attempt_at). succeeded: a 2xx came back. failed: the retries ran out. skipped: the endpoint was disabled or deleted before an attempt. |
created | string | |
next_attempt_at | string or null | When the next retry is due, after a failed attempt with retries left; null otherwise. |
finished_at | string or null | |
attempts | array of object | Every attempt, oldest first. The response body is never read, so it isn't here. |
Events
GET /events
List events of the last 30 days, newest first.
A page can miss an event that commits late with an earlier created time, as with any list: reconcile with overlapping windows and dedupe on evt_. Webhook deliveries never miss one.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
type | query | string | An event type (run.completed), or a family (run.*). | |
workspace | query | string | Only this workspace's events (ws_…). | |
created[gte] | query | string | RFC 3339: created at or after. | |
created[lt] | query | string | RFC 3339: created before. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An evt_ id: the page after it. | |
ending_before | query | string | An evt_ id: the page before it. |
Returns:
200: A list of events.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "event" | |
id | string | evt_…: one id per event, the same on every endpoint and every retry. Dedupe on it. |
type | one of: run.completed, run.failed, run.cancelled, action.requires_approval, action.completed, action.failed, approval.requested, approval.decided, approval.expired, message.created, agent.paused, agent.resumed, agent.attention_needed, task.completed, task.failed, task.escalated, schedule.missed, workspace.cap_reached, usage.threshold_reached, org.credits.low, org.credits.exhausted, org.topup.reversed, org.statement.closed, org.billing_account.changed, org.credits.reloaded, org.credits.reload_failed, org.credits.buffer_used, org.topup.failed, connector.drifted, workspace.suspended, workspace.resumed, workspace.archived, workspace.restored, workspace.erased, export.ready, export.failed, template.promoted, connection.created, connection.updated, connection.needs_reauth, connection.revoked, computer.session_ended, ping | |
api_version | string | |
created | string | RFC 3339 UTC. |
livemode | boolean | |
workspace | string or null | ws_…, or null for an org-level event. |
external_ref | string or null | Your id for the workspace, as you set it. |
data | object |
GET /events/{id}
Retrieve an event of the last 30 days.
Who: An org key, scope webhooks.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The event.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "event" | |
id | string | evt_…: one id per event, the same on every endpoint and every retry. Dedupe on it. |
type | one of: run.completed, run.failed, run.cancelled, action.requires_approval, action.completed, action.failed, approval.requested, approval.decided, approval.expired, message.created, agent.paused, agent.resumed, agent.attention_needed, task.completed, task.failed, task.escalated, schedule.missed, workspace.cap_reached, usage.threshold_reached, org.credits.low, org.credits.exhausted, org.topup.reversed, org.statement.closed, org.billing_account.changed, org.credits.reloaded, org.credits.reload_failed, org.credits.buffer_used, org.topup.failed, connector.drifted, workspace.suspended, workspace.resumed, workspace.archived, workspace.restored, workspace.erased, export.ready, export.failed, template.promoted, connection.created, connection.updated, connection.needs_reauth, connection.revoked, computer.session_ended, ping | |
api_version | string | |
created | string | RFC 3339 UTC. |
livemode | boolean | |
workspace | string or null | ws_…, or null for an org-level event. |
external_ref | string or null | Your id for the workspace, as you set it. |
data | object |
Subjects
DELETE /subjects/{subject}
Erase one of your users: redact what they wrote, then delete their identity.
For your user's right to erasure. In every workspace of this org and mode, the messages they wrote are redacted and lose their author, the threads they started become nobody's (seen only by owner, admin and your key with no subject), the activity-log entries naming them are emptied, the vault items they saved and the files they attached are deleted and the connections they made are revoked (connection.revoked); then their identity, memberships and sessions are deleted. Percent-encode the subject (a / is %2F). A failure part-way answers 500 subject_erase_incomplete: send the same request again and it carries on. From the start of the erase until it finishes, the user can't act: OpenLegion-Subject and POST /sessions for them answer 409 subject_erasing, and their sessions stop working. 409 subject_busy means another request for this user was in flight: retry. An unknown or already-erased subject is a 404. Needs the data_rights scope.
Who: An org key, scope data_rights.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
subject | path | string | yes |
Returns:
200: Erased.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "subject" | |
id | string | Your user's id, as you sent it. |
livemode | boolean | |
deleted | true |
Org audit events
GET /org_audit_events
List your organization's audit log, newest first.
This mode's entries and the org's mode-less ones. Filter by action and by created time; page with starting_after or ending_before.
Who: An org key, scope workspaces:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
action | query | string | An exact action, e.g. key.created. | |
created[gte] | query | string | RFC 3339: created at or after. | |
created[lt] | query | string | RFC 3339: created before. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An oae_ id: the page after it. | |
ending_before | query | string | An oae_ id: the page before it. |
Returns:
200: A list of org audit events.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "org_audit_event" | |
id | string | oae_… |
livemode | boolean or null | null: an act on the org itself, in neither mode (its creation, its billing account). |
created | string | |
action | string | |
actor | object | Who acted: a person in your console (never named here), an org key, or OpenLegion. |
key | string or null | key_…: the org key that acted, when one did. |
resource | string or null | What was acted on, as type:id (workspace:ws_…). A person is the type alone (org_member): never their user id. |
detail | object | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /org_audit_events/{id}
Retrieve one org audit event.
Who: An org key, scope workspaces:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The org audit event.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "org_audit_event" | |
id | string | oae_… |
livemode | boolean or null | null: an act on the org itself, in neither mode (its creation, its billing account). |
created | string | |
action | string | |
actor | object | Who acted: a person in your console (never named here), an org key, or OpenLegion. |
key | string or null | key_…: the org key that acted, when one did. |
resource | string or null | What was acted on, as type:id (workspace:ws_…). A person is the type alone (org_member): never their user id. |
detail | object | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Keys
GET /keys/self
The key you are calling with.
Any org key, whatever its scopes. Its id, name, scopes and expiry, and its organization. Never a secret.
Who: An org key, scope any_key.
Returns:
200: This key.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "api_key" | |
id | string | |
name | string | |
livemode | boolean | |
scopes | array of string | |
hint | string | The key's last four characters. |
created | string | |
expires_at | string or null | |
revoked | boolean | |
org | string | org_… |
org_name | string | |
made_by_login | boolean | True for a key npx openlegion login made (a device approval). |
browser | boolean | Whether this deployment can run the browser tools (browser.open, browser.act, browser.snapshot, browser.close, browser.fill_credential). A template may list them only when this is true; while it is false, a push that lists them is refused. |
POST /keys/self/revoke
Revoke the key you are calling with.
Any org key, whatever its scopes; no body. Revokes the key that sends it, at once (npx openlegion logout). Recorded in the org audit log as the key's own act. A later call with it is 401 api_key_revoked.
Who: An org key, scope any_key.
Returns:
200: Revoked.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "api_key" | |
id | string | |
revoked | true |
Dev sessions
POST /dev_sessions
Open a dev session (npx openlegion dev) on dev targets: takes them over from any session that holds them.
Test mode only. At most 5 live sessions per org; a session not seen for 15 s is offline and does not count. OpenLegion also limits live sessions across all organizations: past that limit, a create is 429 rate_limited, with Retry-After.
Who: An org key, scope connectors.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
connector | string | con_…: a dev connector (transport: dev) of this org. | |
webhook_endpoint | string | whe_…: a dev webhook endpoint (transport: dev). Needs the webhooks scope too. | |
device_name | string | What to call this machine in a takeover's message. |
Returns:
201: The session, connected.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "dev_session" | |
id | string | des_… |
livemode | false | |
status | one of: connected, offline, superseded, closed | offline: connected, but not seen for 15 s. Requests to its targets fail at once until it polls again. |
connector | string or null | con_…: the dev connector it holds. |
webhook_endpoint | string or null | whe_…: the dev webhook endpoint it holds. |
device_name | string or null | |
last_seen_at | string | RFC 3339 UTC. |
created | string | RFC 3339 UTC. |
GET /dev_sessions/{id}
Retrieve a dev session.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The session.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "dev_session" | |
id | string | des_… |
livemode | false | |
status | one of: connected, offline, superseded, closed | offline: connected, but not seen for 15 s. Requests to its targets fail at once until it polls again. |
connector | string or null | con_…: the dev connector it holds. |
webhook_endpoint | string or null | whe_…: the dev webhook endpoint it holds. |
device_name | string or null | |
last_seen_at | string | RFC 3339 UTC. |
created | string | RFC 3339 UTC. |
DELETE /dev_sessions/{id}
Close a dev session: its connector and endpoint stay, for the next one.
Requests it had not answered fail at once. Closing a session that is already closed or superseded changes nothing.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The session, closed.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "dev_session" | |
id | string | des_… |
livemode | false | |
status | one of: connected, offline, superseded, closed | offline: connected, but not seen for 15 s. Requests to its targets fail at once until it polls again. |
connector | string or null | con_…: the dev connector it holds. |
webhook_endpoint | string or null | whe_…: the dev webhook endpoint it holds. |
device_name | string or null | |
last_seen_at | string | RFC 3339 UTC. |
created | string | RFC 3339 UTC. |
GET /dev_sessions/{id}/requests
The long poll: the requests waiting for this session, as soon as there are any.
Answers at once when requests are waiting (at most 10, and at most 4 MiB in all), otherwise an empty list after wait seconds. Each request is handed out once. Each poll marks the session seen.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
wait | query | integer | 1–25 seconds, default 25. |
Returns:
200: The requests handed to this session (possibly none).400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "dev_request" | |
id | string | dvr_… |
kind | one of: mcp, webhook | mcp: forward it to your app's MCP route. webhook: to its webhooks route. Verify its signature first. |
method | one of: POST, GET, DELETE | |
headers | object | content-type, accept, user-agent, mcp-* and openlegion-* only. |
body_base64 | string or null | The exact request bytes, base64. Verify the signature over these bytes, decoded. |
deadline | string | After this the caller has stopped waiting: an answer is refused. |
POST /dev_sessions/{id}/requests/{request_id}/response
Post your app's answer to one request: the raw bytes, with its status in OpenLegion-Dev-Status.
The body is the answer's bytes (at most 4 MiB), sent as they are. Only its content-type and mcp-* headers reach the caller. Single use: a second answer is 409 dev_request_answered; one past the deadline, or for a request the caller gave up on, is 409 dev_request_expired.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
request_id | path | string | yes | |
OpenLegion-Dev-Status | header | integer | yes | The HTTP status your app answered: 200–599. |
Content-Type | header | string | The answer's content type. |
Returns:
200: The answer was taken.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "dev_request_answer" | |
request | string | dvr_… |
status | integer |
Device authorizations
POST /device_authorizations/deploy
Ask a person to approve the keys a deployment needs (npx openlegion deploy).
Asked for with a test key (a live key: 400 test_mode_only). Plans the deployment's two keys (the app key and, unless data_rights is false, the data-rights key): each is kept, made, or replaced. When every key is kept, answers 200 and nothing needs approving. Otherwise answers 201 with codes, as POST /device_authorizations does: a person who is an owner or admin of this key's organization approves on the page, for this organization only, and the next POST /device_authorizations/token makes the keys and answers them once.
LIVE (target.live, for the production environment, or host: "none" with no linked host): the keys are live, the exchange also makes a run key, and it always needs approving (201, codes valid 10 minutes). Refused, with nothing changed: 403 livemode_not_approved (a person asks for live access on Settings → Go live first), 403 org_suspended, 409 live_grant_pending (one is already open: waiting for approval, or approved and not yet collected), 503 live_keys_need_mail (this deployment can't send the mail every live grant sends to the organization's owners and admins). A live login whose asking key is revoked is void at once.
Who: An org key, scope connectors.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
client_version | string | yes | The CLI's version, shown on the approval page. |
device_name | string | What the device calls itself (the CLI sends its host name). Shown on the approval page as the device's own claim. | |
target | object | yes | What is being deployed, and what the CLI saw in the host. |
Returns:
200: Every key is kept: nothing to approve (test mode only).201: A deploy login, waiting for approval.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "deploy_authorization" | |
livemode | boolean | True for a live deploy grant (target.live): the exchange makes live keys and a run key. |
approval_needed | boolean | false: every key is kept and nothing needs approving; the fields below are null. Always true for live (the run key is always made). |
keys | array of object | |
device_code | string or null | oldc_…: send it to POST /device_authorizations/token; never show it. null on an idempotent replay: mint a new one. |
user_code | string or null | WDJB-MJHT: show it to the person, who types it on the page. |
verification_uri | string or null | |
expires_in | integer or null | |
interval | integer or null |
POST /device_authorizations
Start signing in from a terminal (no key).
RFC 8628's device authorization request. Show user_code and open verification_uri; the person signs in, types the code, picks an organization and approves. Then poll POST /device_authorizations/token. Takes no key. Limited per client address: 429.
Who: No key.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
client | "openlegion-cli" | yes | Who is asking. "openlegion-cli": npx openlegion login. |
client_version | string | yes | The client's version, shown on the approval page. |
device_name | string | What the device calls itself (the CLI sends its host name). Shown on the approval page as the device's own claim. Default "Unnamed device". | |
grants | array of one of: cli, app | Which keys an approval makes: ["cli"] (default) or ["cli", "app"]. | |
source | string | Where this login started, as a short code (for example init), for attribution only. Shown on the approval page. |
Returns:
201: A login, waiting for approval.400: invalid_request_error: an invalid parameter or OpenLegion-Version; and the exchange's device-flow codes: authorization_pending, slow_down (with Retry-After), access_denied, expired_token, device_code_invalid.429: rate_limit_error: too many device-flow requests from this client. See Retry-After.
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "device_authorization" | |
device_code | string | oldc_…: the device's secret. Send it to POST /device_authorizations/token; never show it. |
user_code | string | WDJB-MJHT: show it to the person, who types it on the page. |
verification_uri | string | The page where the person signs in, types the code and approves. |
expires_in | integer | Seconds until both codes expire (600). |
interval | integer | Seconds to wait between polls (5). |
POST /device_authorizations/token
Collect the keys a terminal login was approved for (no key).
Poll at interval. 400 authorization_pending until the person approves; slow_down (with Retry-After) when polled too often; access_denied; expired_token; device_code_invalid for a code that is unknown or already used. Once approved, the next poll answers 200 ONCE: the keys are made by that call, in the organization chosen at approval, and their secrets are in that answer only. Test keys, except for a live deploy grant (POST /device_authorizations/deploy with target.live): its keys are live, with a run_key, and it is checked again first: 403 livemode_not_approved or org_suspended, 503 live_keys_need_mail, 409 deploy_plan_changed (the keys it would make or replace are no longer what the approver was shown). Any login whose asking key was revoked since is access_denied. A refusal after the approval spends the code: nothing makes it good later, ask again. Takes no key.
Who: No key.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
device_code | string | yes | The oldc_… code POST /device_authorizations answered. |
Returns:
200: The keys, made now.400: invalid_request_error: an invalid parameter or OpenLegion-Version; and the exchange's device-flow codes: authorization_pending, slow_down (with Retry-After), access_denied, expired_token, device_code_invalid.403: permission_error: org_suspended — the organization chosen at approval is suspended.409: conflict_error: key_limit_reached — the organization holds its maximum of active test keys.429: rate_limit_error: too many device-flow requests from this client. See Retry-After.
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "device_grant" | |
livemode | boolean | True for a live deploy grant: every key in this answer is live. |
org | string | org_…: the organization chosen on the approval page. |
org_name | string | |
keys | array of object | |
kept | array of object | A deploy grant only: the deployment's keys left as they are, because the host has them and they are in service. |
run_key | object | A live deploy grant only: the key this run does its live steps with (the live connector, webhook and template). Never one of keys, so it can't be put into a host by mistake. |
Connector catalog
GET /connector_catalog
List the apps your users can connect.
One entry per app, in name order. Filter by source, status or category.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
source | query | string | vendor_mcp, native or piece. | |
status | query | string | available or needs_oauth_app. | |
category | query | string | One category, e.g. productivity. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An app id: the page after it. |
Returns:
200: A list of catalog entries.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "catalog_entry" | |
id | string | The app: what a connection's app and a connect session's app name. |
name | string | |
description | string | One line, OpenLegion's words. |
categories | array of string | |
logo | string or null | A copy OpenLegion hosts, or null: render the name's initial. |
source | one of: vendor_mcp, native, piece | vendor_mcp: the vendor's own MCP server. native: OpenLegion's own tools. piece: OpenLegion's runner. |
status | one of: available, needs_oauth_app | available: your users can connect it. needs_oauth_app: the vendor's server admits only a registered OAuth app, and OpenLegion has none for it yet. |
auth | object | |
setup | string or null | What has to happen before the first connection can work, or null. |
tools | array of object or null | null: the vendor's server lists its tools once an account is connected, and none of them can be allowed by a template. For a vendor server, the tools OpenLegion has reviewed; a review lapses for a tool whose input schema the vendor changes, which then needs a person's approval again. |
GET /connector_catalog/{id}
Retrieve one app in the catalog.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The catalog entry.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "catalog_entry" | |
id | string | The app: what a connection's app and a connect session's app name. |
name | string | |
description | string | One line, OpenLegion's words. |
categories | array of string | |
logo | string or null | A copy OpenLegion hosts, or null: render the name's initial. |
source | one of: vendor_mcp, native, piece | vendor_mcp: the vendor's own MCP server. native: OpenLegion's own tools. piece: OpenLegion's runner. |
status | one of: available, needs_oauth_app | available: your users can connect it. needs_oauth_app: the vendor's server admits only a registered OAuth app, and OpenLegion has none for it yet. |
auth | object | |
setup | string or null | What has to happen before the first connection can work, or null. |
tools | array of object or null | null: the vendor's server lists its tools once an account is connected, and none of them can be allowed by a template. For a vendor server, the tools OpenLegion has reviewed; a review lapses for a tool whose input schema the vendor changes, which then needs a person's approval again. |
Connect settings
GET /connect_settings
Retrieve the connect page settings.
This mode's settings for the hosted connect page: its name, logo, color, privacy link and return origins.
Who: An org key, scope connectors.
Returns:
200: The settings.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connect_settings" | |
livemode | boolean | |
name | string or null | The name your users see on the connect page. null: your organization's name. |
logo_url | string or null | An https image shown on the connect page, or null. |
accent_color | string or null | #rrggbb, or null for the default. |
privacy_url | string or null | Your privacy policy, linked from the connect page, or null. |
return_origins | array of string | Exact https origins a connect session's return_url may be on (at most 10). Test mode also allows http://localhost. |
updated_at | string or null | When these were last changed, or null: never. |
POST /connect_settings
Update the connect page settings.
Changes only the fields you send; null clears one. return_origins replaces the list: exact https origins, no path.
Who: An org key, scope connectors.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
name | string or null | ||
logo_url | string or null | ||
accent_color | string or null | ||
privacy_url | string or null | ||
return_origins | array of string | Replaces the list. |
Returns:
200: The settings.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connect_settings" | |
livemode | boolean | |
name | string or null | The name your users see on the connect page. null: your organization's name. |
logo_url | string or null | An https image shown on the connect page, or null. |
accent_color | string or null | #rrggbb, or null for the default. |
privacy_url | string or null | Your privacy policy, linked from the connect page, or null. |
return_origins | array of string | Exact https origins a connect session's return_url may be on (at most 10). Test mode also allows http://localhost. |
updated_at | string or null | When these were last changed, or null: never. |
Oauth apps
GET /oauth_apps
List your OAuth apps.
Every OAuth app of this mode, oldest first, on one page (one per catalog app at most).
Who: An org key, scope connectors.
Returns:
200: A list of OAuth apps.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "oauth_app" | |
id | string | oapp_… |
livemode | boolean | |
app | string | The catalog app this OAuth client is for, such as google. |
client_id | string | Your OAuth client id. The client secret is write-only and never returned. |
redirect_uri | string | The redirect URI to register with the vendor for this client. |
created | string | |
updated_at | string |
POST /oauth_apps
Add or replace your OAuth app for a catalog app.
One per catalog app and mode. Sending it again replaces it in place (same id). After a client id change or a delete, existing connections keep working until their next token refresh, then read needs_reauth; a secret change keeps them.
Who: An org key, scope connectors.
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
app | string | yes | A catalog app that connects with OAuth, such as google. |
client_id | string | yes | The OAuth client id from the vendor's console. |
client_secret | string | yes | The client secret. Sealed on arrival; never returned. |
Returns:
200: Replaced: same id.201: Created.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "oauth_app" | |
id | string | oapp_… |
livemode | boolean | |
app | string | The catalog app this OAuth client is for, such as google. |
client_id | string | Your OAuth client id. The client secret is write-only and never returned. |
redirect_uri | string | The redirect URI to register with the vendor for this client. |
created | string | |
updated_at | string |
GET /oauth_apps/{id}
Retrieve an OAuth app.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: The OAuth app.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "oauth_app" | |
id | string | oapp_… |
livemode | boolean | |
app | string | The catalog app this OAuth client is for, such as google. |
client_id | string | Your OAuth client id. The client secret is write-only and never returned. |
redirect_uri | string | The redirect URI to register with the vendor for this client. |
created | string | |
updated_at | string |
DELETE /oauth_apps/{id}
Delete an OAuth app.
New connections use OpenLegion's app again. Connections made with yours keep working until their next token refresh, then read needs_reauth.
Who: An org key, scope connectors.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Returns:
200: Deleted.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "oauth_app" | |
id | string | |
deleted | true |
Onboarding
GET /onboarding
Where this project's setup stands.
Any key of the project, whatever its scopes. Four facts from the project's test mode (signed in, kit added, agent arrived, first message), each with what was seen and when, and the one next step in plain words, with who takes it (by). The same facts the console's setup guide shows. Once the project is approved for live mode, the step after go_live reads its live mode: deploy_live until a live connector passed its test and a live agent version is promoted, then top_up until the live balance was funded.
Who: An org key, scope any_key.
Returns:
200: This project's setup.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "onboarding" | |
org | string | org_… |
org_name | string | |
livemode | boolean | The calling key's mode. The facts are always the project's test mode. |
signed_in | object | The CLI signed in to this project. |
kit_added | object | npx openlegion init made the app's key. |
agent_arrived | object | A version of the developer's own agent arrived. |
first_message | object | A run that the developer's app started. |
next_step | object |
Agents
GET /agents
List the workspace's agents.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An agt_ id: the page after it. | |
ending_before | query | string | An agt_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of agents, oldest first.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "agent" | |
id | string | agt_… |
livemode | boolean | |
created | string | |
name | string | |
status | one of: active, paused | active: it runs when something starts it (an idle agent is active too); paused: it does not until resumed. |
paused | object or null | Why and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard. |
model | object | The effective model choice. |
template | string or null | The workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version the agent runs now. |
template_agent | string or null | The template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes. |
origin | one of: template, api | Who made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API). |
external_ref | string or null | Your own id for an agent made through the API. Null for a template's agent. |
overrides | object | What the end customer changed. Everything else is the template's. |
customizable | object or null | What may be changed on this agent. Null: nothing. |
tools | array of object | The template agent's tools, and which are on. Connector tools are granted beside them and are not listed. |
max_concurrent_runs | integer | At most this many runs of this agent at once, from its template agent (1–32). 1: every run on the agent is serial. Until concurrent runs ship, every agent runs serially, whatever this says. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /agents
Create an agent from a template agent (create-or-get on external_ref).
Makes another agent from one of the template agents the workspace's version lists in customizable.agents.creatable, with the same changes POST /agents/{id} allows, inside the same bounds (409 outside_template_bounds). It follows that template agent through every re-pin and promote, its changes on top. A real create returns 201; an external_ref the workspace already uses returns 200 with that agent, unchanged, whatever the body says. Past customizable.agents.max agents made this way: 409 agent_limit_reached. A session, or a subject, needs the owner or admin role: 403 insufficient_role otherwise.
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
template_agent | string | yes | The template agent to make another of: one of customizable.agents.creatable (GET /template_agents). |
name | string or null | A new display name, within customizable.name. null: the template's again. | |
role | string or null | A new one-line role, within customizable.role. null: the template's again. | |
instructions | string or null | The end customer's own instructions, added after the template's (which they never replace). null or an empty string: none. | |
model_tier | one of: background, fast, reasoning, frontier, auto or null | One of customizable.model_tier.allowed, or "auto" when customizable.model_tier.auto is true: each run is routed to one of auto_presets. null: the template's again (and no Auto). | |
auto_presets | array of one of: background, fast, reasoning, frontier or null | With model_tier "auto" (sent now, or already set): the presets its runs may be routed to, at least two of fast, reasoning and frontier, each in customizable.model_tier.allowed. Absent with "auto", or null: every one of those the template allows. Set it from your plan, never from the browser. | |
tools | object | {id: false} switches off a tool listed in customizable.tools.optional; {id: true} switches it back on. No tool can be added. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. | |
external_ref | string | Your own id for this agent. A second create with the same external_ref returns that agent (200), unchanged. |
Returns:
200: The agent this external_ref already names, unchanged.201: The agent, made.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "agent" | |
id | string | agt_… |
livemode | boolean | |
created | string | |
name | string | |
status | one of: active, paused | active: it runs when something starts it (an idle agent is active too); paused: it does not until resumed. |
paused | object or null | Why and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard. |
model | object | The effective model choice. |
template | string or null | The workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version the agent runs now. |
template_agent | string or null | The template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes. |
origin | one of: template, api | Who made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API). |
external_ref | string or null | Your own id for an agent made through the API. Null for a template's agent. |
overrides | object | What the end customer changed. Everything else is the template's. |
customizable | object or null | What may be changed on this agent. Null: nothing. |
tools | array of object | The template agent's tools, and which are on. Connector tools are granted beside them and are not listed. |
max_concurrent_runs | integer | At most this many runs of this agent at once, from its template agent (1–32). 1: every run on the agent is serial. Until concurrent runs ship, every agent runs serially, whatever this says. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /agents/{id}
Read an agent.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The agent.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "agent" | |
id | string | agt_… |
livemode | boolean | |
created | string | |
name | string | |
status | one of: active, paused | active: it runs when something starts it (an idle agent is active too); paused: it does not until resumed. |
paused | object or null | Why and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard. |
model | object | The effective model choice. |
template | string or null | The workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version the agent runs now. |
template_agent | string or null | The template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes. |
origin | one of: template, api | Who made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API). |
external_ref | string or null | Your own id for an agent made through the API. Null for a template's agent. |
overrides | object | What the end customer changed. Everything else is the template's. |
customizable | object or null | What may be changed on this agent. Null: nothing. |
tools | array of object | The template agent's tools, and which are on. Connector tools are granted beside them and are not listed. |
max_concurrent_runs | integer | At most this many runs of this agent at once, from its template agent (1–32). 1: every run on the agent is serial. Until concurrent runs ship, every agent runs serially, whatever this says. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /agents/{id}
Update an agent.
Change what the template lets an end customer change (the agent's customizable): its name, role, their own instructions, its model preset, and which optional tools are on; and your metadata. Anything else, or a value outside the bounds, is the refusal outside_template_bounds (409), naming the field in param, and nothing is written. The changes are kept across a re-pin or promote; one the new version no longer allows goes back to the template's value. A session, or a subject, needs the owner or admin role: 403 insufficient_role otherwise. Text that looks like a key or holds one of the workspace's secrets is refused with 400 parameter_invalid. Sending what is already set changes nothing. A move to another model preset whose runs the workspace's caps can't cover (one run on it holds more than a hard period_credit_cap or the daily_credit_cap) is outside_template_bounds on model_tier, and partner_message names the cap.
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
name | string or null | A new display name, within customizable.name. null: the template's again. | |
role | string or null | A new one-line role, within customizable.role. null: the template's again. | |
instructions | string or null | The end customer's own instructions, added after the template's (which they never replace). null or an empty string: none. | |
model_tier | one of: background, fast, reasoning, frontier, auto or null | One of customizable.model_tier.allowed, or "auto" when customizable.model_tier.auto is true: each run is routed to one of auto_presets. null: the template's again (and no Auto). | |
auto_presets | array of one of: background, fast, reasoning, frontier or null | With model_tier "auto" (sent now, or already set): the presets its runs may be routed to, at least two of fast, reasoning and frontier, each in customizable.model_tier.allowed. Absent with "auto", or null: every one of those the template allows. Set it from your plan, never from the browser. | |
tools | object | {id: false} switches off a tool listed in customizable.tools.optional; {id: true} switches it back on. No tool can be added. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Returns:
200: The agent, changed.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "agent" | |
id | string | agt_… |
livemode | boolean | |
created | string | |
name | string | |
status | one of: active, paused | active: it runs when something starts it (an idle agent is active too); paused: it does not until resumed. |
paused | object or null | Why and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard. |
model | object | The effective model choice. |
template | string or null | The workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version the agent runs now. |
template_agent | string or null | The template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes. |
origin | one of: template, api | Who made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API). |
external_ref | string or null | Your own id for an agent made through the API. Null for a template's agent. |
overrides | object | What the end customer changed. Everything else is the template's. |
customizable | object or null | What may be changed on this agent. Null: nothing. |
tools | array of object | The template agent's tools, and which are on. Connector tools are granted beside them and are not listed. |
max_concurrent_runs | integer | At most this many runs of this agent at once, from its template agent (1–32). 1: every run on the agent is serial. Until concurrent runs ship, every agent runs serially, whatever this says. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
DELETE /agents/{id}
Delete an agent made with POST /agents.
Deletes an agent made with POST /agents: it stops, its waiting schedules are cancelled, and it is a 404 from then on; its conversations, runs and audit trail are kept, and its external_ref can be used again. The template's own agents can't be deleted (409 template_agent_not_deletable). A session, or a subject, needs the owner or admin role: 403 insufficient_role otherwise.
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The agent, deleted.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "agent" | |
id | string | agt_… |
livemode | boolean | |
created | string | |
name | string | |
status | "deleted" | |
paused | object or null | Why and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard. |
model | object | The effective model choice. |
template | string or null | The workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version the agent runs now. |
template_agent | string or null | The template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes. |
origin | one of: template, api | Who made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API). |
external_ref | string or null | Your own id for an agent made through the API. Null for a template's agent. |
overrides | object | What the end customer changed. Everything else is the template's. |
customizable | object or null | What may be changed on this agent. Null: nothing. |
tools | array of object | The template agent's tools, and which are on. Connector tools are granted beside them and are not listed. |
max_concurrent_runs | integer | At most this many runs of this agent at once, from its template agent (1–32). 1: every run on the agent is serial. Until concurrent runs ship, every agent runs serially, whatever this says. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
deleted | true |
POST /agents/{id}/pause
Pause an agent.
Nothing runs until it is resumed: no schedule, no message, no inbound event. A run that has started finishes the step it is on and stops at the next. Messages sent to it are refused with agent_paused; work already queued is kept for the resume. Pausing a paused agent returns it unchanged.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The agent, paused.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "agent" | |
id | string | agt_… |
livemode | boolean | |
created | string | |
name | string | |
status | one of: active, paused | active: it runs when something starts it (an idle agent is active too); paused: it does not until resumed. |
paused | object or null | Why and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard. |
model | object | The effective model choice. |
template | string or null | The workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version the agent runs now. |
template_agent | string or null | The template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes. |
origin | one of: template, api | Who made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API). |
external_ref | string or null | Your own id for an agent made through the API. Null for a template's agent. |
overrides | object | What the end customer changed. Everything else is the template's. |
customizable | object or null | What may be changed on this agent. Null: nothing. |
tools | array of object | The template agent's tools, and which are on. Connector tools are granted beside them and are not listed. |
max_concurrent_runs | integer | At most this many runs of this agent at once, from its template agent (1–32). 1: every run on the agent is serial. Until concurrent runs ship, every agent runs serially, whatever this says. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /agents/{id}/resume
Resume a paused agent.
Schedules that came due while it was paused are skipped, never replayed. The messages and events kept while it was paused are delivered now, one run per conversation. Resuming an agent that is not paused returns it unchanged.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The agent, active.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "agent" | |
id | string | agt_… |
livemode | boolean | |
created | string | |
name | string | |
status | one of: active, paused | active: it runs when something starts it (an idle agent is active too); paused: it does not until resumed. |
paused | object or null | Why and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard. |
model | object | The effective model choice. |
template | string or null | The workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N. |
template_version | integer or null | The version the agent runs now. |
template_agent | string or null | The template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes. |
origin | one of: template, api | Who made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API). |
external_ref | string or null | Your own id for an agent made through the API. Null for a template's agent. |
overrides | object | What the end customer changed. Everything else is the template's. |
customizable | object or null | What may be changed on this agent. Null: nothing. |
tools | array of object | The template agent's tools, and which are on. Connector tools are granted beside them and are not listed. |
max_concurrent_runs | integer | At most this many runs of this agent at once, from its template agent (1–32). 1: every run on the agent is serial. Until concurrent runs ship, every agent runs serially, whatever this says. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /agents/{id}/runs
Start a run with no chat message.
For your own scheduler or a sign-up flow ("plan this week"). Returns the run: 201 started, 202 queued behind the agent's active run. A run the workspace cannot fund or start is refused before it starts (402 credits_exhausted or cap_reached, 409 agent_paused, …). Idempotent on Idempotency-Key.
Who: An org key, scope messages.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
input | string | yes | What to do, in words: it lands in the thread as the caller's message. |
thread | string | thr_…: run in this conversation, so the result shows in the customer's chat history. Absent: a new thread. | |
metadata | object | Yours: returned on the run and on run.completed / run.failed. A key sent as "" or null is not stored. | |
model_tier | one of: background, fast, reasoning, frontier, auto | A model preset for the run that answers this message, and only that run: one of the template's customizable.model_tier.allowed (GET /template_agents), else 409 outside_template_bounds. The run never moves above it. "auto": the run is routed to one of auto_presets (the template must set customizable.model_tier.auto). Absent: the agent's own preset. | |
auto_presets | array of one of: background, fast, reasoning, frontier | With model_tier "auto" only: the presets this run may be routed to, at least two of fast, reasoning and frontier, each in customizable.model_tier.allowed (else 409 outside_template_bounds). Absent: every one of those the template allows. Set it from your plan, never from the browser. |
Returns:
201: The run (started).202: The run (queued).400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "run" | |
id | string | run_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
agent | string | agt_… |
thread | string or null | thr_…: where the run's messages land. A resume run's is the thread of the run that asked for the approval (the agent's home thread when it answers decisions from different threads). |
status | one of: queued, running, completed, failed, cancelled, settling | One of queued, running, completed, failed, cancelled, settling. settling: an action is still finishing after the run ended. |
trigger | one of: message, schedule, inbound_event, api, resume, handoff, follow_up, other | |
cost_micro | integer | What the run was charged for model calls and paid tools, in micro-dollars; until the run ends, what it has spent so far. A run that was answered together with an earlier message reports 0: the charge is on the earliest. |
credits | number | The same charge in credits: cost_micro / 1000 exactly, at most three decimals, so runs add up exactly; GET /usage rounds a window's spend up to a whole credit, and that spend is its runs added up plus any work that belongs to no run (memory upkeep, voice transcription). |
model | string or null | The gateway id of the model on the run's last step, e.g. anthropic/claude-haiku-5.5. A run can move to a stronger model part way through; this is the one it ended on. It names the model each step was sent to: if that provider was down, a listed backup may have answered a step. Null while the run is queued and until its first model call. |
model_name | string or null | What a person reads for model: the vendor's own product name, e.g. Claude Haiku 5.5 (GET /model_presets names each preset's model now). Null when model is, or when it is a model we have no name for. |
model_tier | one of: background, fast, reasoning, frontier or null | The preset the run started on: the one a person picked with the message (model_tier on POST /threads/{id}/messages or POST /agents/{id}/runs), the one Auto chose, else the agent's own. A run on its agent's own preset may move to a stronger one part way through; model names the model it ended on. Null while the run is queued. |
model_choice | one of: agent, person, auto or null | Who chose model_tier. agent: the agent's own preset. person: a preset picked with the message or run. auto: Auto chose it, because the agent is on Auto or the message asked for it (auto says how). Null while the run is queued. |
auto | object or null | How Auto chose model_tier. Null unless model_choice is auto, and on a run routed before Auto among presets was recorded. |
model_requested | object or null | Set when the run did not run on the preset it was meant to: model_tier is the one it ran on instead. A person's pick that reached a run started without it (a resume, a decision's resume, a continuation) can need more than that run was given. model_choice then reads agent, and the reply ends with a data-model-note part for the person. Null on every other run, and while the run is queued. |
started_at | string or null | |
ended_at | string or null | |
error | object or null | Why the run did not succeed: a stable code, the end user's sentence and yours. |
waiting | object or null | Why a queued run has not started yet. Present only while status is queued; null while a queued run is being retried. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /agents/{id}/memory
List what an agent remembers.
What the agent learned and was told by its user, never its template's own text (soul, instructions, core blocks). Core blocks the template did not write come first (an end customer's own instructions among them), then lessons (both on the first page only), then learnings newest first: the agent's own and the workspace's shared ones. Page the learnings with limit and starting_after. An owner or admin, as a session or a subject; a member is 403 insufficient_role.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
kind | query | string | core_block, lesson, fact, episode or procedure. | |
limit | query | integer | 1–100, default 20: learnings per page. | |
starting_after | query | string | A learning's mem_ id: the page after it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of memory items.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "memory_item" | |
id | string | mem_… |
livemode | boolean | |
agent | string | agt_…: the agent whose memory this is listed under. |
kind | one of: core_block, lesson, fact, episode, procedure | core_block: a block the agent's template did not write (the template's own are never listed). lesson: one bullet of its lessons. fact, episode, procedure: a learning. |
scope | one of: agent, workspace | workspace: shared by every agent of the workspace (a learning only). |
label | string or null | A core block's label; null otherwise. |
text | string | |
version | integer or null | A core block's version; null otherwise. |
trust | one of: owner, system, tool_verified, web_low or null | How far the item is trusted. It comes from who wrote it; storing it never raises it. |
source | object or null | Where it came from, when that is known: the run that learned it, the message behind it, or who wrote it. |
created | string or null | RFC 3339 UTC. A core block's is its current version's. |
metadata | object | Always empty: an item is the agent's, not yours to label (the field is kept for the shape). |
DELETE /agents/{id}/memory/{memory_item_id}
Forget one memory item.
A learning is forgotten for good: the agent never recalls it again, and its history stays readable. A lesson is removed. A core block cannot be forgotten (409 memory_item_not_forgettable): edit it, or reset the agent's memory. An org key only.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
memory_item_id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: Forgotten.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "memory_item" | |
id | string | |
deleted | true |
POST /agents/{id}/memory/reset
Reset an agent's memory to its template.
In one step: forgets everything the agent learned on its own, clears its lessons and puts each template core block back as the template wrote it. The workspace's shared memories stay. While the agent is consolidating what it learned this answers 409 memory_busy: retry. An org key only.
Who: An org key, scope workspaces:write.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: Reset.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "memory_reset" | |
agent | string | |
forgotten | integer | The agent's own learnings forgotten. |
lessons_cleared | integer | |
blocks_restored | integer | Core blocks put back to the text the template wrote. |
GET /agents/summary
A person's agents, with what they haven't seen.
One call for a person's list of agents: the agents GET /agents lists, in the same order and pages, each with the person's ongoing conversation, what they have not seen there, the approvals waiting on them, and whether the agent is working. Needs a person (OpenLegion-Subject, or a session) and the scopes messages and approvals. Cheap enough to call again every few seconds while the page is open, and on focus.
Who: An org key with OpenLegion-Workspace, scopes messages and approvals; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An agt_ id: the page after it. | |
ending_before | query | string | An agt_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of agent summaries, oldest agent first.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "agent_summary" | |
agent | string | agt_… |
name | string | The agent's name, as GET /agents has it. |
status | one of: active, paused | As GET /agents has it. |
ongoing_thread | string or null | The person's ongoing conversation with this agent (thr_…), the one POST /threads {agent, ongoing: true} opens: for an owner or admin, the agent's home conversation; for a member, their newest conversation with it that is not archived. Null when there is none yet. |
unseen | integer | Messages in ongoing_thread the person has not seen: newer than their mark (POST /threads/{id}/seen, or their own newest message there, whichever is later), and not their own. 100 means 100 or more: draw "99+". 0 with no ongoing_thread. |
waiting | integer | Approvals of this agent still waiting that this person may decide (can_decide on GET /approvals/{id}). 100 means 100 or more. |
working | boolean | A run of this agent is answering, or queued, in a conversation this person sees. For an owner or admin, its work in the background counts too. |
last_message_at | string or null | ongoing_thread's newest message (RFC 3339). Null with no ongoing_thread, or none in it yet. |
GET /agents/{id}/browser_sites
List the websites an agent's browser may use.
The template's sites first, in its order; then the ones people allowed, oldest first (only while the version declares personSites). One page, at most 50 sites. Removed sites are left out. An agent without browser.open lists none. Any member may read it.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of browser sites.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "browser_site" | |
agent | string | agt_… |
site | string | The site: the browser may open it and its subdomains. |
source | one of: template, person | template: the version's browser.open sites. person: a person allowed it, on a browser_site_grant approval. |
added | object or null | A person's site: when it was allowed, and who allowed it. Null for the template's. |
approval | string or null | apr_…: the approval that allowed a person's site. Null for the template's. |
removed | object or null | Null on every listed site. On the answer to DELETE: when it was removed, and who removed it. |
DELETE /agents/{id}/browser_sites/{site}
Remove a website a person allowed.
The agent's next browser goes without it; a browser already open keeps it until it closes. The answer is the site, with removed: {at, subject}. A template's site is 409 browser_site_template_owned: change the template instead. An unknown site, or one already removed, is 404. An owner or admin may remove any; a member only one they allowed (403 insufficient_role).
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
site | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: Removed.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "browser_site" | |
agent | string | agt_… |
site | string | The site: the browser may open it and its subdomains. |
source | one of: template, person | template: the version's browser.open sites. person: a person allowed it, on a browser_site_grant approval. |
added | object or null | A person's site: when it was allowed, and who allowed it. Null for the template's. |
approval | string or null | apr_…: the approval that allowed a person's site. Null for the template's. |
removed | object or null | Null on every listed site. On the answer to DELETE: when it was removed, and who removed it. |
Template agents
GET /template_agents
List the template agents of the workspace's version.
The agents the workspace's template version describes, with what may be changed on each and which may be created more of; and agent_limit, how many POST /agents has made and the most allowed. One page, in the version's order.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The template agents.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string | |
agent_limit | object or null | The whole collection's summary, the same on every page: how many agents POST /agents has made and the most allowed, so a page can say so before anyone fills a form. Null when the version lets none be made (no customizable.agents). POST /agents still decides: at the most it refuses with 409 agent_limit_reached. |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "template_agent" | |
key | string | The template agent's key (agents[].key in the spec); an agent's template_agent. |
name | string | |
role | string | |
model_tier | string | Its model preset. |
tools | array of object | Its tools. Connector tools are granted beside them and are not listed. |
customizable | object or null | What may be changed on an agent made from it, or on it. Null: nothing. |
creatable | boolean | POST /agents may make another agent from it (customizable.agents.creatable). |
blueprint | boolean | true: the workspace has none of it until someone makes one with POST /agents (agents[].blueprint in the spec). false: every workspace has it. |
Threads
GET /threads
List conversations, newest first (or by their newest message).
A member acting as themselves (OpenLegion-Subject, or a session's user) gets only the threads they started; owner, admin and your key with no subject get every thread. Another person's thread answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
agent | query | string | Only this agent's (agt_…). | |
archived | query | one of: true, false | true: only archived conversations. Left out, or false: only the ones that are not. | |
unseen | query | one of: true, false | true: only the conversations where the person the call acts as (OpenLegion-Subject, or a session's user) has something unseen, the ones whose unseen > 0, however old, in the list's usual order and pages (archived ones only with archived=true). It needs a person: your key with no subject is 400 subject_required. Left out, or false: every conversation. | |
order | query | one of: created, last_message_at | created (the default): newest conversation first. last_message_at: the one with the newest message first, for a conversation list; one with no message yet sorts by when it was made. A conversation that gets a message while you page moves to the top, so a later page can skip or repeat it. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A thr_ id: the page after it. | |
ending_before | query | string | A thr_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of threads.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "thread" | |
id | string | thr_… |
livemode | boolean | |
created | string | |
agent | string | agt_…: the one agent this conversation is with. |
active_run | string or null | run_…: the run answering in this thread now, or the next one queued; null when idle. Re-attach to it with GET /runs/{id}/stream. |
title | string or null | What to call the conversation: the first line of its first message (at most 80 characters) until POST /threads/{id} changes it. Null before the first message. |
last_message_at | string or null | RFC 3339 UTC: when the newest message was written, by the person or the agent. Null before the first message. |
archived | boolean | true: a person archived it. GET /threads leaves it out unless archived=true. A new message brings it back. |
home | boolean | true: the agent's home conversation, where its work in the background reports (a schedule's run, a hand-off, a decision made outside any conversation). One per agent; POST /threads with home: true returns it. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
seen_through | string or null | How far the person this call acts as (OpenLegion-Subject, or a session's user) has seen this conversation: the time of the newest message they have seen there, as POST /threads/{id}/seen answers it, or of their own newest message there if that is later. RFC 3339 to the second, for display: a message written later in the same second has the same created. Null when they have seen nothing here yet, and when the call names no person (your key with no subject). Each person's own: no one else's mark shows. |
unseen | integer or null | What that person has not seen here: messages newer than their mark, not their own, counted exactly, as GET /agents/summary counts them. 100 means 100 or more. To ask whether anything here is unseen, test unseen > 0, never a time against seen_through. Null when the call names no person. |
POST /threads
Start a conversation with one agent.
With home: true, the agent's home conversation instead of a new one: where its work in the background reports (a schedule's run, a hand-off, a decision made outside any conversation). The same thread every time: 201 the first time, 200 after. Use it as a person's first conversation, and the reports land there. It is the workspace's: a member acting as themselves (OpenLegion-Subject, or a session's user) is 403 insufficient_role, and starts their own conversation without home. With ongoing: true, the person's ongoing conversation with the agent, the one GET /agents/summary names: the home conversation for an owner or admin, a member's newest one that is not archived, or a new one when there is none. 200 when it existed (even with the agent paused, or the workspace suspended: opening it is a read), 201 when this call made it.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
agent | string | yes | agt_… |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. | |
home | boolean | true: the agent's home conversation, where its work in the background reports, made if it has none yet: the same thread every time (201 the first time, 200 after). Use it as a person's first conversation. | |
ongoing | boolean | true: this person's ongoing conversation with the agent, the one GET /agents/summary names as ongoing_thread: for an owner or admin, the agent's home conversation; for a member, their newest conversation with it that is not archived, or a new one when they have none. 200 when it existed, 201 when this call made it. Not with home. |
Returns:
200: home: true, and the agent's home conversation was already the API's; or ongoing: true, and the person's ongoing conversation existed: the same thread.201: The thread.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "thread" | |
id | string | thr_… |
livemode | boolean | |
created | string | |
agent | string | agt_…: the one agent this conversation is with. |
active_run | string or null | run_…: the run answering in this thread now, or the next one queued; null when idle. Re-attach to it with GET /runs/{id}/stream. |
title | string or null | What to call the conversation: the first line of its first message (at most 80 characters) until POST /threads/{id} changes it. Null before the first message. |
last_message_at | string or null | RFC 3339 UTC: when the newest message was written, by the person or the agent. Null before the first message. |
archived | boolean | true: a person archived it. GET /threads leaves it out unless archived=true. A new message brings it back. |
home | boolean | true: the agent's home conversation, where its work in the background reports (a schedule's run, a hand-off, a decision made outside any conversation). One per agent; POST /threads with home: true returns it. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
seen_through | string or null | How far the person this call acts as (OpenLegion-Subject, or a session's user) has seen this conversation: the time of the newest message they have seen there, as POST /threads/{id}/seen answers it, or of their own newest message there if that is later. RFC 3339 to the second, for display: a message written later in the same second has the same created. Null when they have seen nothing here yet, and when the call names no person (your key with no subject). Each person's own: no one else's mark shows. |
unseen | integer or null | What that person has not seen here: messages newer than their mark, not their own, counted exactly, as GET /agents/summary counts them. 100 means 100 or more. To ask whether anything here is unseen, test unseen > 0, never a time against seen_through. Null when the call names no person. |
GET /threads/{id}
Read a conversation, with the run to re-attach to.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The thread.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "thread" | |
id | string | thr_… |
livemode | boolean | |
created | string | |
agent | string | agt_…: the one agent this conversation is with. |
active_run | string or null | run_…: the run answering in this thread now, or the next one queued; null when idle. Re-attach to it with GET /runs/{id}/stream. |
title | string or null | What to call the conversation: the first line of its first message (at most 80 characters) until POST /threads/{id} changes it. Null before the first message. |
last_message_at | string or null | RFC 3339 UTC: when the newest message was written, by the person or the agent. Null before the first message. |
archived | boolean | true: a person archived it. GET /threads leaves it out unless archived=true. A new message brings it back. |
home | boolean | true: the agent's home conversation, where its work in the background reports (a schedule's run, a hand-off, a decision made outside any conversation). One per agent; POST /threads with home: true returns it. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
seen_through | string or null | How far the person this call acts as (OpenLegion-Subject, or a session's user) has seen this conversation: the time of the newest message they have seen there, as POST /threads/{id}/seen answers it, or of their own newest message there if that is later. RFC 3339 to the second, for display: a message written later in the same second has the same created. Null when they have seen nothing here yet, and when the call names no person (your key with no subject). Each person's own: no one else's mark shows. |
unseen | integer or null | What that person has not seen here: messages newer than their mark, not their own, counted exactly, as GET /agents/summary counts them. 100 means 100 or more. To ask whether anything here is unseen, test unseen > 0, never a time against seen_through. Null when the call names no person. |
POST /threads/{id}
Rename or archive a conversation, or change its metadata.
Send only what changes: title (null clears it), archived, metadata. A member acting as themselves changes only a thread they started; another person's thread answers as one that does not exist. An archived conversation keeps its messages, leaves GET /threads unless archived=true is asked for, and is listed again when a new message is sent to it.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
title | string or null | What to call the conversation, 1 to 200 characters. null clears it. | |
archived | boolean | true archives the conversation: it leaves the default list, and nothing is deleted. false brings it back. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Returns:
200: The thread, as it now is.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "thread" | |
id | string | thr_… |
livemode | boolean | |
created | string | |
agent | string | agt_…: the one agent this conversation is with. |
active_run | string or null | run_…: the run answering in this thread now, or the next one queued; null when idle. Re-attach to it with GET /runs/{id}/stream. |
title | string or null | What to call the conversation: the first line of its first message (at most 80 characters) until POST /threads/{id} changes it. Null before the first message. |
last_message_at | string or null | RFC 3339 UTC: when the newest message was written, by the person or the agent. Null before the first message. |
archived | boolean | true: a person archived it. GET /threads leaves it out unless archived=true. A new message brings it back. |
home | boolean | true: the agent's home conversation, where its work in the background reports (a schedule's run, a hand-off, a decision made outside any conversation). One per agent; POST /threads with home: true returns it. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
seen_through | string or null | How far the person this call acts as (OpenLegion-Subject, or a session's user) has seen this conversation: the time of the newest message they have seen there, as POST /threads/{id}/seen answers it, or of their own newest message there if that is later. RFC 3339 to the second, for display: a message written later in the same second has the same created. Null when they have seen nothing here yet, and when the call names no person (your key with no subject). Each person's own: no one else's mark shows. |
unseen | integer or null | What that person has not seen here: messages newer than their mark, not their own, counted exactly, as GET /agents/summary counts them. 100 means 100 or more. To ask whether anything here is unseen, test unseen > 0, never a time against seen_through. Null when the call names no person. |
GET /threads/{id}/messages
A conversation's history, newest first.
Each message's parts are AI SDK UIMessage parts, as the run streamed them: text, tool parts, data-vault-request, data-artifact (a file the agent delivered), data-refusal, data-model-note (the person's chosen preset did not run) and data-redacted. A message the agent sent while it worked is its own message, before the reply: the run's stream carried it as a data-message part with the same msg_ id. The reply of a run a person stopped has stopped: true, as its stream ended with an abort part. Reverse a page to hydrate useChat, which wants oldest first.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A msg_ id: the page after it (older). | |
ending_before | query | string | A msg_ id: the page before it (newer). | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of messages.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "message" | |
id | string | msg_… |
livemode | boolean | |
created | string | |
thread | string | |
role | one of: user, assistant, system | |
parts | array of object | AI SDK UIMessage parts, as the run streamed them: a reload hydrates useChat with no converter. An assistant message has one tool part per action of its run, before its text: its toolCallId is the action's act_ id, and its input is {} (the input is on GET /actions/{id}). A run stopped by its budget or its workspace ends with a data-refusal part. A reply that did not run on the preset its person chose ends with a data-model-note part. An erased message is one data-redacted part. |
trust | string | The content trust tier: owner, tool_verified or web_low. |
tainted | boolean | True when untrusted content reached the run that wrote this message: a web page, a web_low event or tool result, a recalled note, or untrusted earlier turns. For a tainted assistant message, never render remote images or auto-link to hosts other than yours. |
run | string or null | run_…: the run this message started (user) or came from (assistant). |
trigger | one of: message, schedule, inbound_event, api, resume, handoff, follow_up, other or null | What started the run that wrote this message, as GET /runs names a run's trigger: message for a reply to a person, schedule for a schedule's report, resume, handoff, follow_up and the rest. Null on a person's message, and on one no run wrote. |
schedule | string or null | sch_…: the schedule whose run wrote this message (trigger schedule). Null otherwise. |
stopped | boolean | True for the reply of a run a person stopped before it finished (POST /runs/{id}/cancel): what that run's stream said with its abort part. Draw the reply as stopped, whatever parts it has. False for every other message, including a message the run sent before it was stopped. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /threads/{id}/messages
Send a message; the agent answers in a run.
Returns {message, run}: 201 when the run started, 202 when it is queued (its thread's previous run is still going, or the agent or the workspace is at its limit on runs at once). With ?stream=true the response is the run's Server-Sent Events stream (the AI SDK UI message stream), and its OpenLegion-Run header names the run to re-attach to. Closing the stream never cancels the run. An Idempotency-Key replay answers with the JSON. A message whose run is refused as it starts (402 cap_reached or credits_exhausted) is still written: it stays in the thread unanswered, and its run reads failed. The same Idempotency-Key replays that refusal for 24 hours; to have it answered, send it again with a new key once the limit allows, which writes a second copy.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
stream | query | one of: true, false | true: answer with the run's live stream. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
content | string | yes | What the person said: up to 32000 characters. |
attachments | array of string | Up to 5 files (file_…) from POST /files, uploaded for this thread by the same person and not yet sent. The agent reads each with its files.read_attachment tool. | |
model_tier | one of: background, fast, reasoning, frontier, auto | A model preset for the run that answers this message, and only that run: one of the template's customizable.model_tier.allowed (GET /template_agents), else 409 outside_template_bounds. The run never moves above it. "auto": the run is routed to one of auto_presets (the template must set customizable.model_tier.auto). Absent: the agent's own preset. | |
auto_presets | array of one of: background, fast, reasoning, frontier | With model_tier "auto" only: the presets this run may be routed to, at least two of fast, reasoning and frontier, each in customizable.model_tier.allowed (else 409 outside_template_bounds). Absent: every one of those the template allows. Set it from your plan, never from the browser. |
Returns:
200: With ?stream=true: the run's stream, as GET /runs/{id}/stream answers it (Server-Sent Events, ending with data: [DONE]). The OpenLegion-Run header names the run to re-attach to. An Idempotency-Key replay answers 201 or 202 with the JSON instead.201: The message, and its run (started).202: The message, and its run (queued).400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
message | object | One message in a thread. |
run | object | One unit of an agent's work: what it did after one message, schedule, event or resume, from start to end. |
POST /threads/{id}/seen
Record what a person has seen in a conversation.
Call it when the person has seen the conversation up to a message (the kit's AgentChat does, when it fires onSeen). The mark is that message's own time, and it only moves forward: an older message changes nothing. It is the person's own: no one else's badge changes. Needs a person (OpenLegion-Subject, or a session); a member marks only a conversation they started, and another person's answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | yes | The newest message the person has seen (msg_…), one in this thread. Its own time is recorded, so what arrived after it stays unseen. |
Returns:
200: The person's mark there, and what is still unseen.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "thread_seen" | |
thread | string | thr_… |
seen_through | string | The person's mark after this call: the time of the newest message they have seen there. A mark never moves back. |
unseen | integer | What they still have not seen there, as GET /agents/summary counts it. 100 means 100 or more. |
Runs
GET /runs
List runs, newest first.
A member acting as themselves (OpenLegion-Subject, or a session's user) gets only the runs in the threads they started; owner, admin and your key with no subject get every run. Another person's run answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
agent | query | string | Only this agent's (agt_…). | |
thread | query | string | Only the runs that answer in this thread (thr_…). | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A run_ id: the page after it. | |
ending_before | query | string | A run_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of runs.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "run" | |
id | string | run_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
agent | string | agt_… |
thread | string or null | thr_…: where the run's messages land. A resume run's is the thread of the run that asked for the approval (the agent's home thread when it answers decisions from different threads). |
status | one of: queued, running, completed, failed, cancelled, settling | One of queued, running, completed, failed, cancelled, settling. settling: an action is still finishing after the run ended. |
trigger | one of: message, schedule, inbound_event, api, resume, handoff, follow_up, other | |
cost_micro | integer | What the run was charged for model calls and paid tools, in micro-dollars; until the run ends, what it has spent so far. A run that was answered together with an earlier message reports 0: the charge is on the earliest. |
credits | number | The same charge in credits: cost_micro / 1000 exactly, at most three decimals, so runs add up exactly; GET /usage rounds a window's spend up to a whole credit, and that spend is its runs added up plus any work that belongs to no run (memory upkeep, voice transcription). |
model | string or null | The gateway id of the model on the run's last step, e.g. anthropic/claude-haiku-5.5. A run can move to a stronger model part way through; this is the one it ended on. It names the model each step was sent to: if that provider was down, a listed backup may have answered a step. Null while the run is queued and until its first model call. |
model_name | string or null | What a person reads for model: the vendor's own product name, e.g. Claude Haiku 5.5 (GET /model_presets names each preset's model now). Null when model is, or when it is a model we have no name for. |
model_tier | one of: background, fast, reasoning, frontier or null | The preset the run started on: the one a person picked with the message (model_tier on POST /threads/{id}/messages or POST /agents/{id}/runs), the one Auto chose, else the agent's own. A run on its agent's own preset may move to a stronger one part way through; model names the model it ended on. Null while the run is queued. |
model_choice | one of: agent, person, auto or null | Who chose model_tier. agent: the agent's own preset. person: a preset picked with the message or run. auto: Auto chose it, because the agent is on Auto or the message asked for it (auto says how). Null while the run is queued. |
auto | object or null | How Auto chose model_tier. Null unless model_choice is auto, and on a run routed before Auto among presets was recorded. |
model_requested | object or null | Set when the run did not run on the preset it was meant to: model_tier is the one it ran on instead. A person's pick that reached a run started without it (a resume, a decision's resume, a continuation) can need more than that run was given. model_choice then reads agent, and the reply ends with a data-model-note part for the person. Null on every other run, and while the run is queued. |
started_at | string or null | |
ended_at | string or null | |
error | object or null | Why the run did not succeed: a stable code, the end user's sentence and yours. |
waiting | object or null | Why a queued run has not started yet. Present only while status is queued; null while a queued run is being retried. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /runs/{id}
Read a run.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The run.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "run" | |
id | string | run_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
agent | string | agt_… |
thread | string or null | thr_…: where the run's messages land. A resume run's is the thread of the run that asked for the approval (the agent's home thread when it answers decisions from different threads). |
status | one of: queued, running, completed, failed, cancelled, settling | One of queued, running, completed, failed, cancelled, settling. settling: an action is still finishing after the run ended. |
trigger | one of: message, schedule, inbound_event, api, resume, handoff, follow_up, other | |
cost_micro | integer | What the run was charged for model calls and paid tools, in micro-dollars; until the run ends, what it has spent so far. A run that was answered together with an earlier message reports 0: the charge is on the earliest. |
credits | number | The same charge in credits: cost_micro / 1000 exactly, at most three decimals, so runs add up exactly; GET /usage rounds a window's spend up to a whole credit, and that spend is its runs added up plus any work that belongs to no run (memory upkeep, voice transcription). |
model | string or null | The gateway id of the model on the run's last step, e.g. anthropic/claude-haiku-5.5. A run can move to a stronger model part way through; this is the one it ended on. It names the model each step was sent to: if that provider was down, a listed backup may have answered a step. Null while the run is queued and until its first model call. |
model_name | string or null | What a person reads for model: the vendor's own product name, e.g. Claude Haiku 5.5 (GET /model_presets names each preset's model now). Null when model is, or when it is a model we have no name for. |
model_tier | one of: background, fast, reasoning, frontier or null | The preset the run started on: the one a person picked with the message (model_tier on POST /threads/{id}/messages or POST /agents/{id}/runs), the one Auto chose, else the agent's own. A run on its agent's own preset may move to a stronger one part way through; model names the model it ended on. Null while the run is queued. |
model_choice | one of: agent, person, auto or null | Who chose model_tier. agent: the agent's own preset. person: a preset picked with the message or run. auto: Auto chose it, because the agent is on Auto or the message asked for it (auto says how). Null while the run is queued. |
auto | object or null | How Auto chose model_tier. Null unless model_choice is auto, and on a run routed before Auto among presets was recorded. |
model_requested | object or null | Set when the run did not run on the preset it was meant to: model_tier is the one it ran on instead. A person's pick that reached a run started without it (a resume, a decision's resume, a continuation) can need more than that run was given. model_choice then reads agent, and the reply ends with a data-model-note part for the person. Null on every other run, and while the run is queued. |
started_at | string or null | |
ended_at | string or null | |
error | object or null | Why the run did not succeed: a stable code, the end user's sentence and yours. |
waiting | object or null | Why a queued run has not started yet. Present only while status is queued; null while a queued run is being retried. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
POST /runs/{id}/cancel
Cancel a run.
Stops a run. A queued run is cancelled at once and never starts: 200, status cancelled; its message stays in the thread. A run that has started is asked to stop: 202, and its status does not change yet. The answer the model is writing is cut within about 2 seconds (the run of a message or an inbound event; a run started another way finishes the model call it is making first). A tool call already under way completes, nothing further starts, and what the agent wrote so far stays in the thread. The run then reads cancelled, also when stopped during its last step, its stream ends with an abort part, and run.cancelled fires. A member acting as themselves can stop only a run in a thread they started; another person's run answers as one that does not exist. A run that has ended, or is settling, answers 409 run_not_cancellable. Cancelling a cancelled run returns it unchanged.
Who: An org key, scope messages.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The cancelled run (it was queued, or already cancelled).202: The run, started and asked to stop: it reads cancelled once it has stopped.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "run" | |
id | string | run_… |
livemode | boolean | |
created | string | RFC 3339 UTC. |
agent | string | agt_… |
thread | string or null | thr_…: where the run's messages land. A resume run's is the thread of the run that asked for the approval (the agent's home thread when it answers decisions from different threads). |
status | one of: queued, running, completed, failed, cancelled, settling | One of queued, running, completed, failed, cancelled, settling. settling: an action is still finishing after the run ended. |
trigger | one of: message, schedule, inbound_event, api, resume, handoff, follow_up, other | |
cost_micro | integer | What the run was charged for model calls and paid tools, in micro-dollars; until the run ends, what it has spent so far. A run that was answered together with an earlier message reports 0: the charge is on the earliest. |
credits | number | The same charge in credits: cost_micro / 1000 exactly, at most three decimals, so runs add up exactly; GET /usage rounds a window's spend up to a whole credit, and that spend is its runs added up plus any work that belongs to no run (memory upkeep, voice transcription). |
model | string or null | The gateway id of the model on the run's last step, e.g. anthropic/claude-haiku-5.5. A run can move to a stronger model part way through; this is the one it ended on. It names the model each step was sent to: if that provider was down, a listed backup may have answered a step. Null while the run is queued and until its first model call. |
model_name | string or null | What a person reads for model: the vendor's own product name, e.g. Claude Haiku 5.5 (GET /model_presets names each preset's model now). Null when model is, or when it is a model we have no name for. |
model_tier | one of: background, fast, reasoning, frontier or null | The preset the run started on: the one a person picked with the message (model_tier on POST /threads/{id}/messages or POST /agents/{id}/runs), the one Auto chose, else the agent's own. A run on its agent's own preset may move to a stronger one part way through; model names the model it ended on. Null while the run is queued. |
model_choice | one of: agent, person, auto or null | Who chose model_tier. agent: the agent's own preset. person: a preset picked with the message or run. auto: Auto chose it, because the agent is on Auto or the message asked for it (auto says how). Null while the run is queued. |
auto | object or null | How Auto chose model_tier. Null unless model_choice is auto, and on a run routed before Auto among presets was recorded. |
model_requested | object or null | Set when the run did not run on the preset it was meant to: model_tier is the one it ran on instead. A person's pick that reached a run started without it (a resume, a decision's resume, a continuation) can need more than that run was given. model_choice then reads agent, and the reply ends with a data-model-note part for the person. Null on every other run, and while the run is queued. |
started_at | string or null | |
ended_at | string or null | |
error | object or null | Why the run did not succeed: a stable code, the end user's sentence and yours. |
waiting | object or null | Why a queued run has not started yet. Present only while status is queued; null while a queued run is being retried. |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
GET /runs/{id}/stream
Attach to a run's stream.
Server-Sent Events carrying the AI SDK UI message stream. Replays from the start, or after Last-Event-ID; follows a run live until it ends; ends with data: [DONE]. A run's stream is kept 24 hours after it ends. A run the platform did not stream (a schedule's) is replayed from its messages once it has ended. A queued run opens with a data-queued {position, reason} part: reason is thread_busy, agent_busy, agent_paused or workspace_busy. A queued run that ends without starting (refused when its turn comes, or closed by the 40-minute expiry as run_failed) ends with a data-refusal {code, message} part (cap_reached adds limit {cap, why, resets_at} when it knows which limit), then an error part with the same end-user sentence; a cancelled one ends with abort. A run stopped after it started (POST /runs/{id}/cancel) ends with abort too, after the parts of the step it was on. Every part is in your end user's words, for a key and a session alike: the operator's sentence is the run's error.partner_message.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The AI SDK UI message stream as Server-Sent Events:id: Nanddata: <json part>per part (status parts such as data-queued carry no id), ending withdata: [DONE]. Just before [DONE], a finished run's stream carries an id-less message-metadata part {tainted}: true when untrusted content reached the run, so render the reply as untrusted text. A stream that ends without [DONE] was cut short: re-attach with Last-Event-ID. The OpenLegion-Run header names the run.400:401:402:403:404:409:429:
Actions
GET /actions
List actions, newest first.
A member acting as themselves (OpenLegion-Subject, or a session's user) gets only those of the runs in the threads they started; owner, admin and your key with no subject get every one. Another person's answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
agent | query | string | Only this agent's (agt_…). | |
run | query | string | Only the actions this run asked for (run_…). | |
status | query | one of: requires_approval, approved, executing, completed, failed, rejected, expired | Only actions in this status. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An act_ id: the page after it. | |
ending_before | query | string | An act_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of actions.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "action" | |
id | string | act_… |
livemode | boolean | |
created | string | |
agent | string | |
run | string or null | run_…: the run that asked for it. |
thread | string or null | thr_…: the conversation that run is in, as GET /runs/{id} gives it. Background work (a schedule's run, for one) is in the agent's home conversation; tell it apart by the run's trigger. Null: a run in no conversation (a task an agent handed to another). |
tool | string | |
input | object | The persisted input: what will run, exactly, if it is approved. A value shaped like a credential reads as a [redacted:<shape>] marker here; what runs is the stored value. |
computer_session | string | cps_…: on a browser.act only, the agent's browser session the act is in: the id its data-computer part carries. While a person holds that browser (that part's status is owner_control), hold Approve back: the act would not run under their hands. Absent for every other tool, and when the act names no session. |
status | one of: requires_approval, approved, executing, completed, failed, rejected, expired | |
outcome | one of: succeeded, failed, refused, unknown or null | What it came to, once it is no longer open: succeeded, failed (it ran or was sent and did not work), refused (declined on purpose: by your tool, by policy or by a person; it did not run) or unknown (OpenLegion stopped waiting for a tool that could have acted: check before retrying). Null while it is held, approved or executing. |
error | object or null | Why it failed, was refused or has an unknown outcome. Null when it succeeded or is still open. |
tool_refusal_code | string or null | Your tool's own refusal code (refuse(message, code)), when it refused with one. |
policy | object or null | |
risk | string or null | |
action_hash | string | sha256: over the workspace, agent, tool and input. Send it back with a decision. |
tainted | boolean | True when the run had read untrusted content before asking. |
approval | string or null | apr_…: its newest approval, if it needed one. |
receipt | object or null | |
metadata | object |
GET /actions/{id}
Read an action.
A member acting as themselves (OpenLegion-Subject, or a session's user) gets only those of the runs in the threads they started; owner, admin and your key with no subject get every one. Another person's answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The action.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "action" | |
id | string | act_… |
livemode | boolean | |
created | string | |
agent | string | |
run | string or null | run_…: the run that asked for it. |
thread | string or null | thr_…: the conversation that run is in, as GET /runs/{id} gives it. Background work (a schedule's run, for one) is in the agent's home conversation; tell it apart by the run's trigger. Null: a run in no conversation (a task an agent handed to another). |
tool | string | |
input | object | The persisted input: what will run, exactly, if it is approved. A value shaped like a credential reads as a [redacted:<shape>] marker here; what runs is the stored value. |
computer_session | string | cps_…: on a browser.act only, the agent's browser session the act is in: the id its data-computer part carries. While a person holds that browser (that part's status is owner_control), hold Approve back: the act would not run under their hands. Absent for every other tool, and when the act names no session. |
status | one of: requires_approval, approved, executing, completed, failed, rejected, expired | |
outcome | one of: succeeded, failed, refused, unknown or null | What it came to, once it is no longer open: succeeded, failed (it ran or was sent and did not work), refused (declined on purpose: by your tool, by policy or by a person; it did not run) or unknown (OpenLegion stopped waiting for a tool that could have acted: check before retrying). Null while it is held, approved or executing. |
error | object or null | Why it failed, was refused or has an unknown outcome. Null when it succeeded or is still open. |
tool_refusal_code | string or null | Your tool's own refusal code (refuse(message, code)), when it refused with one. |
policy | object or null | |
risk | string or null | |
action_hash | string | sha256: over the workspace, agent, tool and input. Send it back with a decision. |
tainted | boolean | True when the run had read untrusted content before asking. |
approval | string or null | apr_…: its newest approval, if it needed one. |
receipt | object or null | |
metadata | object |
Approvals
GET /approvals
List approvals, newest first.
A member acting as themselves (OpenLegion-Subject, or a session's user) gets only those of the runs in the threads they started; owner, admin and your key with no subject get every one. Another person's answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope approvals; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
status | query | one of: pending, approved, rejected, expired, all | One of pending, approved, rejected, expired, all. The default is pending: those still waiting on a decision. | |
agent | query | string | Only this agent's (agt_…). | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An apr_ id: the page after it. | |
ending_before | query | string | An apr_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of approvals, each with its action.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "approval" | |
id | string | apr_… |
livemode | boolean | |
created | string | |
agent | string | |
thread | string or null | thr_…: the conversation it was asked in, its action's thread. A schedule's run is in the agent's home conversation. Null: no action, or a run in no conversation (a task an agent handed to another). |
kind | string | irreversible_tool, financial, question, … |
status | one of: pending, approved, rejected, expired | |
title | string or null | |
fields | array of object | The card, as structured fields built from the action's input, never model prose. Every field of the input is here; the up-front ones come first. |
risk | string | |
cost_micro | integer or null | |
expires_at | string or null | |
decided | object or null | |
response | string or null | A question's answer. A note sent with an approve or a reject goes to the agent with the decision and is not kept here. |
action | object or null | |
metadata | object |
GET /approvals/{id}
Read an approval, with its action.
A member acting as themselves (OpenLegion-Subject, or a session's user) gets only those of the runs in the threads they started; owner, admin and your key with no subject get every one. Another person's answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope approvals; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The approval, and whether the person reading it may decide it.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "approval" | |
id | string | apr_… |
livemode | boolean | |
created | string | |
agent | string | |
thread | string or null | thr_…: the conversation it was asked in, its action's thread. A schedule's run is in the agent's home conversation. Null: no action, or a run in no conversation (a task an agent handed to another). |
kind | string | irreversible_tool, financial, question, … |
status | one of: pending, approved, rejected, expired | |
title | string or null | |
fields | array of object | The card, as structured fields built from the action's input, never model prose. Every field of the input is here; the up-front ones come first. |
risk | string | |
cost_micro | integer or null | |
expires_at | string or null | |
decided | object or null | |
response | string or null | A question's answer. A note sent with an approve or a reject goes to the agent with the decision and is not kept here. |
action | object or null | |
metadata | object | |
can_decide | boolean | Whether the person this call acts as may decide it: an owner or admin approves and rejects every approval; a member answers a question, and approves or rejects an approval of an action their own conversation asked for, unless the template keeps that tool's approvals for admins (policy_envelope.tools..approver: admin); without a subject, false. For a subject that has not acted in the workspace yet, the template's default_subject_role. Says nothing about whether it is still open to a decision. |
POST /approvals/{id}/decide
Decide an approval as the acting person.
The decider is the OpenLegion-Subject (or the session's user), under the workspace's role rules: an owner or admin approves and rejects every approval; a member answers a question, and approves or rejects an approval of an action their own conversation asked for, unless the template keeps that tool's approvals for admins (policy_envelope.tools..approver: admin), which is 403 insufficient_role. Without a subject the call is refused (subject_required): the service principal never decides. The action_hash must be the action's, as read; any other value is refused (action_changed) and nothing is decided. The agent resumes the approved work in a new run. A member acting as themselves (OpenLegion-Subject, or a session's user) gets only those of the runs in the threads they started; owner, admin and your key with no subject get every one. Another person's answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope approvals; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
decision | one of: approve, reject, answer | yes | |
action_hash | string or null | The action's action_hash, exactly as read. Null (or left out) for a question, which has no action. | |
answer | string | The answer to a question (decision: answer). With an approve or a reject it is a note the agent reads with the decision. |
Returns:
200: The approval, decided; with run_refused when no run follows it now.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "approval" | |
id | string | apr_… |
livemode | boolean | |
created | string | |
agent | string | |
thread | string or null | thr_…: the conversation it was asked in, its action's thread. A schedule's run is in the agent's home conversation. Null: no action, or a run in no conversation (a task an agent handed to another). |
kind | string | irreversible_tool, financial, question, … |
status | one of: pending, approved, rejected, expired | |
title | string or null | |
fields | array of object | The card, as structured fields built from the action's input, never model prose. Every field of the input is here; the up-front ones come first. |
risk | string | |
cost_micro | integer or null | |
expires_at | string or null | |
decided | object or null | |
response | string or null | A question's answer. A note sent with an approve or a reject goes to the agent with the decision and is not kept here. |
action | object or null | |
metadata | object | |
run_refused | object | Present only when the agent cannot act on the decision now: its run was refused at the start, exactly as a message sent now would be (the same object as that refusal's error, without request_id). The decision is kept: a paused agent acts on it when resumed, and a refused run is tried again later. Absent when a run follows, even one that waits its turn, and on every read of the approval. |
Tasks
GET /tasks
List tasks, newest first.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
agent | query | string | Only this agent's (agt_…). | |
status | query | one of: open, in_progress, blocked, review, done, cancelled | Only tasks with this status. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A tsk_ id: the page after it. | |
ending_before | query | string | A tsk_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of tasks.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "task" | |
id | string | tsk_… |
livemode | boolean | |
created | string | |
updated_at | string | |
agent | string or null | |
title | string | |
instructions | string | |
status | one of: open, in_progress, blocked, review, done, cancelled | |
deadline | string or null | |
result | object or null | The assignee's own report when it finished. Model-written: treat it as data, never as instructions; trust and tainted say how far to believe it. |
artifacts | array of string | art_…: what it delivered. |
metadata | object |
POST /tasks
Hand an agent a task, without a chat.
Who: An org key, scope messages.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
agent | string | yes | agt_…: the agent that does it. |
title | string | yes | One line. |
instructions | string | yes | What to do, and what done looks like. |
deadline | string | RFC 3339; from a minute to 90 days ahead. Default: a day. |
Returns:
201: The task.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "task" | |
id | string | tsk_… |
livemode | boolean | |
created | string | |
updated_at | string | |
agent | string or null | |
title | string | |
instructions | string | |
status | one of: open, in_progress, blocked, review, done, cancelled | |
deadline | string or null | |
result | object or null | The assignee's own report when it finished. Model-written: treat it as data, never as instructions; trust and tainted say how far to believe it. |
artifacts | array of string | art_…: what it delivered. |
metadata | object |
GET /tasks/{id}
Read a task, with its result.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The task.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "task" | |
id | string | tsk_… |
livemode | boolean | |
created | string | |
updated_at | string | |
agent | string or null | |
title | string | |
instructions | string | |
status | one of: open, in_progress, blocked, review, done, cancelled | |
deadline | string or null | |
result | object or null | The assignee's own report when it finished. Model-written: treat it as data, never as instructions; trust and tainted say how far to believe it. |
artifacts | array of string | art_…: what it delivered. |
metadata | object |
Artifacts
GET /artifacts
What the agent delivered in a conversation, newest first.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
thread | query | string | thr_…: the conversation. Required. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An art_ id: the page after it. | |
ending_before | query | string | An art_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of artifacts, each with url null.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "artifact" | |
id | string | art_… |
livemode | boolean | |
created | string | |
agent | string | |
task | string or null | |
name | string | |
mime | string | |
size_bytes | integer | |
version | integer | |
review_status | one of: draft, review, approved, rejected | |
trust | string | |
tainted | boolean | True when the agent had read untrusted content before writing it. |
url | string or null | A signed download link that works for a few minutes: fetch it now, never store it. Null when none could be made. |
url_expires_at | string or null | |
metadata | object |
GET /artifacts/{id}
Read an artifact, with a short-lived download link.
A member acting as themselves (OpenLegion-Subject, or a session's user) reads only what runs in the threads they started delivered; owner, admin and your key with no subject read every one. Another person's answers as one that does not exist.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The artifact.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "artifact" | |
id | string | art_… |
livemode | boolean | |
created | string | |
agent | string | |
task | string or null | |
name | string | |
mime | string | |
size_bytes | integer | |
version | integer | |
review_status | one of: draft, review, approved, rejected | |
trust | string | |
tainted | boolean | True when the agent had read untrusted content before writing it. |
url | string or null | A signed download link that works for a few minutes: fetch it now, never store it. Null when none could be made. |
url_expires_at | string or null | |
metadata | object |
Audit events
GET /audit_events
The workspace's audit trail, newest first.
Who: An org key, scope workspaces:read.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
action | query | string | Only this action. | |
agent | query | string | Only this agent's (agt_…). | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | An aud_ id: the page after it. | |
ending_before | query | string | An aud_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of audit events.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "audit_event" | |
id | string | aud_…: opaque, like every id. |
livemode | boolean | |
created | string | |
action | string | e.g. platform.message_sent, approval.decided, agent.paused, task.created, reach.suppressed. |
actor | object | Who: a user (a person or your service principal: subject null), an agent, or the system. |
via | string or null | org_key or org_session for your own acts; null for the agent's and the system's. |
key | string or null | key_…: the org key behind it. |
session | string or null | ses_…: the session behind it. |
agent | string or null | |
resource | string or null | |
decision | string or null | |
detail | object | |
metadata | object | Always empty: an audit entry takes no metadata. |
Inbound events
POST /inbound_events
Send a fact from your system; the template's triggers decide whether it starts a run.
Returns the inbound_event: 201 when it is new, 200 with the first one when its dedupe_key was sent in the last 30 days (nothing else is written). Its content reaches the agent only as data, never as an instruction; web_low content also taints the run it starts. A run refused at its start (credits, caps) is still 201, with the run failed: GET /runs/{id} says why.
Who: An org key, scope inbound.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
type | string | yes | What happened, e.g. order.shipped. |
data | object | yes | The fact, as a JSON object: up to 32 KiB. |
trust | one of: owner, system, tool_verified, web_low | yes | tool_verified for your own product's data; web_low for text people outside it wrote. owner and system are accepted and capped at tool_verified: a fact is never an instruction. |
dedupe_key | string | yes | Your id for this fact. A repeat within 30 days returns the first one and starts nothing. |
agent | string | agt_…: route it to this agent only. |
Returns:
200: A repeat of a dedupe_key: the first inbound_event, unchanged.201: The inbound_event, recorded and routed.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "inbound_event" | |
id | string | ine_… |
livemode | boolean | |
created | string | |
type | string | |
trust | one of: tool_verified, web_low | The trust the fact carries: what you declared, capped at tool_verified. |
tainted | boolean | True for web_low: the run it starts may not pass its content to a tool that reaches outside. |
dedupe_key | string | |
agent | string | agt_…: the agent it was routed to. |
thread | string | thr_…: that agent's inbound thread. |
run | string or null | run_…: the run it started, or null when it started none (see reason). |
reason | one of: no_trigger, agent_paused or null | Why it started no run: no trigger of the template matched (recorded; the agent reads it on its next run), or the agent is paused (kept; its resume delivers it). |
metadata | object |
Vault items
GET /vault_items
List vault items.
Newest first. Never a value. An owner or admin, as a session or a subject; a member lists only an ask's items (ask[thread], ask[message]).
Who: An org key with OpenLegion-Workspace, scope vault; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
name | query | string | One item by its name. | |
kind | query | string | login, api_key or secret. | |
agent | query | string | agt_…: the items this agent may use. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A vlt_ id: the page after it. | |
ending_before | query | string | A vlt_ id: the page before it. | |
ask[thread] | query | string | With ask[message]: only the items that agent message asked for (thr_ id). A member reads these for an ask in a conversation they started; any other is an empty list. | |
ask[message] | query | string | With ask[thread]: the msg_ id of the agent's message that asked. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of vault items.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "vault_item" | |
id | string | vlt_… |
livemode | boolean | |
created | string | |
updated_at | string | |
name | string | |
handle | string | vault://: what an agent calls it by. |
kind | one of: login, api_key, secret | |
label | string | |
origins | array of string | The only pages a login (or a secret) is typed into: exact https origins. |
hosts | array of string | The only hosts an API key (or a secret) is sent to, in a request header: exact names. |
agents | array of string | agt_… ids that may use it; empty: every agent of the workspace. |
secret_fields | array of one of: username, password, totp, value | Which secret fields hold a value. Never a value. |
metadata | object |
POST /vault_items
Save a login, API key or secret.
Seals the value with where it may go: a login's origins, a key's hosts. Agents use it by handle and never see it. secret is write-only. 409 vault_item_exists for a name in use, 409 refusal vault_item_limit_reached at 50 items, 429 vault_writes_exceeded past 60 changes an hour. An owner or admin, as a session or a subject. A member may only save an ask from a conversation they started (ask), never over an item someone else saved: 403 insufficient_role.
Who: An org key with OpenLegion-Workspace, scope vault; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | 1 to 48 characters: a-z, 0-9, - and _. The handle is vault://. |
kind | one of: login, api_key, secret | yes | |
label | string | What a person sees. Defaults to the name. | |
origins | array of string | A login's (or a secret's) https origins, e.g. https://github.com. Exact: no wildcards, no subdomains. | |
hosts | array of string | An API key's (or a secret's) hosts, e.g. api.github.com. Exact: no wildcards. | |
agents | array of string | agt_… ids that may use it; leave out for every agent of the workspace. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. | |
secret | object | yes | Write-only. Never returned, never logged. |
ask | object | Saves what an agent asked for in a conversation, in one call: creates the item, or adds the asked sites to the item of that name and kind. A member may only save an ask made in a conversation they started, with its name, kind and sites, and never over an item someone else saved. A save starts no run: after it, your own chat should send the person's message in that conversation (AgentChat sends "I saved it."), so the agent carries on with the item. |
Returns:
200: The item (never its value).400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "vault_item" | |
id | string | vlt_… |
livemode | boolean | |
created | string | |
updated_at | string | |
name | string | |
handle | string | vault://: what an agent calls it by. |
kind | one of: login, api_key, secret | |
label | string | |
origins | array of string | The only pages a login (or a secret) is typed into: exact https origins. |
hosts | array of string | The only hosts an API key (or a secret) is sent to, in a request header: exact names. |
agents | array of string | agt_… ids that may use it; empty: every agent of the workspace. |
secret_fields | array of one of: username, password, totp, value | Which secret fields hold a value. Never a value. |
metadata | object |
GET /vault_items/{id}
Retrieve a vault item.
Where it may go and which fields it holds. Never a value. An owner or admin, as a session or a subject; a member is 403 insufficient_role.
Who: An org key with OpenLegion-Workspace, scope vault; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The item.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "vault_item" | |
id | string | vlt_… |
livemode | boolean | |
created | string | |
updated_at | string | |
name | string | |
handle | string | vault://: what an agent calls it by. |
kind | one of: login, api_key, secret | |
label | string | |
origins | array of string | The only pages a login (or a secret) is typed into: exact https origins. |
hosts | array of string | The only hosts an API key (or a secret) is sent to, in a request header: exact names. |
agents | array of string | agt_… ids that may use it; empty: every agent of the workspace. |
secret_fields | array of one of: username, password, totp, value | Which secret fields hold a value. Never a value. |
metadata | object |
POST /vault_items/{id}
Update a vault item.
Change its label, sites, agents, metadata or any secret field. Adding an origin or host it did not have needs the password (or value) sent again in secret, and for a login with an authenticator key, the key too (secret.totp, or null to remove it): 400 vault_secret_required otherwise, naming the field in param. An owner or admin, as a session or a subject; a member is 403 insufficient_role.
Who: An org key with OpenLegion-Workspace, scope vault; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
label | string | ||
origins | array of string | Replaces the list. A new origin needs secret.password (or secret.value) again, and secret.totp too when the login has an authenticator key. | |
hosts | array of string | Replaces the list. A new host needs secret.value again. | |
agents | array of string | Replaces the list; [] for every agent. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. | |
secret | object | Merged by field: what you send replaces that field. Write-only. |
Returns:
200: The item (never its value).400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "vault_item" | |
id | string | vlt_… |
livemode | boolean | |
created | string | |
updated_at | string | |
name | string | |
handle | string | vault://: what an agent calls it by. |
kind | one of: login, api_key, secret | |
label | string | |
origins | array of string | The only pages a login (or a secret) is typed into: exact https origins. |
hosts | array of string | The only hosts an API key (or a secret) is sent to, in a request header: exact names. |
agents | array of string | agt_… ids that may use it; empty: every agent of the workspace. |
secret_fields | array of one of: username, password, totp, value | Which secret fields hold a value. Never a value. |
metadata | object |
DELETE /vault_items/{id}
Delete a vault item.
Its value is destroyed; an agent naming its handle is refused from then on. An owner or admin, as a session or a subject; a member is 403 insufficient_role.
Who: An org key with OpenLegion-Workspace, scope vault; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: Deleted.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "vault_item" | |
id | string | |
deleted | true |
Model keys
GET /model_keys
Read the workspace's model key.
Whether the workspace may use a person's own model key (allowed), and the key saved, if any: its vendor and last four characters, never the key. An owner or admin, as a session or a subject; a member is 403 insufficient_role.
Who: An org key with OpenLegion-Workspace, scope vault; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of the workspace's model keys (at most one), and allowed.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | At most one: saving another vendor's key replaces it. |
has_more | boolean | |
url | string | |
allowed | boolean | model_keys_allowed: the workspace's agents may run on a saved key. Here so a page with no key saved knows whether to offer the form. |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "model_key" | |
vendor | one of: anthropic, openai | |
kind | "api_key" | |
tail | string or null | The key's last four characters, e.g. …x9Qa. Never the key. |
created | string | When this key was saved. |
checked_at | string or null | When the vendor last accepted it. |
in_use | boolean | The workspace's agents run on it now: model_keys_allowed is on. |
POST /model_keys
Save a person's own Anthropic or OpenAI key.
Checks the key with the vendor (its models list; no tokens), then saves it. The workspace's agents then run on it, directly with the vendor, and never fall back to OpenLegion's models. One key per workspace: saving another vendor's key replaces the current one (replaced). 409 refusal model_keys_not_allowed while model_keys_allowed is off; 400 model_key_malformed for a key that isn't one or is the other vendor's (nothing is sent to the vendor); 400 model_key_invalid when the vendor refused it; 400 model_key_model_missing when it can't use a model this workspace's agents run on; 503 model_key_unchecked when the vendor didn't answer; 429 model_key_checks_exceeded past 10 checks an hour. An owner or admin, as a session or a subject; a member is 403 insufficient_role.
Who: An org key with OpenLegion-Workspace, scope vault; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
vendor | one of: anthropic, openai | yes | anthropic or openai. |
key | string | yes | The API key, without the spaces around it. Write-only: never returned, never logged. |
Returns:
200: The saved key (never the key itself).400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "model_key" | |
vendor | one of: anthropic, openai | |
kind | "api_key" | |
tail | string or null | The key's last four characters, e.g. …x9Qa. Never the key. |
created | string | When this key was saved. |
checked_at | string or null | When the vendor last accepted it. |
in_use | boolean | The workspace's agents run on it now: model_keys_allowed is on. |
replaced | object or null | The other vendor's key this one replaced, or null. |
DELETE /model_keys/{vendor}
Remove the workspace's model key.
The key is destroyed. From the next run the workspace's agents run on OpenLegion's models again; a run going on this key when it is removed stops with model_key_missing. Allowed with model_keys_allowed on or off. An owner or admin, as a session or a subject; a member is 403 insufficient_role.
Who: An org key with OpenLegion-Workspace, scope vault; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
vendor | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: Removed.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "model_key" | |
vendor | one of: anthropic, openai | |
deleted | true |
Model presets
GET /model_presets
List the model each preset runs on.
Each model preset (background, fast, reasoning, frontier) and the model a run on it uses now, on this workspace: its id, its name as a person reads it, and its vendor. On a workspace whose agents run on a person's own model key (key: own), each preset is that vendor's model for it. Show these names beside the presets a person may pick (GET /template_agents); never write one down, since the mapping changes.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The four presets, in order.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "model_preset" | |
id | one of: background, fast, reasoning, frontier | The preset: the value of model_tier everywhere it is taken. |
model | object | The model a run on this preset uses now, on this workspace. |
key | one of: openlegion, own | openlegion: our models, billed in credits. own: a person's own model key (GET /model_keys); the model is that vendor's for the preset. |
Connections
GET /connections
List connections.
Newest first. Without status, the connections that are not revoked; status=revoked lists the history.
Who: An org key with OpenLegion-Workspace, scope connections; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
app | query | string | One app's connection, e.g. google. | |
status | query | string | active, needs_reauth or revoked. | |
agent | query | string | agt_…: the connections this agent may use. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A cxn_ id: the page after it. | |
ending_before | query | string | A cxn_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of connections.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "connection" | |
id | string | cxn_… |
livemode | boolean | |
created | string | |
updated_at | string | |
app | string | The catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom). |
source | one of: native, vendor_mcp, piece, custom | custom: an MCP server your user added by its address. OpenLegion has not checked it. |
account | object | |
status | one of: active, needs_reauth, revoked | active, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked. |
agents | array of string or null | agt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows. |
connected_by | string or null | The subject who connected it, or null: your server, or a subject since erased. |
last_used_at | string or null | |
revoked_at | string or null | |
tools | array of object | The tools this connection gives the agents it grants, now, by name (at most 100). Empty when it is revoked, or when the vendor's tools changed since it was connected (connect it again). |
server | object or null | For a custom connection only: the server it calls. null for every other source. |
metadata | object |
GET /connections/apps
List the apps this workspace's people may connect.
The catalog entries of the apps the workspace's template version lists in its apps, in name order, whatever their status: connect only those with status available. Empty when the version lists none. custom_servers says whether the workspace's people may add MCP servers by their address, and how many they have.
Who: An org key with OpenLegion-Workspace, scope connections; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of catalog entries.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string | |
custom_servers | object or null | The servers the workspace's people have added by their address (POST /connect_sessions with server), and the most allowed. Null when the version doesn't list {"app": "custom"} in its apps: no server can be added. POST /connect_sessions still decides: at the most it refuses with 409 custom_server_limit_reached. |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "catalog_entry" | |
id | string | The app: what a connection's app and a connect session's app name. |
name | string | |
description | string | One line, OpenLegion's words. |
categories | array of string | |
logo | string or null | A copy OpenLegion hosts, or null: render the name's initial. |
source | one of: vendor_mcp, native, piece | vendor_mcp: the vendor's own MCP server. native: OpenLegion's own tools. piece: OpenLegion's runner. |
status | one of: available, needs_oauth_app | available: your users can connect it. needs_oauth_app: the vendor's server admits only a registered OAuth app, and OpenLegion has none for it yet. |
auth | object | |
setup | string or null | What has to happen before the first connection can work, or null. |
tools | array of object or null | null: the vendor's server lists its tools once an account is connected, and none of them can be allowed by a template. For a vendor server, the tools OpenLegion has reviewed; a review lapses for a tool whose input schema the vendor changes, which then needs a person's approval again. |
GET /connections/{id}
Retrieve a connection.
Which account, its status and which agents may use it. Never a token or key. A revoked connection is still read here.
Who: An org key with OpenLegion-Workspace, scope connections; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The connection.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connection" | |
id | string | cxn_… |
livemode | boolean | |
created | string | |
updated_at | string | |
app | string | The catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom). |
source | one of: native, vendor_mcp, piece, custom | custom: an MCP server your user added by its address. OpenLegion has not checked it. |
account | object | |
status | one of: active, needs_reauth, revoked | active, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked. |
agents | array of string or null | agt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows. |
connected_by | string or null | The subject who connected it, or null: your server, or a subject since erased. |
last_used_at | string or null | |
revoked_at | string or null | |
tools | array of object | The tools this connection gives the agents it grants, now, by name (at most 100). Empty when it is revoked, or when the vendor's tools changed since it was connected (connect it again). |
server | object or null | For a custom connection only: the server it calls. null for every other source. |
metadata | object |
POST /connections/{id}
Update a connection.
Choose which agents may use it (agents replaces the list; null gives it back to every agent the template allows) or change its metadata. Writes connection.updated when agents changes. 409 connection_revoked for a revoked connection: connect the account again. A session needs the owner or admin role.
Who: An org key with OpenLegion-Workspace, scope connections; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
agents | array of string or null | Replaces the list: agt_… ids of this workspace. null: every agent the template allows for the app. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Returns:
200: The connection.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connection" | |
id | string | cxn_… |
livemode | boolean | |
created | string | |
updated_at | string | |
app | string | The catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom). |
source | one of: native, vendor_mcp, piece, custom | custom: an MCP server your user added by its address. OpenLegion has not checked it. |
account | object | |
status | one of: active, needs_reauth, revoked | active, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked. |
agents | array of string or null | agt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows. |
connected_by | string or null | The subject who connected it, or null: your server, or a subject since erased. |
last_used_at | string or null | |
revoked_at | string or null | |
tools | array of object | The tools this connection gives the agents it grants, now, by name (at most 100). Empty when it is revoked, or when the vendor's tools changed since it was connected (connect it again). |
server | object or null | For a custom connection only: the server it calls. null for every other source. |
metadata | object |
DELETE /connections/{id}
Disconnect a connection.
From now on no agent can use the account. Its sealed token or key is destroyed. Its token is also revoked at the vendor where the vendor allows it; for an MCP server that signs in with OAuth, that is one best-effort call to its authorization server's revocation endpoint when it publishes one, which never delays or blocks the disconnect. Writes connection.revoked. The connection stays readable as history with status revoked; a second DELETE answers it again and retries the cleanup. A member may disconnect one they connected; another person's needs the owner or admin role (403 insufficient_role).
Who: An org key with OpenLegion-Workspace, scope connections; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The revoked connection.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connection" | |
id | string | cxn_… |
livemode | boolean | |
created | string | |
updated_at | string | |
app | string | The catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom). |
source | one of: native, vendor_mcp, piece, custom | custom: an MCP server your user added by its address. OpenLegion has not checked it. |
account | object | |
status | one of: active, needs_reauth, revoked | active, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked. |
agents | array of string or null | agt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows. |
connected_by | string or null | The subject who connected it, or null: your server, or a subject since erased. |
last_used_at | string or null | |
revoked_at | string or null | |
tools | array of object | The tools this connection gives the agents it grants, now, by name (at most 100). Empty when it is revoked, or when the vendor's tools changed since it was connected (connect it again). |
server | object or null | For a custom connection only: the server it calls. null for every other source. |
metadata | object | |
deleted | true |
POST /connections/{id}/expire
Make a test connection expire.
Test mode only. The connection's sign-in expires as if the app had refused to refresh it: it reads needs_reauth, connection.needs_reauth is sent, and the chat shows its Reconnect card. Reconnecting works as it does after a real expiry. A connection that uses a key or no sign-in has nothing to expire.
Who: An org key, scope connections.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The connection, reading needs_reauth.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connection" | |
id | string | cxn_… |
livemode | boolean | |
created | string | |
updated_at | string | |
app | string | The catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom). |
source | one of: native, vendor_mcp, piece, custom | custom: an MCP server your user added by its address. OpenLegion has not checked it. |
account | object | |
status | one of: active, needs_reauth, revoked | active, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked. |
agents | array of string or null | agt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows. |
connected_by | string or null | The subject who connected it, or null: your server, or a subject since erased. |
last_used_at | string or null | |
revoked_at | string or null | |
tools | array of object | The tools this connection gives the agents it grants, now, by name (at most 100). Empty when it is revoked, or when the vendor's tools changed since it was connected (connect it again). |
server | object or null | For a custom connection only: the server it calls. null for every other source. |
metadata | object |
Connect sessions
POST /connect_sessions
Create a connect session.
Opens OpenLegion's hosted page, in your brand, for your user to connect one app, or one MCP server they name by its address, to this workspace. Send them to url; they come back to return_url with connect_session and status. An app with no sign-in is connected at once: status completed, no url. A server named by its address is never connected at once: the page tells your user it hasn't been checked first. 400 parameter_invalid when return_url is not on your registered return origins, when both or neither of app and server are given, or when server.url is not a public https address; 400 app_not_enabled when the workspace's template version does not list the app (custom, for a server) in its apps; 409 custom_server_limit_reached when the workspace already has 10 servers added by their address. Any member may connect an app; replacing an account someone else connected needs an owner or admin (403 insufficient_role).
Who: An org key with OpenLegion-Workspace, scope connections; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
app | string | The catalog app (GET /connector_catalog), or a custom connection's own app (custom-) to connect that server again. Exactly one of app and server. | |
server | object | An MCP server your user names by its address, instead of a catalog app. Needs custom in the workspace's template version's apps. Exactly one of app and server. | |
return_url | string | yes | Where to send your user back: on one of your registered return origins (POST /connect_settings), exactly. |
agents | array of string or null | agt_… ids of this workspace. Omitted or null: every agent the template allows. |
Returns:
200: The connect session.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connect_session" | |
id | string | cxs_… |
livemode | boolean | |
created | string | |
app | string | The catalog app being connected (GET /connector_catalog); custom for a new server named by its address, or custom- for one of the workspace's servers connected again. |
server | object or null | For a server named by its address: which one. null for a catalog app. |
url | string or null | Send your user here while status is open. It works once, for 30 minutes, in the first browser that opens it. null once the session has ended. |
status | one of: open, completed, cancelled, failed, expired | |
failure_code | string or null | Why a failed session failed, in OpenLegion's words: attempt_limit_reached, provider_unavailable, app_check_failed (the app's tools did not pass the checks every connected app's tools pass; trying again does not help), replace_not_allowed (a member's session, and someone else had connected the app meanwhile: replacing their account needs an owner or admin), needs_oauth_app (a server named by its address signs in only with an app registered with it first, which a server added by its address cannot use), custom_server_limit_reached (the workspace reached its limit of servers added by their address meanwhile) or failed. A user who declines on the app's own consent screen ends it cancelled. |
return_url | string | Where your user's browser goes when it ends, with connect_session and status added. |
agents | array of string or null | agt_… ids the connection will be open to; null: every agent the template allows. |
connection | string or null | cxn_…: the connection it made, once completed. |
expires_at | string |
GET /connect_sessions/{id}
Retrieve a connect session.
Its status (open, completed, cancelled, failed or expired), the connection it made, and why it failed.
Who: An org key with OpenLegion-Workspace, scope connections; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The connect session.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "connect_session" | |
id | string | cxs_… |
livemode | boolean | |
created | string | |
app | string | The catalog app being connected (GET /connector_catalog); custom for a new server named by its address, or custom- for one of the workspace's servers connected again. |
server | object or null | For a server named by its address: which one. null for a catalog app. |
url | string or null | Send your user here while status is open. It works once, for 30 minutes, in the first browser that opens it. null once the session has ended. |
status | one of: open, completed, cancelled, failed, expired | |
failure_code | string or null | Why a failed session failed, in OpenLegion's words: attempt_limit_reached, provider_unavailable, app_check_failed (the app's tools did not pass the checks every connected app's tools pass; trying again does not help), replace_not_allowed (a member's session, and someone else had connected the app meanwhile: replacing their account needs an owner or admin), needs_oauth_app (a server named by its address signs in only with an app registered with it first, which a server added by its address cannot use), custom_server_limit_reached (the workspace reached its limit of servers added by their address meanwhile) or failed. A user who declines on the app's own consent screen ends it cancelled. |
return_url | string | Where your user's browser goes when it ends, with connect_session and status added. |
agents | array of string or null | agt_… ids the connection will be open to; null: every agent the template allows. |
connection | string or null | cxn_…: the connection it made, once completed. |
expires_at | string |
Schedules
GET /schedules
List the workspace's schedules.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
agent | query | string | An agt_ id: only its schedules. | |
status | query | one of: active, paused, cancelled, completed, all | active, paused, cancelled, completed, or all. Default: every one but a cancelled one. | |
limit | query | integer | 1–100, default 20. | |
starting_after | query | string | A sch_ id: the page after it. | |
ending_before | query | string | A sch_ id: the page before it. | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: A list of schedules, oldest first.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "list" | |
data | array of object | |
has_more | boolean | |
url | string |
Fields of each item in data:
| Field | Type | Description |
|---|---|---|
object | "schedule" | |
id | string | sch_… |
livemode | boolean | |
created | string | |
agent | string | The agt_ it runs. |
origin | one of: template, api, agent | Who made it: template (the workspace's template; pause and resume only), api (a person, through the API), or agent (the agent itself; no edits). |
template_schedule | string or null | The template's schedule (schedules[].key in the spec) this is, beside the agent's template_agent. Null for a person's or the agent's own. |
cron | string or null | Five-field cron, read in time_zone. Null for a one-shot. |
run_at | string or null | When a one-shot runs (or ran). Null for a cron. |
time_zone | string or null | The zone the cron is read in, recorded when the cron was written. Null for a one-shot. |
next_run_at | string or null | The next run, while active or paused. Null once cancelled or completed, and while stopped_by is set. |
instructions | string or null | What the agent is asked to do on each run. The agent states it when it schedules itself; null only on an older schedule an agent made without it. |
description | string or null | Yours (or the template's). Never shown to the agent. |
status | one of: active, paused, cancelled, completed | completed: a one-shot that has run. |
stopped_by | one of: workspace_archived, workspace_suspended, agent_paused or null | What, outside the schedule, keeps it from firing: its workspace is archived or suspended, or its agent is paused. While it is set the schedule does not run and next_run_at is null; status stays the schedule's own. Restore or resume the workspace, or resume the agent, and it runs again. Null otherwise. |
metadata | object | Yours, on a schedule made through the API. Never shown to the agent. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. |
POST /schedules
Create a person's schedule for an agent.
A repeating schedule (cron, read in the workspace's time zone; its first run is the cron's first time) or a one-shot (run_at, at most 30 days out), inside the template's customizable.schedules: runs no closer than min_interval_seconds, starting within hours and on days. Outside them, or with no customizable.schedules at all, is the refusal outside_template_bounds (409), param cron or run_at. Past customizable.schedules.max schedules on the agent that haven't finished, whoever made them (the agent's own and the template's count too): 409 schedule_limit_reached, its partner_message saying how many. A cron that runs more often than the agent may run in a day is 403 policy_denied. It runs as the person who wrote it: an owner or admin's at owner trust, the org key's at tool_verified. A session, or a subject, needs the owner or admin role: 403 insufficient_role otherwise. Instructions that look like a key or hold one of the workspace's secrets are refused with 400 parameter_invalid.
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
agent | string | yes | The agt_ it runs. |
cron | string | Five-field cron, read in the workspace's time zone. Give cron or run_at. | |
run_at | string | A one-shot's time, RFC 3339. At most 30 days out. | |
instructions | string | yes | What the agent is asked to do on each run, up to 1000 characters. |
description | string | Yours, up to 200 characters. Never shown to the agent. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Returns:
201: The schedule.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "schedule" | |
id | string | sch_… |
livemode | boolean | |
created | string | |
agent | string | The agt_ it runs. |
origin | one of: template, api, agent | Who made it: template (the workspace's template; pause and resume only), api (a person, through the API), or agent (the agent itself; no edits). |
template_schedule | string or null | The template's schedule (schedules[].key in the spec) this is, beside the agent's template_agent. Null for a person's or the agent's own. |
cron | string or null | Five-field cron, read in time_zone. Null for a one-shot. |
run_at | string or null | When a one-shot runs (or ran). Null for a cron. |
time_zone | string or null | The zone the cron is read in, recorded when the cron was written. Null for a one-shot. |
next_run_at | string or null | The next run, while active or paused. Null once cancelled or completed, and while stopped_by is set. |
instructions | string or null | What the agent is asked to do on each run. The agent states it when it schedules itself; null only on an older schedule an agent made without it. |
description | string or null | Yours (or the template's). Never shown to the agent. |
status | one of: active, paused, cancelled, completed | completed: a one-shot that has run. |
stopped_by | one of: workspace_archived, workspace_suspended, agent_paused or null | What, outside the schedule, keeps it from firing: its workspace is archived or suspended, or its agent is paused. While it is set the schedule does not run and next_run_at is null; status stays the schedule's own. Restore or resume the workspace, or resume the agent, and it runs again. Null otherwise. |
metadata | object | Yours, on a schedule made through the API. Never shown to the agent. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. |
GET /schedules/{id}
Read a schedule.
Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The schedule.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "schedule" | |
id | string | sch_… |
livemode | boolean | |
created | string | |
agent | string | The agt_ it runs. |
origin | one of: template, api, agent | Who made it: template (the workspace's template; pause and resume only), api (a person, through the API), or agent (the agent itself; no edits). |
template_schedule | string or null | The template's schedule (schedules[].key in the spec) this is, beside the agent's template_agent. Null for a person's or the agent's own. |
cron | string or null | Five-field cron, read in time_zone. Null for a one-shot. |
run_at | string or null | When a one-shot runs (or ran). Null for a cron. |
time_zone | string or null | The zone the cron is read in, recorded when the cron was written. Null for a one-shot. |
next_run_at | string or null | The next run, while active or paused. Null once cancelled or completed, and while stopped_by is set. |
instructions | string or null | What the agent is asked to do on each run. The agent states it when it schedules itself; null only on an older schedule an agent made without it. |
description | string or null | Yours (or the template's). Never shown to the agent. |
status | one of: active, paused, cancelled, completed | completed: a one-shot that has run. |
stopped_by | one of: workspace_archived, workspace_suspended, agent_paused or null | What, outside the schedule, keeps it from firing: its workspace is archived or suspended, or its agent is paused. While it is set the schedule does not run and next_run_at is null; status stays the schedule's own. Restore or resume the workspace, or resume the agent, and it runs again. Null otherwise. |
metadata | object | Yours, on a schedule made through the API. Never shown to the agent. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. |
POST /schedules/{id}
Update a person's schedule.
Change a schedule made through the API: its cron (a repeating one), its run_at (a one-shot), its instructions, your description and metadata. The same bounds, roles and checks as POST /schedules. A template's schedule is 409 schedule_template_owned and an agent's own is 409 schedule_agent_owned: pause, resume or cancel those instead. A schedule that has finished can't be changed. Sending what is already set changes nothing.
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
cron | string | A repeating schedule's new cron, inside the same bounds. | |
run_at | string | A one-shot's new time. | |
instructions | string | What the agent is asked to do on each run, up to 1000 characters. | |
description | string or null | null clears it. | |
metadata | object | Your own key-value map: up to 50 keys, 40-character keys, 500-character values. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. Never put secrets or sensitive personal data in it. |
Returns:
200: The schedule, changed.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "schedule" | |
id | string | sch_… |
livemode | boolean | |
created | string | |
agent | string | The agt_ it runs. |
origin | one of: template, api, agent | Who made it: template (the workspace's template; pause and resume only), api (a person, through the API), or agent (the agent itself; no edits). |
template_schedule | string or null | The template's schedule (schedules[].key in the spec) this is, beside the agent's template_agent. Null for a person's or the agent's own. |
cron | string or null | Five-field cron, read in time_zone. Null for a one-shot. |
run_at | string or null | When a one-shot runs (or ran). Null for a cron. |
time_zone | string or null | The zone the cron is read in, recorded when the cron was written. Null for a one-shot. |
next_run_at | string or null | The next run, while active or paused. Null once cancelled or completed, and while stopped_by is set. |
instructions | string or null | What the agent is asked to do on each run. The agent states it when it schedules itself; null only on an older schedule an agent made without it. |
description | string or null | Yours (or the template's). Never shown to the agent. |
status | one of: active, paused, cancelled, completed | completed: a one-shot that has run. |
stopped_by | one of: workspace_archived, workspace_suspended, agent_paused or null | What, outside the schedule, keeps it from firing: its workspace is archived or suspended, or its agent is paused. While it is set the schedule does not run and next_run_at is null; status stays the schedule's own. Restore or resume the workspace, or resume the agent, and it runs again. Null otherwise. |
metadata | object | Yours, on a schedule made through the API. Never shown to the agent. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. |
DELETE /schedules/{id}
Cancel a schedule.
It never runs again, and is answered with status cancelled; it stays readable. A template's schedule can't be cancelled (409 schedule_template_owned): pause it, or publish a version without it. Cancelling a cancelled schedule returns it unchanged. Same roles as POST /schedules.
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The schedule, cancelled.400:401:402:403:404:409:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "schedule" | |
id | string | sch_… |
livemode | boolean | |
created | string | |
agent | string | The agt_ it runs. |
origin | one of: template, api, agent | Who made it: template (the workspace's template; pause and resume only), api (a person, through the API), or agent (the agent itself; no edits). |
template_schedule | string or null | The template's schedule (schedules[].key in the spec) this is, beside the agent's template_agent. Null for a person's or the agent's own. |
cron | string or null | Five-field cron, read in time_zone. Null for a one-shot. |
run_at | string or null | When a one-shot runs (or ran). Null for a cron. |
time_zone | string or null | The zone the cron is read in, recorded when the cron was written. Null for a one-shot. |
next_run_at | string or null | The next run, while active or paused. Null once cancelled or completed, and while stopped_by is set. |
instructions | string or null | What the agent is asked to do on each run. The agent states it when it schedules itself; null only on an older schedule an agent made without it. |
description | string or null | Yours (or the template's). Never shown to the agent. |
status | one of: active, paused, cancelled, completed | completed: a one-shot that has run. |
stopped_by | one of: workspace_archived, workspace_suspended, agent_paused or null | What, outside the schedule, keeps it from firing: its workspace is archived or suspended, or its agent is paused. While it is set the schedule does not run and next_run_at is null; status stays the schedule's own. Restore or resume the workspace, or resume the agent, and it runs again. Null otherwise. |
metadata | object | Yours, on a schedule made through the API. Never shown to the agent. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. |
POST /schedules/{id}/pause
Pause a schedule.
It stops firing until resumed; any schedule may be paused, a template's included (a re-pin or promote keeps the pause). Pausing a paused schedule returns it unchanged. One that is firing right now, or has finished, is 409. Same roles as POST /schedules.
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The schedule, paused.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "schedule" | |
id | string | sch_… |
livemode | boolean | |
created | string | |
agent | string | The agt_ it runs. |
origin | one of: template, api, agent | Who made it: template (the workspace's template; pause and resume only), api (a person, through the API), or agent (the agent itself; no edits). |
template_schedule | string or null | The template's schedule (schedules[].key in the spec) this is, beside the agent's template_agent. Null for a person's or the agent's own. |
cron | string or null | Five-field cron, read in time_zone. Null for a one-shot. |
run_at | string or null | When a one-shot runs (or ran). Null for a cron. |
time_zone | string or null | The zone the cron is read in, recorded when the cron was written. Null for a one-shot. |
next_run_at | string or null | The next run, while active or paused. Null once cancelled or completed, and while stopped_by is set. |
instructions | string or null | What the agent is asked to do on each run. The agent states it when it schedules itself; null only on an older schedule an agent made without it. |
description | string or null | Yours (or the template's). Never shown to the agent. |
status | one of: active, paused, cancelled, completed | completed: a one-shot that has run. |
stopped_by | one of: workspace_archived, workspace_suspended, agent_paused or null | What, outside the schedule, keeps it from firing: its workspace is archived or suspended, or its agent is paused. While it is set the schedule does not run and next_run_at is null; status stays the schedule's own. Restore or resume the workspace, or resume the agent, and it runs again. Null otherwise. |
metadata | object | Yours, on a schedule made through the API. Never shown to the agent. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. |
POST /schedules/{id}/resume
Resume a paused schedule.
It runs again from its next time, at the earliest a minute from now; runs it missed while paused are not made up. Resuming an active schedule returns it unchanged; a finished one is 409. Same roles as POST /schedules.
Who: An org key with OpenLegion-Workspace, scope workspaces:write; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
200: The schedule, active.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "schedule" | |
id | string | sch_… |
livemode | boolean | |
created | string | |
agent | string | The agt_ it runs. |
origin | one of: template, api, agent | Who made it: template (the workspace's template; pause and resume only), api (a person, through the API), or agent (the agent itself; no edits). |
template_schedule | string or null | The template's schedule (schedules[].key in the spec) this is, beside the agent's template_agent. Null for a person's or the agent's own. |
cron | string or null | Five-field cron, read in time_zone. Null for a one-shot. |
run_at | string or null | When a one-shot runs (or ran). Null for a cron. |
time_zone | string or null | The zone the cron is read in, recorded when the cron was written. Null for a one-shot. |
next_run_at | string or null | The next run, while active or paused. Null once cancelled or completed, and while stopped_by is set. |
instructions | string or null | What the agent is asked to do on each run. The agent states it when it schedules itself; null only on an older schedule an agent made without it. |
description | string or null | Yours (or the template's). Never shown to the agent. |
status | one of: active, paused, cancelled, completed | completed: a one-shot that has run. |
stopped_by | one of: workspace_archived, workspace_suspended, agent_paused or null | What, outside the schedule, keeps it from firing: its workspace is archived or suspended, or its agent is paused. While it is set the schedule does not run and next_run_at is null; status stays the schedule's own. Restore or resume the workspace, or resume the agent, and it runs again. Null otherwise. |
metadata | object | Yours, on a schedule made through the API. Never shown to the agent. Updating it merges by key: a key you send is set, a key you send as "" or null is removed, and keys you leave out stay. |
Files
POST /files
Upload a file to attach to a message.
The body is the file's bytes, at most 4 MB. Attach an image (PNG, JPEG, WebP or GIF), a PDF, or a text file (plain text, Markdown, CSV or JSON). The type is read from the bytes. Send it with POST /threads/{id}/messages {attachments: ["file_…"]} in the same thread, as the same person. The file exists once its bytes are stored: a retry with the same Idempotency-Key while they are being stored is 409 idempotency_in_flight, and after a 500 it uploads the file again.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
thread | query | string | thr_…: the thread the file will be sent in. | |
name | query | string | The file's name, as the person sees it (1 to 200 characters). | |
Content-Type | header | string | yes | The file's type, e.g. application/pdf or text/csv. |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Returns:
201: The file, ready to send.400:401:402:403:404:409:422:429:
Fields of the 201 answer:
| Field | Type | Description |
|---|---|---|
object | "file" | |
id | string | file_… |
livemode | boolean | |
created | string | |
thread | string | thr_…: the thread it was uploaded for. It can only be sent there. |
name | string | |
mime | string | The type read from the file's bytes. |
size_bytes | integer | |
message | string or null | msg_…: the message that sent it, or null until one does. |
Computer sessions
POST /computer_sessions/{id}/viewer
Watch or take over the agent's browser.
A token for one person to watch the agent's browser (control: false) or take it over (control: true), with . The person is named by OpenLegion-Subject or is a session's user; your key with no subject is 400 subject_required. In a conversation someone started, only that user may: no role sees another person's. A conversation nobody started (the agent's home conversation, where a schedule's run reports, or one your key made with no subject) is the workspace's: its owners and admins may, a member may not. Everything else, and a session that does not exist, is 404. Create the conversation for your user (POST /threads with their OpenLegion-Subject) and that user can watch. A session that has ended is 410 computer_session_ended. 409 resource_conflict when the session's state changed while the token was being made (it was parked, given back or taken): retry, and the answer reads it as it now is. When the browser does not answer in time it is 500 internal_error; retrying is safe. 400 parameter_invalid when origin is not one of your registered return origins. Every request mints a new token: a token is never stored, so an Idempotency-Key is checked but never replays one.
Who: An org key with OpenLegion-Workspace, scope messages; or a session token.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes | |
OpenLegion-Workspace | header | string | The workspace (ws_…). Required with an org key; a session names its own. | |
OpenLegion-Subject | header | string | Your user's id, to act as them (the act_as scope). Org key only. | |
OpenLegion-Subject-Name | header | string | That user's display name, percent-encoded UTF-8 (encodeURIComponent): 1 to 120 characters once decoded and trimmed. Only beside OpenLegion-Subject. Kept when it differs from the name kept, on a call that is not a GET; leave it out to keep the name. | |
OpenLegion-Subject-Name-Clear | header | one of: true | Send true to forget that user's display name. Only with OpenLegion-Subject, and never with OpenLegion-Subject-Name. It takes effect on any call except a GET. |
Body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
origin | string | yes | The page that will show the viewer: exactly one of your organization's return origins (POST /connect_settings); test mode also allows http://localhost. |
control | boolean | true to let the person take over (a control token). Default false: watch only. |
Returns:
200: The viewer's URL and token.400:401:402:403:404:409:422:429:
Fields of the 200 answer:
| Field | Type | Description |
|---|---|---|
object | "computer_viewer" | |
url | string | The session's base on OpenLegion's viewer. appends /view, /control and /input. |
token | string | For the Authorization header, never a URL. A view token works once, within 60 seconds; a control token up to 20 minutes, never past the session's deadline. |
control | boolean | true: the token can take over (control). false: it can only watch. |
expires_at | string |