OpenLegion · Docsllms.txt
Docs pages

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.

ParameterInTypeRequiredDescription
external_refquerystringExactly this external_ref.
statusqueryone of: active, suspended, archivedactive, suspended or archived.
templatequerystringA template slug: workspaces tracking it or pinned to any of its versions.
created[gte]querystringRFC 3339: created at or after.
created[lt]querystringRFC 3339: created before.
limitqueryinteger1–100, default 20.
starting_afterquerystringA ws_ id: the page after it.
ending_beforequerystringA ws_ id: the page before it.

Returns:

  • 200: A list of workspaces.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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):

FieldTypeRequiredDescription
external_refstringyesYour customer id. Never a login, email or handle.
namestringyes
templatestringyes"slug" tracks the promoted version; "slug@N" pins version N.
time_zonestringIANA, e.g. "Europe/London". Default UTC.
metadataobjectYour 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.
limitsobjectThe 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:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The workspace.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Body (JSON):

FieldTypeRequiredDescription
namestring
time_zonestringIANA, e.g. "Europe/London". Default UTC.
metadataobjectMerged into the stored map; a key set to "" is removed.
templatestring"slug" tracks the promoted version; "slug@N" pins version N.
limitsanyRefused here: set limits with POST /workspaces/{id}/limits.
model_keys_allowedbooleanLet 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:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 202: Erasing.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 202 answer:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
external_refstring or nullThe external_ref it had. It is free for a new workspace from the moment of the DELETE.
status"deleted"
deletedtrue
createdstring or null
erased_atstring or nullWhen the erase finished: null in the DELETE's answer, set in workspace.erased.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The workspace.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The workspace.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The workspace.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The workspace.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Body (JSON):

FieldTypeRequiredDescription
period_credit_capinteger or nullyesCredits per period. null takes the plan's ceiling (there is no unlimited).
daily_credit_capinteger or nullCredits per UTC day. null or absent: no daily cap below the plan's ceiling.
cap_modeone of: hard, softhard (default) refuses at the cap; soft allows soft_overage_pct more and reports it as overage.
soft_overage_pctintegerSoft caps only, within the plan's maximum.
period_anchorstringRFC 3339. The period renews monthly from it; short months clamp to their last day. Default: the workspace's creation time.
period_restartbooleantrue: 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:

FieldTypeDescription
object"workspace"
idstringws_…
livemodeboolean
createdstringRFC 3339 UTC.
external_refstringYour customer id: unique per org and mode.
namestring
statusone of: active, suspended, archived
templatestring or null"slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version this workspace's agents run now.
time_zonestringIANA. Template schedules run in it.
active_runsinteger
limitsobject or null
usage_periodobject or null
model_keys_allowedbooleanA person may save their own Anthropic or OpenAI key, and the workspace's agents then run on it (GET /model_keys).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
limitqueryinteger1–100, default 20.

Returns:

  • 200: A list of credit grants.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"credit_grant"
idstringcgr_…
livemodeboolean
createdstringRFC 3339 UTC.
workspacestringws_…
creditsinteger
credits_remainingintegerWhat is left now, after this period's live overage (rounded down).
credits_remaining_microinteger
expires_atstring or null
statusone of: active, expired, returned
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Body (JSON):

FieldTypeRequiredDescription
creditsintegeryesCredits to move from the org pool into the workspace.
expires_atstringRFC 3339. What is left then returns to the pool. Absent: never expires.
metadataobjectYour 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:

FieldTypeDescription
object"credit_grant"
idstringcgr_…
livemodeboolean
createdstringRFC 3339 UTC.
workspacestringws_…
creditsinteger
credits_remainingintegerWhat is left now, after this period's live overage (rounded down).
credits_remaining_microinteger
expires_atstring or null
statusone of: active, expired, returned
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
limitqueryinteger1–100, default 20.

Returns:

  • 200: A list of exports.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"export"
idstringexp_…
livemodeboolean
createdstringRFC 3339 UTC.
workspacestringws_…
statusone of: pending, building, ready, failed, expired
include_audit_logbooleanWhether 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_bytesinteger or nullThe file's size in bytes, once ready.
urlstring or nullA download link, valid for an hour, minted when you read a ready export. Never in an event.
url_expires_atstring or null
expires_atstring or nullWhen the file is deleted (7 days after it was ready).
failure_codeone of: export_too_large, export_timeout, export_failed or null
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Body (JSON):

FieldTypeRequiredDescription
include_audit_logbooleanInclude 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:

FieldTypeDescription
object"export"
idstringexp_…
livemodeboolean
createdstringRFC 3339 UTC.
workspacestringws_…
statusone of: pending, building, ready, failed, expired
include_audit_logbooleanWhether 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_bytesinteger or nullThe file's size in bytes, once ready.
urlstring or nullA download link, valid for an hour, minted when you read a ready export. Never in an event.
url_expires_atstring or null
expires_atstring or nullWhen the file is deleted (7 days after it was ready).
failure_codeone of: export_too_large, export_timeout, export_failed or null
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
export_idpathstringyes

Returns:

  • 200: The export.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"export"
idstringexp_…
livemodeboolean
createdstringRFC 3339 UTC.
workspacestringws_…
statusone of: pending, building, ready, failed, expired
include_audit_logbooleanWhether 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_bytesinteger or nullThe file's size in bytes, once ready.
urlstring or nullA download link, valid for an hour, minted when you read a ready export. Never in an event.
url_expires_atstring or null
expires_atstring or nullWhen the file is deleted (7 days after it was ready).
failure_codeone of: export_too_large, export_timeout, export_failed or null
metadataobjectYour 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.

ParameterInTypeRequiredDescription
limitqueryinteger1–100, default 20.
starting_afterquerystringA template slug: the page after it.
ending_beforequerystringA template slug: the page before it.

Returns:

  • 200: A list of templates.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"template"
idstringThe template's slug: templates are addressed by it.
livemodeboolean
createdstringRFC 3339 UTC.
slugstring
namestring
promoted_versioninteger or nullWhat a tracking workspace runs.
latest_versioninteger or null
builtinbooleantrue for starter, which OpenLegion seeds into every org.
metadataobjectYour 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):

FieldTypeRequiredDescription
slugstringyesYour handle for the product line, e.g. social-manager.
namestringyes

Returns:

  • 201: The template.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 201 answer:

FieldTypeDescription
object"template"
idstringThe template's slug: templates are addressed by it.
livemodeboolean
createdstringRFC 3339 UTC.
slugstring
namestring
promoted_versioninteger or nullWhat a tracking workspace runs.
latest_versioninteger or null
builtinbooleantrue for starter, which OpenLegion seeds into every org.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
slugpathstringyes
limitqueryinteger1–100, default 20.
starting_afterquerystringA tplv_ id: the page after it.
ending_beforequerystringA tplv_ id: the page before it.

Returns:

  • 200: A list of versions.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"template_version"
idstringtplv_…
livemodeboolean
createdstringRFC 3339 UTC.
templatestringThe template's slug.
versioninteger
specobjectThe spec as stored (see /platform/v1/schemas/template.json).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
slugpathstringyes

Body (JSON):

A TemplateSpec.

Returns:

  • 201: The new version.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 201 answer:

FieldTypeDescription
object"template_version"
idstringtplv_…
livemodeboolean
createdstringRFC 3339 UTC.
templatestringThe template's slug.
versioninteger
specobjectThe spec as stored (see /platform/v1/schemas/template.json).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
slugpathstringyes
versionpathstringyes

Returns:

  • 200: The version.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"template_version"
idstringtplv_…
livemodeboolean
createdstringRFC 3339 UTC.
templatestringThe template's slug.
versioninteger
specobjectThe spec as stored (see /platform/v1/schemas/template.json).
metadataobjectYour 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.

ParameterInTypeRequiredDescription
slugpathstringyes

Body (JSON):

FieldTypeRequiredDescription
versionintegeryes

Returns:

  • 200: The template, now promoted.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"template"
idstringThe template's slug: templates are addressed by it.
livemodeboolean
createdstringRFC 3339 UTC.
slugstring
namestring
promoted_versioninteger or nullWhat a tracking workspace runs.
latest_versioninteger or null
builtinbooleantrue for starter, which OpenLegion seeds into every org.
metadataobjectYour 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_movedinteger

Connectors

GET /connectors

List connectors, newest first.

Who: An org key, scope connectors.

ParameterInTypeRequiredDescription
limitqueryinteger1–100, default 20.
starting_afterquerystringA connector id: the page after it.

Returns:

  • 200: A list of connectors.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"connector"
idstringcon_…
livemodeboolean
createdstringRFC 3339 UTC.
namestring
slugstring
urlstring or nullYour MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this connector now, or null.
authobject
header_namesarray of stringStatic extra headers. Names only; values are never returned.
statusone of: active, disabled
pinned_atstring or nullNull until the first pin.
last_testobject or null
toolsarray of object
metadataobject

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):

FieldTypeRequiredDescription
type"mcp"yesv1.0: an MCP server.
urlstringYour MCP endpoint. https in test mode too. Required unless transport is dev, which takes none.
transportone of: https, devhttps (the default): OpenLegion calls url. dev, test mode only: reached through your dev session (npx openlegion dev), with no url and no headers.
authobjectyesv1.0: ol_signed.
namestringyes
slugstringNames the tools: mcp... ^[a-z][a-z0-9]{1,15}$. Derived from name when left out.
headersobjectStatic extra headers, e.g. x-vercel-protection-bypass. At most 8.

Returns:

  • 201: Created. secret is shown this once.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 201 answer:

FieldTypeDescription
object"connector"
idstringcon_…
livemodeboolean
createdstringRFC 3339 UTC.
namestring
slugstring
urlstring or nullYour MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this connector now, or null.
authobject
header_namesarray of stringStatic extra headers. Names only; values are never returned.
statusone of: active, disabled
pinned_atstring or nullNull until the first pin.
last_testobject or null
toolsarray of object
metadataobject
secretstring or nullolcs_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_errorobject or null

GET /connectors/{id}

Retrieve a connector and its pinned tools.

Who: An org key, scope connectors.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The connector.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"connector"
idstringcon_…
livemodeboolean
createdstringRFC 3339 UTC.
namestring
slugstring
urlstring or nullYour MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this connector now, or null.
authobject
header_namesarray of stringStatic extra headers. Names only; values are never returned.
statusone of: active, disabled
pinned_atstring or nullNull until the first pin.
last_testobject or null
toolsarray of object
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes

Body (JSON):

FieldTypeRequiredDescription
dry_runbooleanReturn 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:

FieldTypeDescription
object"connector"
idstringcon_…
livemodeboolean
createdstringRFC 3339 UTC.
namestring
slugstring
urlstring or nullYour MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this connector now, or null.
authobject
header_namesarray of stringStatic extra headers. Names only; values are never returned.
statusone of: active, disabled
pinned_atstring or nullNull until the first pin.
last_testobject or null
toolsarray of object
metadataobject
diffobject
appliedboolean

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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The test result.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"connector_test"
connectorstringcon_…
okbooleanThe signed list worked AND the mis-signed one was refused with 401.
atstringRFC 3339 UTC.
signed_listobject{ok, tools[{name, digest, change, pinnable}], removed, matches_pins}, or {ok: false, code, status}.
unsigned_rejectedboolean
unsigned_statusinteger or nullWhat 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.

ParameterInTypeRequiredDescription
idpathstringyes

Body (JSON):

FieldTypeRequiredDescription
expires_in_secondsintegerHow 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:

FieldTypeDescription
object"connector"
idstringcon_…
livemodeboolean
createdstringRFC 3339 UTC.
namestring
slugstring
urlstring or nullYour MCP endpoint. null for a dev connector: it is reached through your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion calls url. dev (test mode): OpenLegion hands each request to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this connector now, or null.
authobject
header_namesarray of stringStatic extra headers. Names only; values are never returned.
statusone of: active, disabled
pinned_atstring or nullNull until the first pin.
last_testobject or null
toolsarray of object
metadataobject
secretstring or nullolcs_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_atstringRFC 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.

ParameterInTypeRequiredDescription
idpathstringyes
limitqueryinteger1–100, default 20.
starting_afterquerystringAn 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"connector_call"
idstringact_…: the action's id. One call is one action: GET /actions/{id} in its workspace reads the same call.
toolstring
workspacestringws_…
external_refstring or null
runstring or nullrun_…: the run that made the call.
statusone of: requires_approval, approved, executing, completed, failed, rejected, expiredThe action's status, as GET /actions/{id} reads it: a tool that answered with an error is failed.
outcomeone of: succeeded, failed, refused, unknown or nullsucceeded, failed, refused or unknown, as on the action. Null while it is open.
errorobject or nullWhy 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_codestring or nullWhy 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_codestring or nullYour tool's own refusal code: the code in refuse(message, code), when the call ran and your tool refused it. Null otherwise.
latency_msinteger or null
createdstringRFC 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.

ParameterInTypeRequiredDescription
idpathstringyes

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:

FieldTypeDescription
object"template_definition"
connectorstringcon_…: the connector it was pulled through.
slugstringThe template's slug: where npx openlegion templates push publishes it.
namestring
versionobjectThe template version, ready for POST /templates/{slug}/versions: the kit's template.toTemplateSpec for this connector.
toolsarray of objectPer tool, sha256 of what the model reads (title and description) and of its input schema.
hashstringsha256 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:

FieldTypeDescription
object"balance"
livemodeboolean
availableintegerCredits 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_microinteger
pendingintegerCredits on their way: top-ups opened and not yet paid, and bank (ACH) payments received but held until they become spendable.
pending_microinteger
in_workspacesintegerFloat 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_microinteger
credit_limitintegerLive 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.
owedintegerCredits 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_microinteger
currency"credits"
topups_blockedbooleanA 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.

ParameterInTypeRequiredDescription
limitqueryinteger1–100, default 20.
starting_afterquerystringA txn_ id: the page after it.
ending_beforequerystringA 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"balance_transaction"
idstringtxn_…
typeone of: topup, reload, refill, return, grant, grant_return, test_allowance, refund, fee, repayment, adjustmentreload: 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.
amountintegerCredits, signed from the pool's side (a top-up is positive, a refill negative), toward zero.
amount_microinteger
workspacestring or nullws_… for a refill, return, grant or fee (the workspace the month's line is for); null for a top-up.
createdstringRFC 3339 UTC.
descriptionstring

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.

ParameterInTypeRequiredDescription
group_byqueryone of: workspace, agent, template, dayworkspace (default), agent, template or day.
fromquerystringRFC 3339 or YYYY-MM-DD (UTC). Default: the start of this UTC month.
toquerystringRFC 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring
group_byone of: workspace, agent, template, day
fromstringRFC 3339 UTC.
tostringRFC 3339 UTC.

Fields of each item in data:

FieldTypeDescription
object"usage"
keystring or nullws_… · agt_… · a template slug · YYYY-MM-DD (UTC), by group_by. null: spend no agent made.
creditsintegerNet spend, rounded up.
cost_microinteger
runsinteger
actions_completedinteger
approvalsinteger
refusalsinteger
overage_creditsinteger or nullSoft room used past the cap and grants. Workspace grouping only; null otherwise.
run_credits_requiredinteger or nullThe 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.

ParameterInTypeRequiredDescription
monthquerystringYYYY-MM (UTC). Default: this month.

Returns:

  • 200: The bill preview.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"billing_preview"
livemodeboolean
monthstringYYYY-MM (UTC).
statusone of: open, closedopen: computed now from this month's runs. closed: the frozen statement.
computed_atstring
billing_accountstringbac_…
amounts_hiddenbooleantrue: every amount is null (prices are not published yet); counts and ranks are real.
currency"credits"
live_chargesbooleanLive mode: false means nothing is charged for this month, ever. Test mode never charges.
explanationstring
pricingobject
accountobject
active_workspacesinteger
free_workspacesinteger
paying_workspacesinteger
suspended_active_workspacesintegerActive this month and suspended now: a suspended workspace stays on the month it ran in.
runsinteger
overage_runsinteger
feeinteger or nullCredits (rounded up) for the active-workspace fee.
fee_microinteger or null
run_chargeinteger or nullCredits (rounded up) for runs past the included number.
run_charge_microinteger or null
totalinteger or null
total_microinteger or null
projectedobject or nullOpen month: the same workspaces, their runs at the month-to-date rate. Null once closed.
postedinteger or nullClosed: what the pool paid.
posted_microinteger or null
uncoveredinteger or nullClosed: what the pool could not cover.
uncovered_microinteger or null
statement_statusone of: pending, posted, unpaid, waived, not_charged, nothing_due or null
workspaces_urlstring

GET /billing/preview/workspaces

The bill's workspaces by rank, each with why it counts.

Who: An org key, scope usage:read.

ParameterInTypeRequiredDescription
monthquerystringYYYY-MM (UTC). Default: this month.
limitqueryinteger1–100, default 20.
starting_afterquerystringA 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring
monthstring
statusone of: open, closed
amounts_hiddenboolean

Fields of each item in data:

FieldTypeDescription
object"billing_preview_line"
workspacestringws_…
external_refstring or null
workspace_statusstring
rankinteger
bandone of: free, standard, volume, enterprise
whystring
first_runobject
runsinteger
runs_by_triggerobjectRuns this month by what started them, in a run's trigger values.
included_runsinteger
overage_runsinteger
feeinteger or nullCredits (rounded up) for the active-workspace fee.
fee_microinteger or null
run_chargeinteger or nullCredits (rounded up) for runs past the included number.
run_charge_microinteger or null
totalinteger or null
total_microinteger or null
projected_run_charge_microinteger or null
statusone 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:

FieldTypeDescription
object"billing_account"
idstringbac_…
organization_countintegerHow many organizations share it. Never which.
business_verifiedboolean
card_verifiedbooleanA 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_sincestring or nullRFC 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).
creditobjectA 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_allowanceobject
createdstring

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:

FieldTypeDescription
object"auto_reload"
livemodetrue
enabledbooleanOn: a saved card the admin consented to, and a reload is sent when the live pool falls below low_balance.
amountintegerCredits a reload buys, in whole cents (a multiple of 10), within the platform's bounds for a reload.
amount_microinteger
low_balanceintegerThe live pool's low-balance line (the same one org.credits.low uses).
low_balance_microinteger
cardobject or nullThe saved card: never its id or fingerprint. Saved and removed in the org console only.
consented_atstring or nullRFC 3339: when the card was saved, from an admin's card top-up that chose auto-reload.
last_reloadobject or null
live_chargesbooleanfalse: 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):

FieldTypeRequiredDescription
enabledbooleanyestrue needs a card saved with an admin's consent; else 409 no_saved_card.
amountintegeryesCredits 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:

FieldTypeDescription
object"auto_reload"
livemodetrue
enabledbooleanOn: a saved card the admin consented to, and a reload is sent when the live pool falls below low_balance.
amountintegerCredits a reload buys, in whole cents (a multiple of 10), within the platform's bounds for a reload.
amount_microinteger
low_balanceintegerThe live pool's low-balance line (the same one org.credits.low uses).
low_balance_microinteger
cardobject or nullThe saved card: never its id or fingerprint. Saved and removed in the org console only.
consented_atstring or nullRFC 3339: when the card was saved, from an admin's card top-up that chose auto-reload.
last_reloadobject or null
live_chargesbooleanfalse: 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):

FieldTypeRequiredDescription
workspacestringyesThe workspace (ws_…) the session acts in.
subjectstringyesYour user's id. Never an email, a login or a handle.
roleone of: owner, admin, memberyesThe role this user has in the workspace. It is written on every call: the role you last gave it.
display_namestring or nullThe 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_secondsintegerLifetime 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:

FieldTypeDescription
object"session"
idstring
livemodeboolean
createdstring
expires_atstring
workspacestring
subjectstring
roleone of: owner, admin, member
tokenstring or nullSend 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.
metadataobjectAlways 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"webhook_endpoint"
idstringwhe_…
livemodeboolean
createdstring
urlstring or nullWhere deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this endpoint now, or null.
eventsarray of string
descriptionstring or null
statusone of: enabled, disabled
disabled_reasonone of: failures, blocked, manual or nullfailures: 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_atstring or null
last_failure_atstring or null
metadataobjectYour 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):

FieldTypeRequiredDescription
urlstringhttps only, port 443, a public host. Each delivery re-checks where it resolves. Required unless transport is dev, which takes none.
transportone of: https, devhttps (the default): deliveries POST to url. dev, test mode only: each delivery goes to your dev session (npx openlegion dev), with no url.
eventsarray of stringyesThe 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.
descriptionstring
metadataobjectYour 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. secret is shown this once.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 201 answer:

FieldTypeDescription
object"webhook_endpoint"
idstringwhe_…
livemodeboolean
createdstring
urlstring or nullWhere deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this endpoint now, or null.
eventsarray of string
descriptionstring or null
statusone of: enabled, disabled
disabled_reasonone of: failures, blocked, manual or nullfailures: 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_atstring or null
last_failure_atstring or null
metadataobjectYour 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.
secretstring or nullwhsec_…, 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The endpoint.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"webhook_endpoint"
idstringwhe_…
livemodeboolean
createdstring
urlstring or nullWhere deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this endpoint now, or null.
eventsarray of string
descriptionstring or null
statusone of: enabled, disabled
disabled_reasonone of: failures, blocked, manual or nullfailures: 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_atstring or null
last_failure_atstring or null
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Body (JSON):

FieldTypeRequiredDescription
urlstring
eventsarray of stringThe 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.
descriptionstring or null
disabledbooleantrue stops deliveries; false re-enables the endpoint and clears its failure count and failing time.
metadataobjectYour 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:

FieldTypeDescription
object"webhook_endpoint"
idstringwhe_…
livemodeboolean
createdstring
urlstring or nullWhere deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this endpoint now, or null.
eventsarray of string
descriptionstring or null
statusone of: enabled, disabled
disabled_reasonone of: failures, blocked, manual or nullfailures: 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_atstring or null
last_failure_atstring or null
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: Deleted.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"webhook_endpoint"
idstring
deletedtrue

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.

ParameterInTypeRequiredDescription
idpathstringyes

Body (JSON):

FieldTypeRequiredDescription
expires_in_secondsintegerHow 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:

FieldTypeDescription
object"webhook_endpoint"
idstringwhe_…
livemodeboolean
createdstring
urlstring or nullWhere deliveries go. null for a dev endpoint: they go to your dev session (npx openlegion dev).
transportone of: https, devhttps: OpenLegion POSTs to url. dev (test mode): each delivery goes to your dev session (npx openlegion dev).
dev_sessionstring or nulldes_…: the dev session holding this endpoint now, or null.
eventsarray of string
descriptionstring or null
statusone of: enabled, disabled
disabled_reasonone of: failures, blocked, manual or nullfailures: 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_atstring or null
last_failure_atstring or null
metadataobjectYour 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.
secretstring or nullwhsec_…, shown this once: verify OpenLegion-Signature with it. null on an idempotent replay; rotate_secret mints a new one.
previous_secret_expires_atstring

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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The ping event.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"event"
idstringevt_…: one id per event, the same on every endpoint and every retry. Dedupe on it.
typeone 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_versionstring
createdstringRFC 3339 UTC.
livemodeboolean
workspacestring or nullws_…, or null for an org-level event.
external_refstring or nullYour id for the workspace, as you set it.
dataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
statusqueryone of: pending, succeeded, failed, skippedOnly deliveries in this status.
limitqueryinteger1–100, default 20.
starting_afterquerystringA whd_ id: the page after it.
ending_beforequerystringA whd_ id: the page before it.

Returns:

  • 200: A list of deliveries.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"webhook_delivery"
idstringwhd_…: also the OpenLegion-Delivery header your endpoint received.
endpointstringwhe_…
eventstringevt_…: the event delivered, the receiver's dedupe key.
event_typestring
livemodeboolean
statusone of: pending, succeeded, failed, skippedpending: 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.
createdstring
next_attempt_atstring or nullWhen the next retry is due, after a failed attempt with retries left; null otherwise.
finished_atstring or null
attemptsarray of objectEvery 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.

ParameterInTypeRequiredDescription
idpathstringyes
delivery_idpathstringyes

Returns:

  • 200: The delivery, queued for its one more attempt.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"webhook_delivery"
idstringwhd_…: also the OpenLegion-Delivery header your endpoint received.
endpointstringwhe_…
eventstringevt_…: the event delivered, the receiver's dedupe key.
event_typestring
livemodeboolean
statusone of: pending, succeeded, failed, skippedpending: 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.
createdstring
next_attempt_atstring or nullWhen the next retry is due, after a failed attempt with retries left; null otherwise.
finished_atstring or null
attemptsarray of objectEvery 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.

ParameterInTypeRequiredDescription
typequerystringAn event type (run.completed), or a family (run.*).
workspacequerystringOnly this workspace's events (ws_…).
created[gte]querystringRFC 3339: created at or after.
created[lt]querystringRFC 3339: created before.
limitqueryinteger1–100, default 20.
starting_afterquerystringAn evt_ id: the page after it.
ending_beforequerystringAn evt_ id: the page before it.

Returns:

  • 200: A list of events.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"event"
idstringevt_…: one id per event, the same on every endpoint and every retry. Dedupe on it.
typeone 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_versionstring
createdstringRFC 3339 UTC.
livemodeboolean
workspacestring or nullws_…, or null for an org-level event.
external_refstring or nullYour id for the workspace, as you set it.
dataobject

GET /events/{id}

Retrieve an event of the last 30 days.

Who: An org key, scope webhooks.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The event.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"event"
idstringevt_…: one id per event, the same on every endpoint and every retry. Dedupe on it.
typeone 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_versionstring
createdstringRFC 3339 UTC.
livemodeboolean
workspacestring or nullws_…, or null for an org-level event.
external_refstring or nullYour id for the workspace, as you set it.
dataobject

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.

ParameterInTypeRequiredDescription
subjectpathstringyes

Returns:

  • 200: Erased.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"subject"
idstringYour user's id, as you sent it.
livemodeboolean
deletedtrue

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.

ParameterInTypeRequiredDescription
actionquerystringAn exact action, e.g. key.created.
created[gte]querystringRFC 3339: created at or after.
created[lt]querystringRFC 3339: created before.
limitqueryinteger1–100, default 20.
starting_afterquerystringAn oae_ id: the page after it.
ending_beforequerystringAn 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"org_audit_event"
idstringoae_…
livemodeboolean or nullnull: an act on the org itself, in neither mode (its creation, its billing account).
createdstring
actionstring
actorobjectWho acted: a person in your console (never named here), an org key, or OpenLegion.
keystring or nullkey_…: the org key that acted, when one did.
resourcestring or nullWhat was acted on, as type:id (workspace:ws_…). A person is the type alone (org_member): never their user id.
detailobject
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The org audit event.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"org_audit_event"
idstringoae_…
livemodeboolean or nullnull: an act on the org itself, in neither mode (its creation, its billing account).
createdstring
actionstring
actorobjectWho acted: a person in your console (never named here), an org key, or OpenLegion.
keystring or nullkey_…: the org key that acted, when one did.
resourcestring or nullWhat was acted on, as type:id (workspace:ws_…). A person is the type alone (org_member): never their user id.
detailobject
metadataobjectYour 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:

FieldTypeDescription
object"api_key"
idstring
namestring
livemodeboolean
scopesarray of string
hintstringThe key's last four characters.
createdstring
expires_atstring or null
revokedboolean
orgstringorg_…
org_namestring
made_by_loginbooleanTrue for a key npx openlegion login made (a device approval).
browserbooleanWhether 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:

FieldTypeDescription
object"api_key"
idstring
revokedtrue

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):

FieldTypeRequiredDescription
connectorstringcon_…: a dev connector (transport: dev) of this org.
webhook_endpointstringwhe_…: a dev webhook endpoint (transport: dev). Needs the webhooks scope too.
device_namestringWhat 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:

FieldTypeDescription
object"dev_session"
idstringdes_…
livemodefalse
statusone of: connected, offline, superseded, closedoffline: connected, but not seen for 15 s. Requests to its targets fail at once until it polls again.
connectorstring or nullcon_…: the dev connector it holds.
webhook_endpointstring or nullwhe_…: the dev webhook endpoint it holds.
device_namestring or null
last_seen_atstringRFC 3339 UTC.
createdstringRFC 3339 UTC.

GET /dev_sessions/{id}

Retrieve a dev session.

Who: An org key, scope connectors.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The session.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"dev_session"
idstringdes_…
livemodefalse
statusone of: connected, offline, superseded, closedoffline: connected, but not seen for 15 s. Requests to its targets fail at once until it polls again.
connectorstring or nullcon_…: the dev connector it holds.
webhook_endpointstring or nullwhe_…: the dev webhook endpoint it holds.
device_namestring or null
last_seen_atstringRFC 3339 UTC.
createdstringRFC 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The session, closed.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"dev_session"
idstringdes_…
livemodefalse
statusone of: connected, offline, superseded, closedoffline: connected, but not seen for 15 s. Requests to its targets fail at once until it polls again.
connectorstring or nullcon_…: the dev connector it holds.
webhook_endpointstring or nullwhe_…: the dev webhook endpoint it holds.
device_namestring or null
last_seen_atstringRFC 3339 UTC.
createdstringRFC 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.

ParameterInTypeRequiredDescription
idpathstringyes
waitqueryinteger1–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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"dev_request"
idstringdvr_…
kindone of: mcp, webhookmcp: forward it to your app's MCP route. webhook: to its webhooks route. Verify its signature first.
methodone of: POST, GET, DELETE
headersobjectcontent-type, accept, user-agent, mcp-* and openlegion-* only.
body_base64string or nullThe exact request bytes, base64. Verify the signature over these bytes, decoded.
deadlinestringAfter 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.

ParameterInTypeRequiredDescription
idpathstringyes
request_idpathstringyes
OpenLegion-Dev-StatusheaderintegeryesThe HTTP status your app answered: 200–599.
Content-TypeheaderstringThe answer's content type.

Returns:

  • 200: The answer was taken.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"dev_request_answer"
requeststringdvr_…
statusinteger

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):

FieldTypeRequiredDescription
client_versionstringyesThe CLI's version, shown on the approval page.
device_namestringWhat the device calls itself (the CLI sends its host name). Shown on the approval page as the device's own claim.
targetobjectyesWhat 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:

FieldTypeDescription
object"deploy_authorization"
livemodebooleanTrue for a live deploy grant (target.live): the exchange makes live keys and a run key.
approval_neededbooleanfalse: every key is kept and nothing needs approving; the fields below are null. Always true for live (the run key is always made).
keysarray of object
device_codestring or nulloldc_…: send it to POST /device_authorizations/token; never show it. null on an idempotent replay: mint a new one.
user_codestring or nullWDJB-MJHT: show it to the person, who types it on the page.
verification_uristring or null
expires_ininteger or null
intervalinteger 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):

FieldTypeRequiredDescription
client"openlegion-cli"yesWho is asking. "openlegion-cli": npx openlegion login.
client_versionstringyesThe client's version, shown on the approval page.
device_namestringWhat the device calls itself (the CLI sends its host name). Shown on the approval page as the device's own claim. Default "Unnamed device".
grantsarray of one of: cli, appWhich keys an approval makes: ["cli"] (default) or ["cli", "app"].
sourcestringWhere 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:

FieldTypeDescription
object"device_authorization"
device_codestringoldc_…: the device's secret. Send it to POST /device_authorizations/token; never show it.
user_codestringWDJB-MJHT: show it to the person, who types it on the page.
verification_uristringThe page where the person signs in, types the code and approves.
expires_inintegerSeconds until both codes expire (600).
intervalintegerSeconds 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):

FieldTypeRequiredDescription
device_codestringyesThe 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:

FieldTypeDescription
object"device_grant"
livemodebooleanTrue for a live deploy grant: every key in this answer is live.
orgstringorg_…: the organization chosen on the approval page.
org_namestring
keysarray of object
keptarray of objectA deploy grant only: the deployment's keys left as they are, because the host has them and they are in service.
run_keyobjectA 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.

ParameterInTypeRequiredDescription
sourcequerystringvendor_mcp, native or piece.
statusquerystringavailable or needs_oauth_app.
categoryquerystringOne category, e.g. productivity.
limitqueryinteger1–100, default 20.
starting_afterquerystringAn 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"catalog_entry"
idstringThe app: what a connection's app and a connect session's app name.
namestring
descriptionstringOne line, OpenLegion's words.
categoriesarray of string
logostring or nullA copy OpenLegion hosts, or null: render the name's initial.
sourceone of: vendor_mcp, native, piecevendor_mcp: the vendor's own MCP server. native: OpenLegion's own tools. piece: OpenLegion's runner.
statusone of: available, needs_oauth_appavailable: 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.
authobject
setupstring or nullWhat has to happen before the first connection can work, or null.
toolsarray of object or nullnull: 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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The catalog entry.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"catalog_entry"
idstringThe app: what a connection's app and a connect session's app name.
namestring
descriptionstringOne line, OpenLegion's words.
categoriesarray of string
logostring or nullA copy OpenLegion hosts, or null: render the name's initial.
sourceone of: vendor_mcp, native, piecevendor_mcp: the vendor's own MCP server. native: OpenLegion's own tools. piece: OpenLegion's runner.
statusone of: available, needs_oauth_appavailable: 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.
authobject
setupstring or nullWhat has to happen before the first connection can work, or null.
toolsarray of object or nullnull: 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:

FieldTypeDescription
object"connect_settings"
livemodeboolean
namestring or nullThe name your users see on the connect page. null: your organization's name.
logo_urlstring or nullAn https image shown on the connect page, or null.
accent_colorstring or null#rrggbb, or null for the default.
privacy_urlstring or nullYour privacy policy, linked from the connect page, or null.
return_originsarray of stringExact https origins a connect session's return_url may be on (at most 10). Test mode also allows http://localhost.
updated_atstring or nullWhen 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):

FieldTypeRequiredDescription
namestring or null
logo_urlstring or null
accent_colorstring or null
privacy_urlstring or null
return_originsarray of stringReplaces the list.

Returns:

  • 200: The settings.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 422:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"connect_settings"
livemodeboolean
namestring or nullThe name your users see on the connect page. null: your organization's name.
logo_urlstring or nullAn https image shown on the connect page, or null.
accent_colorstring or null#rrggbb, or null for the default.
privacy_urlstring or nullYour privacy policy, linked from the connect page, or null.
return_originsarray of stringExact https origins a connect session's return_url may be on (at most 10). Test mode also allows http://localhost.
updated_atstring or nullWhen 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"oauth_app"
idstringoapp_…
livemodeboolean
appstringThe catalog app this OAuth client is for, such as google.
client_idstringYour OAuth client id. The client secret is write-only and never returned.
redirect_uristringThe redirect URI to register with the vendor for this client.
createdstring
updated_atstring

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):

FieldTypeRequiredDescription
appstringyesA catalog app that connects with OAuth, such as google.
client_idstringyesThe OAuth client id from the vendor's console.
client_secretstringyesThe 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:

FieldTypeDescription
object"oauth_app"
idstringoapp_…
livemodeboolean
appstringThe catalog app this OAuth client is for, such as google.
client_idstringYour OAuth client id. The client secret is write-only and never returned.
redirect_uristringThe redirect URI to register with the vendor for this client.
createdstring
updated_atstring

GET /oauth_apps/{id}

Retrieve an OAuth app.

Who: An org key, scope connectors.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: The OAuth app.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"oauth_app"
idstringoapp_…
livemodeboolean
appstringThe catalog app this OAuth client is for, such as google.
client_idstringYour OAuth client id. The client secret is write-only and never returned.
redirect_uristringThe redirect URI to register with the vendor for this client.
createdstring
updated_atstring

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.

ParameterInTypeRequiredDescription
idpathstringyes

Returns:

  • 200: Deleted.
  • 400:
  • 401:
  • 402:
  • 403:
  • 404:
  • 409:
  • 429:

Fields of the 200 answer:

FieldTypeDescription
object"oauth_app"
idstring
deletedtrue

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:

FieldTypeDescription
object"onboarding"
orgstringorg_…
org_namestring
livemodebooleanThe calling key's mode. The facts are always the project's test mode.
signed_inobjectThe CLI signed in to this project.
kit_addedobjectnpx openlegion init made the app's key.
agent_arrivedobjectA version of the developer's own agent arrived.
first_messageobjectA run that the developer's app started.
next_stepobject

Agents

GET /agents

List the workspace's agents.

Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.

ParameterInTypeRequiredDescription
limitqueryinteger1–100, default 20.
starting_afterquerystringAn agt_ id: the page after it.
ending_beforequerystringAn agt_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"agent"
idstringagt_…
livemodeboolean
createdstring
namestring
statusone of: active, pausedactive: it runs when something starts it (an idle agent is active too); paused: it does not until resumed.
pausedobject or nullWhy and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard.
modelobjectThe effective model choice.
templatestring or nullThe workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version the agent runs now.
template_agentstring or nullThe template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes.
originone of: template, apiWho made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API).
external_refstring or nullYour own id for an agent made through the API. Null for a template's agent.
overridesobjectWhat the end customer changed. Everything else is the template's.
customizableobject or nullWhat may be changed on this agent. Null: nothing.
toolsarray of objectThe template agent's tools, and which are on. Connector tools are granted beside them and are not listed.
max_concurrent_runsintegerAt 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.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
template_agentstringyesThe template agent to make another of: one of customizable.agents.creatable (GET /template_agents).
namestring or nullA new display name, within customizable.name. null: the template's again.
rolestring or nullA new one-line role, within customizable.role. null: the template's again.
instructionsstring or nullThe end customer's own instructions, added after the template's (which they never replace). null or an empty string: none.
model_tierone of: background, fast, reasoning, frontier, auto or nullOne 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_presetsarray of one of: background, fast, reasoning, frontier or nullWith 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.
toolsobject{id: false} switches off a tool listed in customizable.tools.optional; {id: true} switches it back on. No tool can be added.
metadataobjectYour 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_refstringYour 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:

FieldTypeDescription
object"agent"
idstringagt_…
livemodeboolean
createdstring
namestring
statusone of: active, pausedactive: it runs when something starts it (an idle agent is active too); paused: it does not until resumed.
pausedobject or nullWhy and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard.
modelobjectThe effective model choice.
templatestring or nullThe workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version the agent runs now.
template_agentstring or nullThe template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes.
originone of: template, apiWho made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API).
external_refstring or nullYour own id for an agent made through the API. Null for a template's agent.
overridesobjectWhat the end customer changed. Everything else is the template's.
customizableobject or nullWhat may be changed on this agent. Null: nothing.
toolsarray of objectThe template agent's tools, and which are on. Connector tools are granted beside them and are not listed.
max_concurrent_runsintegerAt 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.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"agent"
idstringagt_…
livemodeboolean
createdstring
namestring
statusone of: active, pausedactive: it runs when something starts it (an idle agent is active too); paused: it does not until resumed.
pausedobject or nullWhy and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard.
modelobjectThe effective model choice.
templatestring or nullThe workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version the agent runs now.
template_agentstring or nullThe template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes.
originone of: template, apiWho made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API).
external_refstring or nullYour own id for an agent made through the API. Null for a template's agent.
overridesobjectWhat the end customer changed. Everything else is the template's.
customizableobject or nullWhat may be changed on this agent. Null: nothing.
toolsarray of objectThe template agent's tools, and which are on. Connector tools are granted beside them and are not listed.
max_concurrent_runsintegerAt 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.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
namestring or nullA new display name, within customizable.name. null: the template's again.
rolestring or nullA new one-line role, within customizable.role. null: the template's again.
instructionsstring or nullThe end customer's own instructions, added after the template's (which they never replace). null or an empty string: none.
model_tierone of: background, fast, reasoning, frontier, auto or nullOne 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_presetsarray of one of: background, fast, reasoning, frontier or nullWith 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.
toolsobject{id: false} switches off a tool listed in customizable.tools.optional; {id: true} switches it back on. No tool can be added.
metadataobjectYour 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:

FieldTypeDescription
object"agent"
idstringagt_…
livemodeboolean
createdstring
namestring
statusone of: active, pausedactive: it runs when something starts it (an idle agent is active too); paused: it does not until resumed.
pausedobject or nullWhy and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard.
modelobjectThe effective model choice.
templatestring or nullThe workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version the agent runs now.
template_agentstring or nullThe template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes.
originone of: template, apiWho made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API).
external_refstring or nullYour own id for an agent made through the API. Null for a template's agent.
overridesobjectWhat the end customer changed. Everything else is the template's.
customizableobject or nullWhat may be changed on this agent. Null: nothing.
toolsarray of objectThe template agent's tools, and which are on. Connector tools are granted beside them and are not listed.
max_concurrent_runsintegerAt 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.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"agent"
idstringagt_…
livemodeboolean
createdstring
namestring
status"deleted"
pausedobject or nullWhy and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard.
modelobjectThe effective model choice.
templatestring or nullThe workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version the agent runs now.
template_agentstring or nullThe template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes.
originone of: template, apiWho made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API).
external_refstring or nullYour own id for an agent made through the API. Null for a template's agent.
overridesobjectWhat the end customer changed. Everything else is the template's.
customizableobject or nullWhat may be changed on this agent. Null: nothing.
toolsarray of objectThe template agent's tools, and which are on. Connector tools are granted beside them and are not listed.
max_concurrent_runsintegerAt 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.
metadataobjectYour 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.
deletedtrue

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"agent"
idstringagt_…
livemodeboolean
createdstring
namestring
statusone of: active, pausedactive: it runs when something starts it (an idle agent is active too); paused: it does not until resumed.
pausedobject or nullWhy and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard.
modelobjectThe effective model choice.
templatestring or nullThe workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version the agent runs now.
template_agentstring or nullThe template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes.
originone of: template, apiWho made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API).
external_refstring or nullYour own id for an agent made through the API. Null for a template's agent.
overridesobjectWhat the end customer changed. Everything else is the template's.
customizableobject or nullWhat may be changed on this agent. Null: nothing.
toolsarray of objectThe template agent's tools, and which are on. Connector tools are granted beside them and are not listed.
max_concurrent_runsintegerAt 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.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"agent"
idstringagt_…
livemodeboolean
createdstring
namestring
statusone of: active, pausedactive: it runs when something starts it (an idle agent is active too); paused: it does not until resumed.
pausedobject or nullWhy and since when it is paused: manual is a person's (or your) stop; auto_* is OpenLegion's spend, failure or taint guard.
modelobjectThe effective model choice.
templatestring or nullThe workspace's template, as the workspace says it: "slug" tracks the promoted version; "slug@N" pins version N.
template_versioninteger or nullThe version the agent runs now.
template_agentstring or nullThe template agent (agents[].key in the spec) this agent is. Null for an agent no template agent describes.
originone of: template, apiWho made it: template (the workspace's template; a re-pin or promote updates it) or api (made through the API).
external_refstring or nullYour own id for an agent made through the API. Null for a template's agent.
overridesobjectWhat the end customer changed. Everything else is the template's.
customizableobject or nullWhat may be changed on this agent. Null: nothing.
toolsarray of objectThe template agent's tools, and which are on. Connector tools are granted beside them and are not listed.
max_concurrent_runsintegerAt 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.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
inputstringyesWhat to do, in words: it lands in the thread as the caller's message.
threadstringthr_…: run in this conversation, so the result shows in the customer's chat history. Absent: a new thread.
metadataobjectYours: returned on the run and on run.completed / run.failed. A key sent as "" or null is not stored.
model_tierone of: background, fast, reasoning, frontier, autoA 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_presetsarray of one of: background, fast, reasoning, frontierWith 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:

FieldTypeDescription
object"run"
idstringrun_…
livemodeboolean
createdstringRFC 3339 UTC.
agentstringagt_…
threadstring or nullthr_…: 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).
statusone of: queued, running, completed, failed, cancelled, settlingOne of queued, running, completed, failed, cancelled, settling. settling: an action is still finishing after the run ended.
triggerone of: message, schedule, inbound_event, api, resume, handoff, follow_up, other
cost_microintegerWhat 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.
creditsnumberThe 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).
modelstring or nullThe 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_namestring or nullWhat 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_tierone of: background, fast, reasoning, frontier or nullThe 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_choiceone of: agent, person, auto or nullWho 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.
autoobject or nullHow Auto chose model_tier. Null unless model_choice is auto, and on a run routed before Auto among presets was recorded.
model_requestedobject or nullSet 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_atstring or null
ended_atstring or null
errorobject or nullWhy the run did not succeed: a stable code, the end user's sentence and yours.
waitingobject or nullWhy a queued run has not started yet. Present only while status is queued; null while a queued run is being retried.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
kindquerystringcore_block, lesson, fact, episode or procedure.
limitqueryinteger1–100, default 20: learnings per page.
starting_afterquerystringA learning's mem_ id: the page after it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"memory_item"
idstringmem_…
livemodeboolean
agentstringagt_…: the agent whose memory this is listed under.
kindone of: core_block, lesson, fact, episode, procedurecore_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.
scopeone of: agent, workspaceworkspace: shared by every agent of the workspace (a learning only).
labelstring or nullA core block's label; null otherwise.
textstring
versioninteger or nullA core block's version; null otherwise.
trustone of: owner, system, tool_verified, web_low or nullHow far the item is trusted. It comes from who wrote it; storing it never raises it.
sourceobject or nullWhere it came from, when that is known: the run that learned it, the message behind it, or who wrote it.
createdstring or nullRFC 3339 UTC. A core block's is its current version's.
metadataobjectAlways 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.

ParameterInTypeRequiredDescription
idpathstringyes
memory_item_idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"memory_item"
idstring
deletedtrue

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"memory_reset"
agentstring
forgottenintegerThe agent's own learnings forgotten.
lessons_clearedinteger
blocks_restoredintegerCore 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.

ParameterInTypeRequiredDescription
limitqueryinteger1–100, default 20.
starting_afterquerystringAn agt_ id: the page after it.
ending_beforequerystringAn agt_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"agent_summary"
agentstringagt_…
namestringThe agent's name, as GET /agents has it.
statusone of: active, pausedAs GET /agents has it.
ongoing_threadstring or nullThe 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.
unseenintegerMessages 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.
waitingintegerApprovals of this agent still waiting that this person may decide (can_decide on GET /approvals/{id}). 100 means 100 or more.
workingbooleanA 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_atstring or nullongoing_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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"browser_site"
agentstringagt_…
sitestringThe site: the browser may open it and its subdomains.
sourceone of: template, persontemplate: the version's browser.open sites. person: a person allowed it, on a browser_site_grant approval.
addedobject or nullA person's site: when it was allowed, and who allowed it. Null for the template's.
approvalstring or nullapr_…: the approval that allowed a person's site. Null for the template's.
removedobject or nullNull 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.

ParameterInTypeRequiredDescription
idpathstringyes
sitepathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"browser_site"
agentstringagt_…
sitestringThe site: the browser may open it and its subdomains.
sourceone of: template, persontemplate: the version's browser.open sites. person: a person allowed it, on a browser_site_grant approval.
addedobject or nullA person's site: when it was allowed, and who allowed it. Null for the template's.
approvalstring or nullapr_…: the approval that allowed a person's site. Null for the template's.
removedobject or nullNull 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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring
agent_limitobject or nullThe 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:

FieldTypeDescription
object"template_agent"
keystringThe template agent's key (agents[].key in the spec); an agent's template_agent.
namestring
rolestring
model_tierstringIts model preset.
toolsarray of objectIts tools. Connector tools are granted beside them and are not listed.
customizableobject or nullWhat may be changed on an agent made from it, or on it. Null: nothing.
creatablebooleanPOST /agents may make another agent from it (customizable.agents.creatable).
blueprintbooleantrue: 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.

ParameterInTypeRequiredDescription
agentquerystringOnly this agent's (agt_…).
archivedqueryone of: true, falsetrue: only archived conversations. Left out, or false: only the ones that are not.
unseenqueryone of: true, falsetrue: 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.
orderqueryone of: created, last_message_atcreated (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.
limitqueryinteger1–100, default 20.
starting_afterquerystringA thr_ id: the page after it.
ending_beforequerystringA thr_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"thread"
idstringthr_…
livemodeboolean
createdstring
agentstringagt_…: the one agent this conversation is with.
active_runstring or nullrun_…: the run answering in this thread now, or the next one queued; null when idle. Re-attach to it with GET /runs/{id}/stream.
titlestring or nullWhat 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_atstring or nullRFC 3339 UTC: when the newest message was written, by the person or the agent. Null before the first message.
archivedbooleantrue: a person archived it. GET /threads leaves it out unless archived=true. A new message brings it back.
homebooleantrue: 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.
metadataobjectYour 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_throughstring or nullHow 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.
unseeninteger or nullWhat 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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
agentstringyesagt_…
metadataobjectYour 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.
homebooleantrue: 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.
ongoingbooleantrue: 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:

FieldTypeDescription
object"thread"
idstringthr_…
livemodeboolean
createdstring
agentstringagt_…: the one agent this conversation is with.
active_runstring or nullrun_…: the run answering in this thread now, or the next one queued; null when idle. Re-attach to it with GET /runs/{id}/stream.
titlestring or nullWhat 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_atstring or nullRFC 3339 UTC: when the newest message was written, by the person or the agent. Null before the first message.
archivedbooleantrue: a person archived it. GET /threads leaves it out unless archived=true. A new message brings it back.
homebooleantrue: 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.
metadataobjectYour 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_throughstring or nullHow 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.
unseeninteger or nullWhat 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"thread"
idstringthr_…
livemodeboolean
createdstring
agentstringagt_…: the one agent this conversation is with.
active_runstring or nullrun_…: the run answering in this thread now, or the next one queued; null when idle. Re-attach to it with GET /runs/{id}/stream.
titlestring or nullWhat 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_atstring or nullRFC 3339 UTC: when the newest message was written, by the person or the agent. Null before the first message.
archivedbooleantrue: a person archived it. GET /threads leaves it out unless archived=true. A new message brings it back.
homebooleantrue: 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.
metadataobjectYour 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_throughstring or nullHow 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.
unseeninteger or nullWhat 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
titlestring or nullWhat to call the conversation, 1 to 200 characters. null clears it.
archivedbooleantrue archives the conversation: it leaves the default list, and nothing is deleted. false brings it back.
metadataobjectYour 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:

FieldTypeDescription
object"thread"
idstringthr_…
livemodeboolean
createdstring
agentstringagt_…: the one agent this conversation is with.
active_runstring or nullrun_…: the run answering in this thread now, or the next one queued; null when idle. Re-attach to it with GET /runs/{id}/stream.
titlestring or nullWhat 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_atstring or nullRFC 3339 UTC: when the newest message was written, by the person or the agent. Null before the first message.
archivedbooleantrue: a person archived it. GET /threads leaves it out unless archived=true. A new message brings it back.
homebooleantrue: 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.
metadataobjectYour 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_throughstring or nullHow 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.
unseeninteger or nullWhat 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.

ParameterInTypeRequiredDescription
idpathstringyes
limitqueryinteger1–100, default 20.
starting_afterquerystringA msg_ id: the page after it (older).
ending_beforequerystringA msg_ id: the page before it (newer).
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"message"
idstringmsg_…
livemodeboolean
createdstring
threadstring
roleone of: user, assistant, system
partsarray of objectAI 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.
truststringThe content trust tier: owner, tool_verified or web_low.
taintedbooleanTrue 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.
runstring or nullrun_…: the run this message started (user) or came from (assistant).
triggerone of: message, schedule, inbound_event, api, resume, handoff, follow_up, other or nullWhat 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.
schedulestring or nullsch_…: the schedule whose run wrote this message (trigger schedule). Null otherwise.
stoppedbooleanTrue 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.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
streamqueryone of: true, falsetrue: answer with the run's live stream.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
contentstringyesWhat the person said: up to 32000 characters.
attachmentsarray of stringUp 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_tierone of: background, fast, reasoning, frontier, autoA 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_presetsarray of one of: background, fast, reasoning, frontierWith 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:

FieldTypeDescription
messageobjectOne message in a thread.
runobjectOne 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
messagestringyesThe 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:

FieldTypeDescription
object"thread_seen"
threadstringthr_…
seen_throughstringThe person's mark after this call: the time of the newest message they have seen there. A mark never moves back.
unseenintegerWhat 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.

ParameterInTypeRequiredDescription
agentquerystringOnly this agent's (agt_…).
threadquerystringOnly the runs that answer in this thread (thr_…).
limitqueryinteger1–100, default 20.
starting_afterquerystringA run_ id: the page after it.
ending_beforequerystringA run_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"run"
idstringrun_…
livemodeboolean
createdstringRFC 3339 UTC.
agentstringagt_…
threadstring or nullthr_…: 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).
statusone of: queued, running, completed, failed, cancelled, settlingOne of queued, running, completed, failed, cancelled, settling. settling: an action is still finishing after the run ended.
triggerone of: message, schedule, inbound_event, api, resume, handoff, follow_up, other
cost_microintegerWhat 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.
creditsnumberThe 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).
modelstring or nullThe 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_namestring or nullWhat 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_tierone of: background, fast, reasoning, frontier or nullThe 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_choiceone of: agent, person, auto or nullWho 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.
autoobject or nullHow Auto chose model_tier. Null unless model_choice is auto, and on a run routed before Auto among presets was recorded.
model_requestedobject or nullSet 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_atstring or null
ended_atstring or null
errorobject or nullWhy the run did not succeed: a stable code, the end user's sentence and yours.
waitingobject or nullWhy a queued run has not started yet. Present only while status is queued; null while a queued run is being retried.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"run"
idstringrun_…
livemodeboolean
createdstringRFC 3339 UTC.
agentstringagt_…
threadstring or nullthr_…: 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).
statusone of: queued, running, completed, failed, cancelled, settlingOne of queued, running, completed, failed, cancelled, settling. settling: an action is still finishing after the run ended.
triggerone of: message, schedule, inbound_event, api, resume, handoff, follow_up, other
cost_microintegerWhat 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.
creditsnumberThe 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).
modelstring or nullThe 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_namestring or nullWhat 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_tierone of: background, fast, reasoning, frontier or nullThe 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_choiceone of: agent, person, auto or nullWho 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.
autoobject or nullHow Auto chose model_tier. Null unless model_choice is auto, and on a run routed before Auto among presets was recorded.
model_requestedobject or nullSet 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_atstring or null
ended_atstring or null
errorobject or nullWhy the run did not succeed: a stable code, the end user's sentence and yours.
waitingobject or nullWhy a queued run has not started yet. Present only while status is queued; null while a queued run is being retried.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"run"
idstringrun_…
livemodeboolean
createdstringRFC 3339 UTC.
agentstringagt_…
threadstring or nullthr_…: 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).
statusone of: queued, running, completed, failed, cancelled, settlingOne of queued, running, completed, failed, cancelled, settling. settling: an action is still finishing after the run ended.
triggerone of: message, schedule, inbound_event, api, resume, handoff, follow_up, other
cost_microintegerWhat 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.
creditsnumberThe 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).
modelstring or nullThe 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_namestring or nullWhat 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_tierone of: background, fast, reasoning, frontier or nullThe 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_choiceone of: agent, person, auto or nullWho 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.
autoobject or nullHow Auto chose model_tier. Null unless model_choice is auto, and on a run routed before Auto among presets was recorded.
model_requestedobject or nullSet 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_atstring or null
ended_atstring or null
errorobject or nullWhy the run did not succeed: a stable code, the end user's sentence and yours.
waitingobject or nullWhy a queued run has not started yet. Present only while status is queued; null while a queued run is being retried.
metadataobjectYour 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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: N and data: <json part> per part (status parts such as data-queued carry no id), ending with data: [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.

ParameterInTypeRequiredDescription
agentquerystringOnly this agent's (agt_…).
runquerystringOnly the actions this run asked for (run_…).
statusqueryone of: requires_approval, approved, executing, completed, failed, rejected, expiredOnly actions in this status.
limitqueryinteger1–100, default 20.
starting_afterquerystringAn act_ id: the page after it.
ending_beforequerystringAn act_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"action"
idstringact_…
livemodeboolean
createdstring
agentstring
runstring or nullrun_…: the run that asked for it.
threadstring or nullthr_…: 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).
toolstring
inputobjectThe 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_sessionstringcps_…: 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.
statusone of: requires_approval, approved, executing, completed, failed, rejected, expired
outcomeone of: succeeded, failed, refused, unknown or nullWhat 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.
errorobject or nullWhy it failed, was refused or has an unknown outcome. Null when it succeeded or is still open.
tool_refusal_codestring or nullYour tool's own refusal code (refuse(message, code)), when it refused with one.
policyobject or null
riskstring or null
action_hashstringsha256: over the workspace, agent, tool and input. Send it back with a decision.
taintedbooleanTrue when the run had read untrusted content before asking.
approvalstring or nullapr_…: its newest approval, if it needed one.
receiptobject or null
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"action"
idstringact_…
livemodeboolean
createdstring
agentstring
runstring or nullrun_…: the run that asked for it.
threadstring or nullthr_…: 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).
toolstring
inputobjectThe 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_sessionstringcps_…: 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.
statusone of: requires_approval, approved, executing, completed, failed, rejected, expired
outcomeone of: succeeded, failed, refused, unknown or nullWhat 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.
errorobject or nullWhy it failed, was refused or has an unknown outcome. Null when it succeeded or is still open.
tool_refusal_codestring or nullYour tool's own refusal code (refuse(message, code)), when it refused with one.
policyobject or null
riskstring or null
action_hashstringsha256: over the workspace, agent, tool and input. Send it back with a decision.
taintedbooleanTrue when the run had read untrusted content before asking.
approvalstring or nullapr_…: its newest approval, if it needed one.
receiptobject or null
metadataobject

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.

ParameterInTypeRequiredDescription
statusqueryone of: pending, approved, rejected, expired, allOne of pending, approved, rejected, expired, all. The default is pending: those still waiting on a decision.
agentquerystringOnly this agent's (agt_…).
limitqueryinteger1–100, default 20.
starting_afterquerystringAn apr_ id: the page after it.
ending_beforequerystringAn apr_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"approval"
idstringapr_…
livemodeboolean
createdstring
agentstring
threadstring or nullthr_…: 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).
kindstringirreversible_tool, financial, question, …
statusone of: pending, approved, rejected, expired
titlestring or null
fieldsarray of objectThe 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.
riskstring
cost_microinteger or null
expires_atstring or null
decidedobject or null
responsestring or nullA question's answer. A note sent with an approve or a reject goes to the agent with the decision and is not kept here.
actionobject or null
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"approval"
idstringapr_…
livemodeboolean
createdstring
agentstring
threadstring or nullthr_…: 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).
kindstringirreversible_tool, financial, question, …
statusone of: pending, approved, rejected, expired
titlestring or null
fieldsarray of objectThe 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.
riskstring
cost_microinteger or null
expires_atstring or null
decidedobject or null
responsestring or nullA question's answer. A note sent with an approve or a reject goes to the agent with the decision and is not kept here.
actionobject or null
metadataobject
can_decidebooleanWhether 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
decisionone of: approve, reject, answeryes
action_hashstring or nullThe action's action_hash, exactly as read. Null (or left out) for a question, which has no action.
answerstringThe 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:

FieldTypeDescription
object"approval"
idstringapr_…
livemodeboolean
createdstring
agentstring
threadstring or nullthr_…: 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).
kindstringirreversible_tool, financial, question, …
statusone of: pending, approved, rejected, expired
titlestring or null
fieldsarray of objectThe 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.
riskstring
cost_microinteger or null
expires_atstring or null
decidedobject or null
responsestring or nullA question's answer. A note sent with an approve or a reject goes to the agent with the decision and is not kept here.
actionobject or null
metadataobject
run_refusedobjectPresent 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.

ParameterInTypeRequiredDescription
agentquerystringOnly this agent's (agt_…).
statusqueryone of: open, in_progress, blocked, review, done, cancelledOnly tasks with this status.
limitqueryinteger1–100, default 20.
starting_afterquerystringA tsk_ id: the page after it.
ending_beforequerystringA tsk_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"task"
idstringtsk_…
livemodeboolean
createdstring
updated_atstring
agentstring or null
titlestring
instructionsstring
statusone of: open, in_progress, blocked, review, done, cancelled
deadlinestring or null
resultobject or nullThe 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.
artifactsarray of stringart_…: what it delivered.
metadataobject

POST /tasks

Hand an agent a task, without a chat.

Who: An org key, scope messages.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
agentstringyesagt_…: the agent that does it.
titlestringyesOne line.
instructionsstringyesWhat to do, and what done looks like.
deadlinestringRFC 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:

FieldTypeDescription
object"task"
idstringtsk_…
livemodeboolean
createdstring
updated_atstring
agentstring or null
titlestring
instructionsstring
statusone of: open, in_progress, blocked, review, done, cancelled
deadlinestring or null
resultobject or nullThe 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.
artifactsarray of stringart_…: what it delivered.
metadataobject

GET /tasks/{id}

Read a task, with its result.

Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"task"
idstringtsk_…
livemodeboolean
createdstring
updated_atstring
agentstring or null
titlestring
instructionsstring
statusone of: open, in_progress, blocked, review, done, cancelled
deadlinestring or null
resultobject or nullThe 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.
artifactsarray of stringart_…: what it delivered.
metadataobject

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.

ParameterInTypeRequiredDescription
threadquerystringthr_…: the conversation. Required.
limitqueryinteger1–100, default 20.
starting_afterquerystringAn art_ id: the page after it.
ending_beforequerystringAn art_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"artifact"
idstringart_…
livemodeboolean
createdstring
agentstring
taskstring or null
namestring
mimestring
size_bytesinteger
versioninteger
review_statusone of: draft, review, approved, rejected
truststring
taintedbooleanTrue when the agent had read untrusted content before writing it.
urlstring or nullA signed download link that works for a few minutes: fetch it now, never store it. Null when none could be made.
url_expires_atstring or null
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"artifact"
idstringart_…
livemodeboolean
createdstring
agentstring
taskstring or null
namestring
mimestring
size_bytesinteger
versioninteger
review_statusone of: draft, review, approved, rejected
truststring
taintedbooleanTrue when the agent had read untrusted content before writing it.
urlstring or nullA signed download link that works for a few minutes: fetch it now, never store it. Null when none could be made.
url_expires_atstring or null
metadataobject

Audit events

GET /audit_events

The workspace's audit trail, newest first.

Who: An org key, scope workspaces:read.

ParameterInTypeRequiredDescription
actionquerystringOnly this action.
agentquerystringOnly this agent's (agt_…).
limitqueryinteger1–100, default 20.
starting_afterquerystringAn aud_ id: the page after it.
ending_beforequerystringAn aud_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"audit_event"
idstringaud_…: opaque, like every id.
livemodeboolean
createdstring
actionstringe.g. platform.message_sent, approval.decided, agent.paused, task.created, reach.suppressed.
actorobjectWho: a user (a person or your service principal: subject null), an agent, or the system.
viastring or nullorg_key or org_session for your own acts; null for the agent's and the system's.
keystring or nullkey_…: the org key behind it.
sessionstring or nullses_…: the session behind it.
agentstring or null
resourcestring or null
decisionstring or null
detailobject
metadataobjectAlways 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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
typestringyesWhat happened, e.g. order.shipped.
dataobjectyesThe fact, as a JSON object: up to 32 KiB.
trustone of: owner, system, tool_verified, web_lowyestool_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_keystringyesYour id for this fact. A repeat within 30 days returns the first one and starts nothing.
agentstringagt_…: 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:

FieldTypeDescription
object"inbound_event"
idstringine_…
livemodeboolean
createdstring
typestring
trustone of: tool_verified, web_lowThe trust the fact carries: what you declared, capped at tool_verified.
taintedbooleanTrue for web_low: the run it starts may not pass its content to a tool that reaches outside.
dedupe_keystring
agentstringagt_…: the agent it was routed to.
threadstringthr_…: that agent's inbound thread.
runstring or nullrun_…: the run it started, or null when it started none (see reason).
reasonone of: no_trigger, agent_paused or nullWhy 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).
metadataobject

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.

ParameterInTypeRequiredDescription
namequerystringOne item by its name.
kindquerystringlogin, api_key or secret.
agentquerystringagt_…: the items this agent may use.
limitqueryinteger1–100, default 20.
starting_afterquerystringA vlt_ id: the page after it.
ending_beforequerystringA vlt_ id: the page before it.
ask[thread]querystringWith 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]querystringWith ask[thread]: the msg_ id of the agent's message that asked.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"vault_item"
idstringvlt_…
livemodeboolean
createdstring
updated_atstring
namestring
handlestringvault://: what an agent calls it by.
kindone of: login, api_key, secret
labelstring
originsarray of stringThe only pages a login (or a secret) is typed into: exact https origins.
hostsarray of stringThe only hosts an API key (or a secret) is sent to, in a request header: exact names.
agentsarray of stringagt_… ids that may use it; empty: every agent of the workspace.
secret_fieldsarray of one of: username, password, totp, valueWhich secret fields hold a value. Never a value.
metadataobject

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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
namestringyes1 to 48 characters: a-z, 0-9, - and _. The handle is vault://.
kindone of: login, api_key, secretyes
labelstringWhat a person sees. Defaults to the name.
originsarray of stringA login's (or a secret's) https origins, e.g. https://github.com. Exact: no wildcards, no subdomains.
hostsarray of stringAn API key's (or a secret's) hosts, e.g. api.github.com. Exact: no wildcards.
agentsarray of stringagt_… ids that may use it; leave out for every agent of the workspace.
metadataobjectYour 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.
secretobjectyesWrite-only. Never returned, never logged.
askobjectSaves 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:

FieldTypeDescription
object"vault_item"
idstringvlt_…
livemodeboolean
createdstring
updated_atstring
namestring
handlestringvault://: what an agent calls it by.
kindone of: login, api_key, secret
labelstring
originsarray of stringThe only pages a login (or a secret) is typed into: exact https origins.
hostsarray of stringThe only hosts an API key (or a secret) is sent to, in a request header: exact names.
agentsarray of stringagt_… ids that may use it; empty: every agent of the workspace.
secret_fieldsarray of one of: username, password, totp, valueWhich secret fields hold a value. Never a value.
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"vault_item"
idstringvlt_…
livemodeboolean
createdstring
updated_atstring
namestring
handlestringvault://: what an agent calls it by.
kindone of: login, api_key, secret
labelstring
originsarray of stringThe only pages a login (or a secret) is typed into: exact https origins.
hostsarray of stringThe only hosts an API key (or a secret) is sent to, in a request header: exact names.
agentsarray of stringagt_… ids that may use it; empty: every agent of the workspace.
secret_fieldsarray of one of: username, password, totp, valueWhich secret fields hold a value. Never a value.
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
labelstring
originsarray of stringReplaces the list. A new origin needs secret.password (or secret.value) again, and secret.totp too when the login has an authenticator key.
hostsarray of stringReplaces the list. A new host needs secret.value again.
agentsarray of stringReplaces the list; [] for every agent.
metadataobjectYour 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.
secretobjectMerged 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:

FieldTypeDescription
object"vault_item"
idstringvlt_…
livemodeboolean
createdstring
updated_atstring
namestring
handlestringvault://: what an agent calls it by.
kindone of: login, api_key, secret
labelstring
originsarray of stringThe only pages a login (or a secret) is typed into: exact https origins.
hostsarray of stringThe only hosts an API key (or a secret) is sent to, in a request header: exact names.
agentsarray of stringagt_… ids that may use it; empty: every agent of the workspace.
secret_fieldsarray of one of: username, password, totp, valueWhich secret fields hold a value. Never a value.
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"vault_item"
idstring
deletedtrue

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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of objectAt most one: saving another vendor's key replaces it.
has_moreboolean
urlstring
allowedbooleanmodel_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:

FieldTypeDescription
object"model_key"
vendorone of: anthropic, openai
kind"api_key"
tailstring or nullThe key's last four characters, e.g. …x9Qa. Never the key.
createdstringWhen this key was saved.
checked_atstring or nullWhen the vendor last accepted it.
in_usebooleanThe 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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
vendorone of: anthropic, openaiyesanthropic or openai.
keystringyesThe 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:

FieldTypeDescription
object"model_key"
vendorone of: anthropic, openai
kind"api_key"
tailstring or nullThe key's last four characters, e.g. …x9Qa. Never the key.
createdstringWhen this key was saved.
checked_atstring or nullWhen the vendor last accepted it.
in_usebooleanThe workspace's agents run on it now: model_keys_allowed is on.
replacedobject or nullThe 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.

ParameterInTypeRequiredDescription
vendorpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"model_key"
vendorone of: anthropic, openai
deletedtrue

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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"model_preset"
idone of: background, fast, reasoning, frontierThe preset: the value of model_tier everywhere it is taken.
modelobjectThe model a run on this preset uses now, on this workspace.
keyone of: openlegion, ownopenlegion: 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.

ParameterInTypeRequiredDescription
appquerystringOne app's connection, e.g. google.
statusquerystringactive, needs_reauth or revoked.
agentquerystringagt_…: the connections this agent may use.
limitqueryinteger1–100, default 20.
starting_afterquerystringA cxn_ id: the page after it.
ending_beforequerystringA cxn_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"connection"
idstringcxn_…
livemodeboolean
createdstring
updated_atstring
appstringThe catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom).
sourceone of: native, vendor_mcp, piece, customcustom: an MCP server your user added by its address. OpenLegion has not checked it.
accountobject
statusone of: active, needs_reauth, revokedactive, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked.
agentsarray of string or nullagt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows.
connected_bystring or nullThe subject who connected it, or null: your server, or a subject since erased.
last_used_atstring or null
revoked_atstring or null
toolsarray of objectThe 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).
serverobject or nullFor a custom connection only: the server it calls. null for every other source.
metadataobject

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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring
custom_serversobject or nullThe 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:

FieldTypeDescription
object"catalog_entry"
idstringThe app: what a connection's app and a connect session's app name.
namestring
descriptionstringOne line, OpenLegion's words.
categoriesarray of string
logostring or nullA copy OpenLegion hosts, or null: render the name's initial.
sourceone of: vendor_mcp, native, piecevendor_mcp: the vendor's own MCP server. native: OpenLegion's own tools. piece: OpenLegion's runner.
statusone of: available, needs_oauth_appavailable: 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.
authobject
setupstring or nullWhat has to happen before the first connection can work, or null.
toolsarray of object or nullnull: 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"connection"
idstringcxn_…
livemodeboolean
createdstring
updated_atstring
appstringThe catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom).
sourceone of: native, vendor_mcp, piece, customcustom: an MCP server your user added by its address. OpenLegion has not checked it.
accountobject
statusone of: active, needs_reauth, revokedactive, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked.
agentsarray of string or nullagt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows.
connected_bystring or nullThe subject who connected it, or null: your server, or a subject since erased.
last_used_atstring or null
revoked_atstring or null
toolsarray of objectThe 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).
serverobject or nullFor a custom connection only: the server it calls. null for every other source.
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
agentsarray of string or nullReplaces the list: agt_… ids of this workspace. null: every agent the template allows for the app.
metadataobjectYour 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:

FieldTypeDescription
object"connection"
idstringcxn_…
livemodeboolean
createdstring
updated_atstring
appstringThe catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom).
sourceone of: native, vendor_mcp, piece, customcustom: an MCP server your user added by its address. OpenLegion has not checked it.
accountobject
statusone of: active, needs_reauth, revokedactive, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked.
agentsarray of string or nullagt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows.
connected_bystring or nullThe subject who connected it, or null: your server, or a subject since erased.
last_used_atstring or null
revoked_atstring or null
toolsarray of objectThe 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).
serverobject or nullFor a custom connection only: the server it calls. null for every other source.
metadataobject

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"connection"
idstringcxn_…
livemodeboolean
createdstring
updated_atstring
appstringThe catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom).
sourceone of: native, vendor_mcp, piece, customcustom: an MCP server your user added by its address. OpenLegion has not checked it.
accountobject
statusone of: active, needs_reauth, revokedactive, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked.
agentsarray of string or nullagt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows.
connected_bystring or nullThe subject who connected it, or null: your server, or a subject since erased.
last_used_atstring or null
revoked_atstring or null
toolsarray of objectThe 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).
serverobject or nullFor a custom connection only: the server it calls. null for every other source.
metadataobject
deletedtrue

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"connection"
idstringcxn_…
livemodeboolean
createdstring
updated_atstring
appstringThe catalog app (GET /connector_catalog), or custom- for a server your user added by its address (source custom).
sourceone of: native, vendor_mcp, piece, customcustom: an MCP server your user added by its address. OpenLegion has not checked it.
accountobject
statusone of: active, needs_reauth, revokedactive, needs_reauth (the vendor refused a refresh, or the server's tools changed since it was connected: your user connects again), or revoked.
agentsarray of string or nullagt_… ids that may use it, within what the workspace's template allows for the app. null: every agent the template allows.
connected_bystring or nullThe subject who connected it, or null: your server, or a subject since erased.
last_used_atstring or null
revoked_atstring or null
toolsarray of objectThe 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).
serverobject or nullFor a custom connection only: the server it calls. null for every other source.
metadataobject

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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
appstringThe catalog app (GET /connector_catalog), or a custom connection's own app (custom-) to connect that server again. Exactly one of app and server.
serverobjectAn 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_urlstringyesWhere to send your user back: on one of your registered return origins (POST /connect_settings), exactly.
agentsarray of string or nullagt_… 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:

FieldTypeDescription
object"connect_session"
idstringcxs_…
livemodeboolean
createdstring
appstringThe 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.
serverobject or nullFor a server named by its address: which one. null for a catalog app.
urlstring or nullSend 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.
statusone of: open, completed, cancelled, failed, expired
failure_codestring or nullWhy 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_urlstringWhere your user's browser goes when it ends, with connect_session and status added.
agentsarray of string or nullagt_… ids the connection will be open to; null: every agent the template allows.
connectionstring or nullcxn_…: the connection it made, once completed.
expires_atstring

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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"connect_session"
idstringcxs_…
livemodeboolean
createdstring
appstringThe 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.
serverobject or nullFor a server named by its address: which one. null for a catalog app.
urlstring or nullSend 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.
statusone of: open, completed, cancelled, failed, expired
failure_codestring or nullWhy 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_urlstringWhere your user's browser goes when it ends, with connect_session and status added.
agentsarray of string or nullagt_… ids the connection will be open to; null: every agent the template allows.
connectionstring or nullcxn_…: the connection it made, once completed.
expires_atstring

Schedules

GET /schedules

List the workspace's schedules.

Who: An org key with OpenLegion-Workspace, scope workspaces:read; or a session token.

ParameterInTypeRequiredDescription
agentquerystringAn agt_ id: only its schedules.
statusqueryone of: active, paused, cancelled, completed, allactive, paused, cancelled, completed, or all. Default: every one but a cancelled one.
limitqueryinteger1–100, default 20.
starting_afterquerystringA sch_ id: the page after it.
ending_beforequerystringA sch_ id: the page before it.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"list"
dataarray of object
has_moreboolean
urlstring

Fields of each item in data:

FieldTypeDescription
object"schedule"
idstringsch_…
livemodeboolean
createdstring
agentstringThe agt_ it runs.
originone of: template, api, agentWho 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_schedulestring or nullThe 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.
cronstring or nullFive-field cron, read in time_zone. Null for a one-shot.
run_atstring or nullWhen a one-shot runs (or ran). Null for a cron.
time_zonestring or nullThe zone the cron is read in, recorded when the cron was written. Null for a one-shot.
next_run_atstring or nullThe next run, while active or paused. Null once cancelled or completed, and while stopped_by is set.
instructionsstring or nullWhat 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.
descriptionstring or nullYours (or the template's). Never shown to the agent.
statusone of: active, paused, cancelled, completedcompleted: a one-shot that has run.
stopped_byone of: workspace_archived, workspace_suspended, agent_paused or nullWhat, 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.
metadataobjectYours, 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.

ParameterInTypeRequiredDescription
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
agentstringyesThe agt_ it runs.
cronstringFive-field cron, read in the workspace's time zone. Give cron or run_at.
run_atstringA one-shot's time, RFC 3339. At most 30 days out.
instructionsstringyesWhat the agent is asked to do on each run, up to 1000 characters.
descriptionstringYours, up to 200 characters. Never shown to the agent.
metadataobjectYour 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:

FieldTypeDescription
object"schedule"
idstringsch_…
livemodeboolean
createdstring
agentstringThe agt_ it runs.
originone of: template, api, agentWho 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_schedulestring or nullThe 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.
cronstring or nullFive-field cron, read in time_zone. Null for a one-shot.
run_atstring or nullWhen a one-shot runs (or ran). Null for a cron.
time_zonestring or nullThe zone the cron is read in, recorded when the cron was written. Null for a one-shot.
next_run_atstring or nullThe next run, while active or paused. Null once cancelled or completed, and while stopped_by is set.
instructionsstring or nullWhat 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.
descriptionstring or nullYours (or the template's). Never shown to the agent.
statusone of: active, paused, cancelled, completedcompleted: a one-shot that has run.
stopped_byone of: workspace_archived, workspace_suspended, agent_paused or nullWhat, 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.
metadataobjectYours, 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"schedule"
idstringsch_…
livemodeboolean
createdstring
agentstringThe agt_ it runs.
originone of: template, api, agentWho 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_schedulestring or nullThe 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.
cronstring or nullFive-field cron, read in time_zone. Null for a one-shot.
run_atstring or nullWhen a one-shot runs (or ran). Null for a cron.
time_zonestring or nullThe zone the cron is read in, recorded when the cron was written. Null for a one-shot.
next_run_atstring or nullThe next run, while active or paused. Null once cancelled or completed, and while stopped_by is set.
instructionsstring or nullWhat 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.
descriptionstring or nullYours (or the template's). Never shown to the agent.
statusone of: active, paused, cancelled, completedcompleted: a one-shot that has run.
stopped_byone of: workspace_archived, workspace_suspended, agent_paused or nullWhat, 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.
metadataobjectYours, 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
cronstringA repeating schedule's new cron, inside the same bounds.
run_atstringA one-shot's new time.
instructionsstringWhat the agent is asked to do on each run, up to 1000 characters.
descriptionstring or nullnull clears it.
metadataobjectYour 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:

FieldTypeDescription
object"schedule"
idstringsch_…
livemodeboolean
createdstring
agentstringThe agt_ it runs.
originone of: template, api, agentWho 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_schedulestring or nullThe 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.
cronstring or nullFive-field cron, read in time_zone. Null for a one-shot.
run_atstring or nullWhen a one-shot runs (or ran). Null for a cron.
time_zonestring or nullThe zone the cron is read in, recorded when the cron was written. Null for a one-shot.
next_run_atstring or nullThe next run, while active or paused. Null once cancelled or completed, and while stopped_by is set.
instructionsstring or nullWhat 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.
descriptionstring or nullYours (or the template's). Never shown to the agent.
statusone of: active, paused, cancelled, completedcompleted: a one-shot that has run.
stopped_byone of: workspace_archived, workspace_suspended, agent_paused or nullWhat, 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.
metadataobjectYours, 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"schedule"
idstringsch_…
livemodeboolean
createdstring
agentstringThe agt_ it runs.
originone of: template, api, agentWho 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_schedulestring or nullThe 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.
cronstring or nullFive-field cron, read in time_zone. Null for a one-shot.
run_atstring or nullWhen a one-shot runs (or ran). Null for a cron.
time_zonestring or nullThe zone the cron is read in, recorded when the cron was written. Null for a one-shot.
next_run_atstring or nullThe next run, while active or paused. Null once cancelled or completed, and while stopped_by is set.
instructionsstring or nullWhat 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.
descriptionstring or nullYours (or the template's). Never shown to the agent.
statusone of: active, paused, cancelled, completedcompleted: a one-shot that has run.
stopped_byone of: workspace_archived, workspace_suspended, agent_paused or nullWhat, 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.
metadataobjectYours, 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"schedule"
idstringsch_…
livemodeboolean
createdstring
agentstringThe agt_ it runs.
originone of: template, api, agentWho 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_schedulestring or nullThe 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.
cronstring or nullFive-field cron, read in time_zone. Null for a one-shot.
run_atstring or nullWhen a one-shot runs (or ran). Null for a cron.
time_zonestring or nullThe zone the cron is read in, recorded when the cron was written. Null for a one-shot.
next_run_atstring or nullThe next run, while active or paused. Null once cancelled or completed, and while stopped_by is set.
instructionsstring or nullWhat 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.
descriptionstring or nullYours (or the template's). Never shown to the agent.
statusone of: active, paused, cancelled, completedcompleted: a one-shot that has run.
stopped_byone of: workspace_archived, workspace_suspended, agent_paused or nullWhat, 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.
metadataobjectYours, 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"schedule"
idstringsch_…
livemodeboolean
createdstring
agentstringThe agt_ it runs.
originone of: template, api, agentWho 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_schedulestring or nullThe 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.
cronstring or nullFive-field cron, read in time_zone. Null for a one-shot.
run_atstring or nullWhen a one-shot runs (or ran). Null for a cron.
time_zonestring or nullThe zone the cron is read in, recorded when the cron was written. Null for a one-shot.
next_run_atstring or nullThe next run, while active or paused. Null once cancelled or completed, and while stopped_by is set.
instructionsstring or nullWhat 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.
descriptionstring or nullYours (or the template's). Never shown to the agent.
statusone of: active, paused, cancelled, completedcompleted: a one-shot that has run.
stopped_byone of: workspace_archived, workspace_suspended, agent_paused or nullWhat, 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.
metadataobjectYours, 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.

ParameterInTypeRequiredDescription
threadquerystringthr_…: the thread the file will be sent in.
namequerystringThe file's name, as the person sees it (1 to 200 characters).
Content-TypeheaderstringyesThe file's type, e.g. application/pdf or text/csv.
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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:

FieldTypeDescription
object"file"
idstringfile_…
livemodeboolean
createdstring
threadstringthr_…: the thread it was uploaded for. It can only be sent there.
namestring
mimestringThe type read from the file's bytes.
size_bytesinteger
messagestring or nullmsg_…: 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.

ParameterInTypeRequiredDescription
idpathstringyes
OpenLegion-WorkspaceheaderstringThe workspace (ws_…). Required with an org key; a session names its own.
OpenLegion-SubjectheaderstringYour user's id, to act as them (the act_as scope). Org key only.
OpenLegion-Subject-NameheaderstringThat 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-Clearheaderone of: trueSend 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):

FieldTypeRequiredDescription
originstringyesThe page that will show the viewer: exactly one of your organization's return origins (POST /connect_settings); test mode also allows http://localhost.
controlbooleantrue 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:

FieldTypeDescription
object"computer_viewer"
urlstringThe session's base on OpenLegion's viewer. appends /view, /control and /input.
tokenstringFor 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.
controlbooleantrue: the token can take over (control). false: it can only watch.
expires_atstring