Template spec
A template version is what POST /templates/{slug}/versions takes, and what npx openlegion templates push sends. Each version is immutable: to change a template, push a new version, then promote it. This page has the rules for each field, in the order of the spec's schema. The API reference has the request's full shape.
The agent's fields: name, role, soul, instructions, model_tier, tools, schedules, core_blocks, max_concurrent_runs
A template seeds one agent from these fields at the top level, or several from agents, whose items take the same fields plus a key (see agents). Not both: a version with top-level agent fields and agents is refused (400 parameter_invalid, param: "agents"). The top-level agent's key is main.
name: the agent's display name, 1 to 80 characters. Absent: the template's name.role: one line on what the agent is for, 1 to 200 characters.soul: up to 4,000 characters.instructions: up to 8,000 characters.model_tier: the model preset the agent runs on:background,fast,reasoningorfrontier. Absent:fast. Abudget.run_creditsabove 0 must cover the floor of the highest tier among the template's agents (seebudget).tools: platform tool ids, at most 64, and at most 15 of them resident, e.g.agent.finish,memory.search. Platform tools lists every id, and its Loaded column says which kind each is. A resident tool's definition goes with every step of every run; OpenLegion keeps at most 15 resident, and they areagent.finish,agent.schedule,agent.note_to_user,memory.search,memory.timeline,memory.write_candidate,web.search,web.fetch,files.read,files.write,sandbox.run,sandbox.code_run,team.hand_off,team.askandteam.complete. Every other tool is deferred: a run starts with a short index that names it, a call by name runs from the first step, and its definitions are sent from the step after. A list past either number is refused (400 parameter_invalidontools), naming both numbers and the resident tools it lists. Each is checked, and refused (400 parameter_invalidontools[i]) if it isn't a platform tool, isn't available yet, or is a workspace-admin power (team.admin.*). One refusal names every id that was refused, on the first one'stools[i], with the nearest id that exists when one is close. A connector tool (mcp.…) is refused here too: declare it underconnectors, and every agent is granted it. Whenpolicy_envelope.toolsis present, every tool must be in it.schedules: at most 20, each{key, cron, instructions, description?}.key: unique within the agent: a lower-case letter, then up to 63 lower-case letters, digits,-or_. A later version updates the schedule with the same key. One the previous version wrote and a later version drops is cancelled. The agent's own schedules and your end customers' are never the template's to cancel.cron: five fields, read in the workspace'stime_zone.instructions: what the agent is asked to do when the schedule fires, 1 to 1,000 characters.description: up to 200 characters.
core_blocks: at most 8 (7 whencustomizable.instructionsis set: the eighth is the end customer's), each{label, text}, written into the agent's core memory.label:SOUL,INSTRUCTIONS, or your own: an upper-case letter, then up to 31 upper-case letters, digits or_. NeverOWNER_INSTRUCTIONS, which holds an end customer's own instructions.text: up to 4,000 characters.
max_concurrent_runs: at most this many of the agent's runs at once, 1 to 32, its own scheduled and inbound work included. Absent: 1, every run one at a time. One thread's runs are always one at a time, in order. Runs at once aren't on yet: the value is stored and checked now, and every run stays one at a time until they are. It can't be made customizable. A value above your plan's limit on runs at once is accepted: the plan's limit applies when runs start.
A template is written into every workspace's core memory, so a version holding anything shaped like a secret key, in any field, is refused (400 parameter_invalid, param: "body"). Agents get keys from the credential vault, never from their instructions.
agents
agents: several agents from one template, 1 to 10. Each item is{key, …}with the agent's fields (agent.md). Leave the top-level agent fields out when you use it: a version with both is refused (400 parameter_invalid,param: "agents").key: the agent's handle across versions: a lower-case letter, then up to 31 lower-case letters, digits,-or_. Two agents may not share a key. Applying a later version to a workspace updates the agent with the same key in place, so its id, threads, memory and history stay. A key a later version adds is created, and one it drops is archived. A version that drops a key your end customers' created agents still follow is refused (409 template_agent_in_use), and nothing is applied.blueprint: true(defaultfalse): the agent is a blueprint. No workspace gets it until one of your users makes one from it withPOST /agents, so a starter can have its owntools,model_tierandscheduleswithout being made for everyone. Itstoolsare the platform's; which of your own tools it gets isconnectors[].tools.<name>.agents. A version is refused (400 parameter_invalid) when a blueprint is not incustomizable.agents.creatable(agents[i].blueprint: nobody could ever make it), when every agent is a blueprint (agents: a new workspace would have no agent), or when a trigger names one (triggers[i].agent). A later version that makes an existing agent a blueprint archives the template's own agent in each workspace and keeps the ones your users made from it; the reverse makes it in each workspace.- The first agent that is not a blueprint is the default: a trigger without
agentstarts it, and an event no trigger matches is recorded on its inbound thread (seetriggers). - A
budget.run_creditsabove 0 must cover the floor of the highestmodel_tieramong all the agents (seebudget).
budget
-
budget.run_credits: the credits a run holds up front, in whole credits. Set it to what one run should spend. A run starts only when its workspace has that much under its caps and grants. Above 0 it must be at least the floor of the highestmodel_tieramong the template's agents, or the version is refused (400 parameter_invalidonbudget.run_credits, and the message names the floor). Absent or0, a run holds the per-run ceiling of the dearest tier it may reach: the agent'smodel_tieror any tier its policy allows. The ceilings are background 10, fast 50, reasoning 250 and frontier 1,000 credits, so afastagent that may escalate toreasoningholds 250, and a run that may usefrontierholds 1,000 credits ($1.00) up front, many times what most runs spend.ol devwarns when it pushes a template that allowsfrontierwith nobudget.run_credits. A workspace'susage_period.run_credits_requiredsays what its runs hold. Every model call in a run is sized to what the run's budget has left, so a run ends at its budget rather than past it.Or one budget per preset: a map,
run_credits: { fast: 40, reasoning: 250 }. A run holds, and stops at, the entry of the preset it starts on, a person's pick (model_tieron a message) included. The rungs its policy allows add nothing (a template agent is pinned; an Auto run's step-up spends from the same entry). A preset left out, or at0, holds its ceiling. Each key must be a preset an agent is on or a person may pick (customizable.model_tier.allowed), and each entry above 0 at least that preset's floor; otherwise400 parameter_invalidon that entry (budget.run_credits.reasoning), naming the floor. A workspace's caps must cover the largest entry a person may pick, as they must the one number. -
budget.agent_daily_run_capandbudget.agent_daily_credit_cap(optional): each agent's limits in any trailing 24 hours, in whole runs (1 to 10,000) and whole credits (at least 1). Withoutagent_daily_run_cap, a backstop against a runaway agent applies. Withoutagent_daily_credit_capthere is no per-agent money limit, and the workspace's caps bind. A run past either limit is refused (402 cap_reached), and itspartner_messagenames the limit and the field to raise. A promote or re-pin applies a change.
default_limits
default_limits:{period_credit_cap?, daily_credit_cap?, cap_mode?, soft_overage_pct?}, the caps a workspace gets when it is created without any, in a workspace's own limit fields. A hardperiod_credit_capabove 0, or anydaily_credit_cap, below one run's hold on the agents this version seeds is refused (400 parameter_invalidon that field), because it would refuse every run. A version pushed before this check is refused atPOST /workspacesinstead (param: "template").
policy_envelope
policy_envelope.tools:{<tool id>: {status, limits?}}, the outer bound on every agent's tools. When it is present, every tool an agent lists must be in it (400 parameter_invalidotherwise); when it is absent, every listed tool is allowed. An end customer can only tighten inside it.status:allowed;held, where each call waits for a person's approval; orlimited, where itslimitsbecome that tool's config, which its executor enforces.limits: only for alimitedtool.limits.allowCredentials, whichweb.fetchandvault.request_credentialread: the names of the workspace's saved credentials the tool may use.web.fetchsends one in a request header as{{cred:<name>}}, andvault.request_credentialgives the agent a handle to one. Some secrets no tool opens by name, so naming one here refuses the version (400 parameter_invalidatpolicy_envelope.tools.<tool>.limits.allowCredentials[i], and the message says which kind it is): a connected account's own key, an app's OAuth client secret, a connected channel's own secret, the workspace's own model key, or one of the workspace's own system secrets (a trigger's or a webhook's). An agent uses a connected account only through its connection's tools (connectors.*ormcp.*). To call a model provider's API with your own key, save the key again under an ordinary name and list that name.limits.sitesandlimits.personSites, whichbrowser.openreads: the websites the agent's browser may open, each one with its subdomains (["example.com"]), and whether a person may add more. WithpersonSites: true, an open of a website on neither list does not fail: it waits for a person's approval, abrowser_site_grantapproval titled "Let ‹agent› use ‹site› in the browser?". A person's Allow adds that website to the agent, for every conversation in the workspace, until someone removes it; "Not now" adds nothing, and the agent does not ask about that website again until a person writes in that conversation again.sitesmay be empty whenpersonSitesis true. The template's websites and the person's together are at most 50. A public suffix (co.uk,github.io), an IP address, a local name or one of OpenLegion's own hosts is never opened and never asked for.- This widens the agent. One person's Allow lets the agent open that website in every conversation, including other people's. Under the usual rule, a member may Allow a website their own conversation asked for. To keep that decision for owners and admins, set
approver: "admin"onbrowser.open.
- This widens the agent. One person's Allow lets the agent open that website in every conversation, including other people's. Under the usual rule, a member may Allow a website their own conversation asked for. To keep that decision for owners and admins, set
approver:requester(the default) oradmin. Who may approve or reject a held call of the tool, besides the workspace's owners and admins:requesteris the member whose conversation asked for it, andadminis nobody else. It goes with anystatus, because anallowedtool can still be held for its cost or for whom it reaches. It is read when a person decides, from the version the workspace runs then, so a new version that sets it covers the approvals already waiting. A member reading such an approval getscan_decide: false, and their decision is403 insufficient_role.- A connector tool is keyed
mcp.<slug>.<local>, and isallowedorheld, neverlimited: its limits are your server's to enforce.
connectors
connectors: up to 10, each{connector: "con_…", tools?: {<tool name>: {trust?, effect?}}}. Every agent of the template is granted each declared tool, or only the agents the tool'sagentslists; a tool not declared isn't granted. Each connector is listed once (400 parameter_invalidon a second entry). The tools must be pinned on that connector in your organization when the version is created. Inpolicy_envelope.tools, a declared tool's id ismcp.<slug>.<local>.trust, of its results:tool_verified(your own product's data) orweb_low(text people outside your product wrote). Defaultweb_low.effect, of calling it:read,draft(nothing leaves your product),write(changes your product) oregress(reaches people or systems outside it). Defaultegress.approval_title(optional, 1 to 200 characters): the sentence a person reads as the approval's title when a call of the tool waits for them, e.g.Email you "{subject}"?. Each{name}is replaced by that field of the call's input (text or a number, one line, at most 80 characters); a field the call left out is replaced by nothing. Without it the title is the tool's title and a question mark, or its name in words. The kit writes it fromapprovalTitleondefineTool.approval_fields(optional, at most 20 names, none twice): the fields of the call's input that the approval shows up front, in this order. Every other field stays in the approval'sfields, markeddetail: true, for the card's details: the list moves facts and removes none.[]marks them all. Without it no field is marked. The kit writes it fromapprovalFieldsondefineTool.agents(optional, 1 to 10 agent keys, none twice): the template agents that get this tool, and so the agentsPOST /agentsmakes from them. Left out, every agent gets it. An agent that is not listed is never offered the tool and a call of it is refused. A key that is not an agent of this version is refused (400 parameter_invalidonconnectors[i].tools.<name>.agents[j]); a blueprint's key is allowed. A later version that changes the list takes the tool from an agent, or gives it, from that agent's next run. To give a tool to no agent, leave it out. The kit writes it fromtoolAgentsondefineTemplate.
apps
Which catalog apps your workspace's users may connect, and which of your agents may use each one. At most 50 entries, each {app, agents?, tools?}:
app: a catalog app (GET /connector_catalog), orcustom: your users may add MCP servers of their own by address, up to 10 a workspace. Every tool of such a server asks before it runs. Left out, nobody may.agents: the template agents, by key (1 to 100), that may use the app, and so the agentsPOST /agentsmakes from them. Left out, every agent may.tools: {<catalog tool id>: {allowed: true}}: those of the app's tools that run without asking first.
A version is refused (400 parameter_invalid) when:
apps[i].appis listed twice, or is neither in the catalog norcustom;apps[i].agents[j]is not an agent of this version;apps[i].toolsnames a tool that is not one of the app's, or any tool of avendor_mcpapp or ofcustom(their tools are their servers' own).
The list applies with the version. An app a later version drops stays connected and grants no agent.
A version that lists no apps grants no agent a connected account, and opens no connect session, until a version that lists apps is applied. A workspace on a version made before apps existed is in that state.
customizable
customizable(optional): what an end customer may change on the template's agents, and within which bounds. Absent: nothing. Every field is optional, and a field left out can't be changed. No list may repeat an entry.name,role,instructions:{max_length?}, at most 80, 200 and 4,000 characters (the default and the ceiling).instructionsare the end customer's own, added after the template's as one more core block (OWNER_INSTRUCTIONS, a label a template may not use); the template'ssoulandinstructionsare never replaced and never returned. With it, each agent has at most 7core_blocks.model_tier: {allowed: [tier, …]}: the presets an end customer may pick. Whenbudget.run_creditsis above 0, each must fit it, as the agents' own tiers do (400 parameter_invalidoncustomizable.model_tier.allowed[i]).tools: {optional: [tool, …], labels?: {tool: label}}: tools an end customer may switch off. Each must be on some agent'stools, and is neveragent.finishor a connector tool. Nothing can be switched on that the template agent doesn't list.labelsnames an optional tool in your product's words, 1 to 80 characters (a key not inoptionalis400 parameter_invalidoncustomizable.tools.labels.<tool>). The version stores only yours; the agent and template agent objects carry a label for every optional tool, yours or the platform's plain-word default.agents: {creatable: [key, …], max}andschedules: {min_interval_seconds, max, hours?: {from, to}, days?: [0–6]}: applied byPOST /agents, the schedule routes and the agent's own schedules (agent.schedule). Everycreatablekey is an agent of this version.agents.max(the agents an end customer may create in a workspace),schedules.max(unfinished schedules per agent, whoever made them) andmin_interval_secondseach have a platform bound, and a value past it is400 parameter_invalid.hoursis a window within one day (frombeforeto, in the workspace's time zone), anddaysare 0 = Sunday … 6 = Saturday.
A version stored before this shape (any map, or the old spelling customisable) customizes nothing; everything else in it still applies. One stored as min_interval_minutes reads as min_interval_seconds, × 60, and one stored with max_count as max.
triggers
triggers: which inbound events (POST /inbound_events) start which agent, at most 20,[{type, agent?, filter?: {where: [...]}}]. They are tried in order: the first trigger that matches starts a run of its agent, once.typeis an exact type, a family (order.*) or*.agentis a template agent's key (default: the first agent); a key the template doesn't have is refused.whereholds up to 10 conditions on the event'sdata. An event no trigger matches is recorded on the agent's inbound thread, and the agent reads it on its next run.
default_subject_role
default_subject_role:member(the default) oradmin. The role a person your server names inOpenLegion-Subjectgets the first time they act in a workspace. After that the header keeps whatever role they have; a session (POST /sessionswithrole) sets it. Neverowner: a version that saysowneris refused (400 parameter_invalidondefault_subject_role), and only a session can make an owner.