Skip to content

Agent routes: teach, upgrade

The Agent Verbs teach, upgrade as api.sb routes, with inputs, result, refusals and an example.

Agent.mintMode do
curl -X POST https://api.sb/leaseline.app/agents/mint \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tenant":"ten_Bu63f0he26","product":"prod_MJmgS5dysq"}'
API referenceAgent.mint
npx startup-builder do Agent.mint --data '{"tenant":"ten_Bu63f0he26","product":"prod_MJmgS5dysq"}'
CLI referenceAgent.mint
{
  "name": "do",
  "arguments": {
    "code": "return await $.Agent.mint({ tenant: 'ten_Bu63f0he26', product: 'prod_MJmgS5dysq' })"
  }
}
MCP referenceAgent.mint
import { $ } from 'startup-builder'

const agent = await $.Agent.mint({ tenant: 'ten_Bu63f0he26', product: 'prod_MJmgS5dysq' })
SDK referenceAgent.mint

Reference for Agent, one group of Agent routes.

Agent.teach

Teach adds a rule to a Customer’s own minted Agent that binds only that Customer’s Tenant. Verb page.

Text
POST /{namespace}/agents/{agent}/teach

Path: agent. Body, as JSON: the other inputs. Emits Agent.taught.

Inputs

InputTypeRequiredDescription
agentAgentrequiredThe minted Agent.
ruletextrequiredThe rule, in plain words.
casetextrequiredA case the rule must pass, kept with the Tenant’s cases.

Returns

OutputTypeRequiredDescription
agentAgentrequiredThe Agent with the rule.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operationforbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
A rule that would widen what the product’s Role contract allowsrefusedClear what the check names, then call it again.None.
agent is missing, or is not a agentinvalid-inputSend agent as a agent, then call it again.None.
rule is missing, or is not a textinvalid-inputSend rule as a text, then call it again.None.
case is missing, or is not a textinvalid-inputSend case as a text, then call it again.None.
The Idempotency-Key was sent before with another operation or other inputidempotency-mismatchSend a new key for new input; reuse a key only to retry the same request.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/agents/agent_tCzKDMorKn/teach \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Idempotency-Key: leaseline-agent-teach-1" \
  -H "Content-Type: application/json" \
  -d '{"rule":"Example rule","case":"Example case"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "agent": {
    "$id": "https://api.sb/leaseline.app/agents/agent_tCzKDMorKn",
    "$type": "Agent",
    "instructions": "Write as the property manager’s assistant. Never promise a rent the manager has not set.",
    "model": "claude-opus-5-5",
    "status": "seated"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Agent.teach",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Agent.upgrade

Upgrade moves a Customer’s minted Agent to a new Version once every case in its Tenant passes on that Version. Verb page.

Text
POST /{namespace}/agents/{agent}/upgrade

Path: agent. Body, as JSON: the other inputs. Emits Agent.upgraded.

Inputs

InputTypeRequiredDescription
agentAgentrequiredThe minted Agent.
versionVersionrequiredThe target Version.

Returns

OutputTypeRequiredDescription
agentAgentrequiredThe Agent, on the target Version.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operationforbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
agent is missing, or is not a agentinvalid-inputSend agent as a agent, then call it again.None.
version is missing, or is not a versioninvalid-inputSend version as a version, then call it again.None.
The Idempotency-Key was sent before with another operation or other inputidempotency-mismatchSend a new key for new input; reuse a key only to retry the same request.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/agents/agent_tCzKDMorKn/upgrade \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Idempotency-Key: leaseline-agent-upgrade-1" \
  -H "Content-Type: application/json" \
  -d '{"version":"version_4HTEMs14G4"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "agent": {
    "$id": "https://api.sb/leaseline.app/agents/agent_tCzKDMorKn",
    "$type": "Agent",
    "instructions": "Write as the property manager’s assistant. Never promise a rent the manager has not set.",
    "model": "claude-opus-5-5",
    "status": "seated"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Agent.upgrade",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}