Lelemon
  • Get started
  • Use cases
  • Guides
  • API basics
  • Webhooks
  • SDK, CLI and MCP
  • API reference
  • Changelog
  • v1 (legacy)
Information
Me
    Retrieve the current keyget
API keys
    List scopesget
Agents
    List agentsgetCreate an agentpostRetrieve an agentgetDelete an agentdeleteUpdate an agentpatchActivate an agentpostPause an agentpostList versionsgetRetrieve a versiongetRestore a versionpostList the fixed facts of an agentgetSave a fixed fact of an agentputForget a fixed fact of an agentdelete
Models and templates
    List agent templatesgetList modelsget
Subaccounts
    List subaccountsgetCreate a subaccountpostRetrieve a subaccountgetDelete a subaccountdeleteUpdate a subaccountpatchGive a subaccount its own keypost
WhatsApp
    List WhatsApp connectionsgetCreate a WhatsApp connection linkpostRetrieve a WhatsApp connectiongetRevoke a pending WhatsApp connectiondeleteList WhatsApp phone numbersgetRetrieve a WhatsApp phone numbergetDisconnect a WhatsApp phone numberdeleteChange the agent, label or state of a numberpatchRead the cart and catalog settings of a numbergetTurn the cart button or the catalog icon of a number on or offpatch
Actions
    List actionsgetCreate an actionpostRead the current authorization textgetRotate the signing secret of your actionspostRetrieve the signing secret of an actiongetRetrieve an actiongetDelete an actiondeleteUpdate an actionpatchTest an actionpostRead the approval floor of a shared actiongetSet the approval floor of a shared actionput
MCP servers
    List MCP serversgetConnect an MCP serverpostRetrieve an MCP servergetDisconnect an MCP serverdeleteUpdate an MCP serverpatchList the tools of an MCP servergetDiscover toolspostRead the run identity of an MCP servergetTurn on or rotate the run identity of an MCP serverpostTurn off the run identity of an MCP serverdelete
Data connectors
    Get the lelemon-connector/v1 formatgetValidate a connector documentpostList data connectorsgetRegister a data connectorpostRetrieve a data connectorgetDelete a data connectordeleteUpdate a data connectorpatchRetrieve the signing secret of a data connectorgetRotate the signing secret of a data connectorpostCheck a data connectorpostRetrieve the manifest of a data connectorgetSearch accounts by emailgetRead the card of an account livegetReveal one masked value of an accountpostGet the link of an account actionpostRead a view livegetList who looked at what through a connectorget
Skills
    List skillsgetCreate a skillpostRetrieve a skillgetDelete a skilldeleteUpdate a skillpatch
Agent tools
    List an agent's toolsgetGrant a toolputRemove a tooldelete
Approvals
    List approvalsgetRetrieve an approvalgetApprove an actionpostReject an actionpostAsk for a human review of a decisionpost
Automated decisions
    List automated decisionsgetRetrieve an automated decisiongetAsk for a human review of an automated decisionpost
Team questions
    List team questionsgetRetrieve a team questiongetRead a team question with its contextgetAnswer a team questionpost
Runs
    Give an agent a jobpostList runsgetRetrieve a rungetCancel a runpostAnswer a run that asked somethingpost
Schedules
    Schedule a job for an agentpostList scheduled tasksgetRetrieve a scheduled taskgetDelete a scheduled taskdeleteChange a scheduled taskpatchFire a scheduled task nowpost
Pipelines
    List pipelinesgetCreate a pipelinepostRetrieve a pipelinegetDelete a pipelinedeleteUpdate a pipelinepatchClone a pipelinepostReorder the stages of a pipelinepost
Stages
    List the stages of a pipelinegetCreate a stagepostRetrieve a stagegetDelete a stagedeleteUpdate a stagepatchMake a stage the entry stagepost
Fields
    List the fields of a pipelinegetCreate a fieldpostRetrieve a fieldgetDelete a fielddeleteUpdate a fieldpatch
Routing rules
    List the routing rules of a pipelinegetCreate a routing rulepostRetrieve a routing rulegetDelete a routing ruledeleteUpdate a routing rulepatch
Knowledge
    List collectionsgetCreate a collectionpostSearch the knowledgepostRetrieve a collectiongetDelete a collectiondeleteUpdate a collectionpatchList documentsgetAdd a documentpostRetrieve a documentgetDelete a documentdeleteUpdate a documentpatchLet an agent search a collectionputStop an agent from searching a collectiondelete
Contacts
    List contactsgetCreate a contactpostCreate or update a contact by your own idputRetrieve a contactgetErase a contactdeleteUpdate a contactpatch
Contact fields
    List the contact fieldsgetCreate a contact fieldpostRetrieve a contact fieldgetDelete a contact fielddeleteUpdate a contact fieldpatch
Companies
    List companiesgetCreate a companypostRetrieve a companygetDelete a companydeleteUpdate a companypatch
Lead forms
    List lead formsgetCreate a lead formpostRetrieve a lead formgetDelete a lead formdeleteUpdate a lead formpatch
Suppressions
    Retrieve a suppressionget
Cases
    List casesgetOpen a casepostRetrieve a casegetDelete a casedeleteUpdate a casepatchMove a case to a stagepostAssign a case to a memberpostClose a casepostReopen a casepostTake control of a casepostHand a case back to the agentpostMark a case as readpostMove several cases to a stagepostArchive a casepostBring an archived case backpostMute the contact of a casepostUnmute the contact of a casepostHand a case to a personpostReveal a sensitive field of a casepostEscalate a case to the technical teampostList the escalations of a caseget
Case queue
    Read the attention queue of a memberget
Contact events
    List the events of a contactgetReport a contact eventpostRetrieve a contact eventget
Case reminders
    List the reminders of a casegetAdd a reminder to a casepost
Reminders
    Retrieve a remindergetDelete a reminderdeleteEdit a reminderpatchComplete a reminderpostDismiss a reminderpost
Presence
    Report who is online in your apppostRead the presence settinggetTurn presence on or offput
Organization
    Get the organizationgetRename the organizationpatchGet the organization settingsgetChange the organization settingspatchGet the company profilegetChange the company profilepatch
Case notes
    List the notes of a casegetAdd a note to a casepostRetrieve a notegetDelete a notedeleteEdit a notepatch
Case attachments
    List the files of a casegetUpload a file to a casepostRetrieve a file of a casegetDelete a file of a casedeleteGet the download link of a fileget
Files
    List filesgetUpload a filepostRetrieve a filegetDelete a filedelete
Case messages
    List the messages of a casegetAdd a message to a casepostRedact a messagepost
Case turns
    List the turns the agent took in a caseget
Usage
    Get the usage of your agentsget
Case metrics
    List the times of the cases that changed in a rangeget
Budgets
    List the budgetsgetCreate a monthly budgetpostGet a budgetgetDelete a budgetdeleteChange a budgetpatch
Members
    List the active members of the organizationgetList who invited, changed the role of or removed membersgetRead whether a team member is availablegetMark a team member available or awayputChange the role of a memberpatchChange which cases a member seespatchRemove a member from the organizationdelete
Invitations
    List the invitations of the organizationgetInvite a person to the organizationpostResend an invitationpostCancel an invitationpost
Scheduling
    List the agendasgetCreate an agendapostRetrieve an agendagetUpdate an agendapatchList the team of an agendagetAdd a person to the team of an agendapostRemove a person from the team of an agendadeleteUpdate a person in the team of an agendapatchRead the free slots of an agendagetList meetingsgetBook a meetingpostRetrieve a meetinggetCancel a meetingpostMove a meeting to another slotpost
Webhook endpoints
    List webhook endpointsgetCreate a webhook endpointpostRetrieve a webhook endpointgetDelete a webhook endpointdeleteUpdate a webhook endpointpatchRotate the signing secretpostSend a test eventpostList the deliveries of an endpointget
Events
    Resend an eventpostList the event typesget
Recipient allowlist
    Get the recipient allowlistgetReplace the recipient allowlistput
WhatsApp templates
    List templatesgetCreate a templatepostSync template statusespostRetrieve a templategetDelete a templatedeleteUpdate a templatepatchRender a templatepostSend a test messagepost
WhatsApp messages
    Send a templatepostRetrieve a template messagegetCancel a scheduled messagepost
Triggers
    List triggersgetCreate a triggerpostRetrieve a triggergetDelete a triggerdeleteUpdate a triggerpatchList the runs of a triggerget
Opt-outs
    List opt-outsgetOpt a contact outputClear an opt-outdelete
Campaigns
    List campaignsgetCreate a campaignpostRetrieve a campaigngetDelete a campaigndeleteUpdate a campaignpatchPreview a campaignpostLaunch a campaignpostPause a campaignpostResume a campaignpostCancel a campaignpostList recipientsget
Email domains
    List the sender domainsgetAdd a sender domainpostGet a sender domain with its status and DNS recordsgetRemove a sender domaindeleteChange the default sender or the inbound agent of a domainpatchCheck the DNS records nowpost
Email messages
    Write first by emailpostRetrieve an email messageget
Teams
    List the teamsgetCreate a teampostRetrieve a teamgetDelete a teamdeleteUpdate a teampatchMerge another team into this onepostMove a pipeline into a teamputAdd a member to a team or change their role in itputRemove a member from a teamdelete
Linear
    Get the Linear connectiongetConnect LinearputDisconnect LineardeleteUpdate the Linear connectionpatch
Schemas
powered by Zudoku
Lelemon API
Lelemon API

Runs


Give an agent a job

POST
https://api.lelemon.cl
/v2/agents/{id}/runs
Bearer (API key)

The agent works on its own, outside this request, until it finishes the job or hits a limit, and answers right away with the run in progress. Follow it with GET /v2/runs/{id} or the run.* webhooks. With this scope the agent runs unattended any action it is granted, including the ones that write, as the person you declare in actor (or as your key when you declare none): your key is what vouches for them, nothing else is signed. The limits you ask for are cut to the server maximums (60 rounds and 120 minutes). If the agent has to ask something it pauses with status waiting_for_answer: answer it with POST /v2/runs/{id}/answer. Repeat the request with the same Idempotency-Key and you get the run already created, not a second one. Use dryRun=true to run the same checks (agent active and exposed, role of the actor, limits) and see the run as it would be created, without queueing anything.

Required scope: runs:write.

Give an agent a job › path Parameters

id
​string · pattern: ^agt_[0-9A-Za-z]{22}… · required

The id of the agent (agt_…).

Give an agent a job › query Parameters

dryRun
​boolean

When true, the request goes through the same validation as the real one and is answered with what would happen (always 200), and nothing is saved, sent or charged. The answer has the same shape as the real one plus dryRun: true; an id in it is not saved. It does not use the Idempotency-Key.

Give an agent a job › Headers

Lelemon-Subaccount
​string · pattern: ^sub_[0-9A-Za-z]{22}…

The subaccount (sub_…) this request acts on. Only for the keys of a platform account; without it the request acts on the account itself.

Idempotency-Key
​string · minLength: 1 · maxLength: 255

Makes the request safe to retry. Once it starts running, its final response (2xx, 4xx or 5xx) is kept for 24 hours and the same key gets it back, without repeating the effect. A request rejected before it runs leaves the key free. A replayed create omits the secret. The same key with a different request is rejected with 409 idempotency_key_reused.

Give an agent a job › Request Body

CreateRun
goal
​string · minLength: 1 · maxLength: 8000 · required

What the agent has to achieve. It is treated as text from a user.

​object

The person in your system the agent works for. It travels signed by Lelemon to every action and MCP server of the run as the actor, marked as declared by your key and not verified. Without it the run works as your key. A key cannot declare a role above its own.

​object

Caps for this run. The server cuts them to its own maximums; what you leave out takes the default.

Give an agent a job › Responses

What a dryRun answer adds to the normal one: nothing was saved, sent or charged, and an id in it is not saved.
object
​string · enum · required
Enum values:
run
id
​string · required
agentId
​string · required
status
​string · enum · required

running: working, or in the queue. waiting_for_answer: paused to ask; question has it, answer it with POST /v2/runs/{id}/answer. completed_unverified: the agent says it finished and nobody has checked it, so do not read it as done. completed: a verifier checked it (it does not happen yet). stopped: the run was cut before the agent declared the job done, by a limit (rounds, time or the spending limit Lelemon sets for every run) or because the agent never concluded (no_conclusion) or repeated itself (loop); stopReason says which and result.partial keeps the last thing the agent wrote. failed: an error; result.error says what, or stopReason abandoned if nobody answered the pause in 30 days. canceled: you canceled it.

Enum values:
running
waiting_for_answer
completed_unverified
stopped
failed
canceled
stopReason
​string | null · enum · required

Why the run ended without finishing. Set with status stopped, and with status failed for abandoned. rounds: the run used all the rounds allowed by limits.maxRounds. cost: the run reached the spending limit Lelemon sets for every run. time: the run lasted all the minutes allowed by limits.maxMinutes. no_conclusion: the agent answered four times in a row without calling its finish action, so it never declared the job done. Its last answer is in result.partial. loop: the agent kept repeating the same action, so the run was cut. abandoned: with status failed: the agent asked a question and nobody answered it in 30 days.

Enum values:
rounds
cost
time
no_conclusion
loop
abandoned
question
​string | null · required

With status waiting_for_answer, what the agent asked. Answer it with POST /v2/runs/{id}/answer.

rounds
​integer · required

Rounds taken so far.

​RunLimits · required
​required
cancelRequested
​boolean · required

true if a cancel was asked. While a worker runs it, the run stops at the start of its next round.

schedule
​string | null · required

The scheduled task that started this run. null for a run you created with POST /v2/agents/{id}/runs.

​required

The person the run works for, as declared by the key that created it. null when the run works as the key itself.

createdAt
​string · date-time · required
startedAt
​string | null · date-time · required
finishedAt
​string | null · date-time · required
updatedAt
​string · date-time · required
dryRun
​boolean · const

Present and true when the request had dryRun=true.

Const value:
POST/v2/agents/{id}/runs
curl https://api.lelemon.cl/v2/agents/:id/runs \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <token>' \ --data '{ "goal": "Reconcile the August bank statement and tell me what is left pending.", "actor": { "id": "user_8841", "role": "staff" }, "limits": { "maxRounds": 20, "maxMinutes": 20 } }'
Example Request Body
{ "goal": "Reconcile the August bank statement and tell me what is left pending.", "actor": { "id": "user_8841", "role": "staff" }, "limits": { "maxRounds": 20, "maxMinutes": 20 } }
json
application/json
Example Responses
{ "object": "run", "id": "run_5RvP2aKq9XwLmN3tYbZc01", "agentId": "agt_5RvP2aKq9XwLmN3tYbZc01", "status": "running", "stopReason": "rounds", "question": "question", "rounds": 0, "limits": { "maxRounds": 0, "maxMinutes": 0 }, "result": { "summary": "summary", "checks": [ "string" ], "partial": "partial", "error": "error", "errorCode": "budget_exceeded" }, "cancelRequested": true, "schedule": "sch_5RvP2aKq9XwLmN3tYbZc01", "actor": { "id": "user_8841", "role": "end_user", "name": "Ana Pérez", "declaredBy": "key_5RvP2aKq9XwLmN3tYbZc01" }, "createdAt": "2024-08-25T15:00:00Z", "startedAt": "2024-08-25T15:00:00Z", "finishedAt": "2024-08-25T15:00:00Z", "updatedAt": "2024-08-25T15:00:00Z", "dryRun": true }
json
application/json

List runs

GET
https://api.lelemon.cl
/v2/runs
Bearer (API key)

The jobs given to agents, newest first. Filter by agentId, or by status=waiting_for_answer to build the queue of what waits for an answer. Read only and safe to repeat.

Required scope: runs:read.

List runs › query Parameters

limit
​integer · min: 1 · max: 100
Default: 20
cursor
​string · maxLength: 512

The nextCursor of the previous page, with the same filters.

agentId
​string
status
​string · enum
Enum values:
running
waiting_for_answer
completed_unverified
stopped
failed
canceled
scheduleId
​string

Only the runs started by this scheduled task.

List runs › Headers

Lelemon-Subaccount
​string · pattern: ^sub_[0-9A-Za-z]{22}…

The subaccount (sub_…) this request acts on. Only for the keys of a platform account; without it the request acts on the account itself.

List runs › Responses

RunList
object
​string · enum · required
Enum values:
list
hasMore
​boolean · required
nextCursor
​string | null · required
​Run[] · required
GET/v2/runs
curl https://api.lelemon.cl/v2/runs \ --header 'Authorization: Bearer <token>'
Example Responses
{ "object": "list", "hasMore": true, "nextCursor": "nextCursor", "data": [ { "object": "run", "id": "run_5RvP2aKq9XwLmN3tYbZc01", "agentId": "agt_5RvP2aKq9XwLmN3tYbZc01", "status": "running", "stopReason": "rounds", "question": "question", "rounds": 0, "limits": { "maxRounds": 0, "maxMinutes": 0 }, "result": { "summary": "summary", "checks": [ "string" ], "partial": "partial", "error": "error", "errorCode": "budget_exceeded" }, "cancelRequested": true, "schedule": "sch_5RvP2aKq9XwLmN3tYbZc01", "actor": { "id": "user_8841", "role": "end_user", "name": "Ana Pérez", "declaredBy": "key_5RvP2aKq9XwLmN3tYbZc01" }, "createdAt": "2024-08-25T15:00:00Z", "startedAt": "2024-08-25T15:00:00Z", "finishedAt": "2024-08-25T15:00:00Z", "updatedAt": "2024-08-25T15:00:00Z" } ] }
json
application/json

Retrieve a run

GET
https://api.lelemon.cl
/v2/runs/{id}
Bearer (API key)

Where the run is: its status, what it spent, the question it waits on, and what the agent declared when it finished. Read only and safe to repeat.

Required scope: runs:read.

Retrieve a run › path Parameters

id
​string · pattern: ^run_[0-9A-Za-z]{22}… · required

The id of the run (run_…).

Retrieve a run › Headers

Lelemon-Subaccount
​string · pattern: ^sub_[0-9A-Za-z]{22}…

The subaccount (sub_…) this request acts on. Only for the keys of a platform account; without it the request acts on the account itself.

Retrieve a run › Responses

Run
object
​string · enum · required
Enum values:
run
id
​string · required
agentId
​string · required
status
​string · enum · required

running: working, or in the queue. waiting_for_answer: paused to ask; question has it, answer it with POST /v2/runs/{id}/answer. completed_unverified: the agent says it finished and nobody has checked it, so do not read it as done. completed: a verifier checked it (it does not happen yet). stopped: the run was cut before the agent declared the job done, by a limit (rounds, time or the spending limit Lelemon sets for every run) or because the agent never concluded (no_conclusion) or repeated itself (loop); stopReason says which and result.partial keeps the last thing the agent wrote. failed: an error; result.error says what, or stopReason abandoned if nobody answered the pause in 30 days. canceled: you canceled it.

Enum values:
running
waiting_for_answer
completed_unverified
stopped
failed
canceled
stopReason
​string | null · enum · required

Why the run ended without finishing. Set with status stopped, and with status failed for abandoned. rounds: the run used all the rounds allowed by limits.maxRounds. cost: the run reached the spending limit Lelemon sets for every run. time: the run lasted all the minutes allowed by limits.maxMinutes. no_conclusion: the agent answered four times in a row without calling its finish action, so it never declared the job done. Its last answer is in result.partial. loop: the agent kept repeating the same action, so the run was cut. abandoned: with status failed: the agent asked a question and nobody answered it in 30 days.

Enum values:
rounds
cost
time
no_conclusion
loop
abandoned
question
​string | null · required

With status waiting_for_answer, what the agent asked. Answer it with POST /v2/runs/{id}/answer.

rounds
​integer · required

Rounds taken so far.

​RunLimits · required
​required
cancelRequested
​boolean · required

true if a cancel was asked. While a worker runs it, the run stops at the start of its next round.

schedule
​string | null · required

The scheduled task that started this run. null for a run you created with POST /v2/agents/{id}/runs.

​required

The person the run works for, as declared by the key that created it. null when the run works as the key itself.

createdAt
​string · date-time · required
startedAt
​string | null · date-time · required
finishedAt
​string | null · date-time · required
updatedAt
​string · date-time · required
GET/v2/runs/{id}
curl https://api.lelemon.cl/v2/runs/:id \ --header 'Authorization: Bearer <token>'
Example Responses
{ "object": "run", "id": "run_5RvP2aKq9XwLmN3tYbZc01", "agentId": "agt_5RvP2aKq9XwLmN3tYbZc01", "status": "running", "stopReason": "rounds", "question": "question", "rounds": 0, "limits": { "maxRounds": 0, "maxMinutes": 0 }, "result": { "summary": "summary", "checks": [ "string" ], "partial": "partial", "error": "error", "errorCode": "budget_exceeded" }, "cancelRequested": true, "schedule": "sch_5RvP2aKq9XwLmN3tYbZc01", "actor": { "id": "user_8841", "role": "end_user", "name": "Ana Pérez", "declaredBy": "key_5RvP2aKq9XwLmN3tYbZc01" }, "createdAt": "2024-08-25T15:00:00Z", "startedAt": "2024-08-25T15:00:00Z", "finishedAt": "2024-08-25T15:00:00Z", "updatedAt": "2024-08-25T15:00:00Z" }
json
application/json

Cancel a run

POST
https://api.lelemon.cl
/v2/runs/{id}/cancel
Bearer (API key)

If nobody is running it, it ends canceled now. If a worker is running it, cancelRequested turns true and it ends canceled when its next round starts: what it was doing finishes. A run that already ended answers 409 run_finished.

Required scope: runs:write.

Cancel a run › path Parameters

id
​string · pattern: ^run_[0-9A-Za-z]{22}… · required

The id of the run (run_…).

Cancel a run › Headers

Lelemon-Subaccount
​string · pattern: ^sub_[0-9A-Za-z]{22}…

The subaccount (sub_…) this request acts on. Only for the keys of a platform account; without it the request acts on the account itself.

Idempotency-Key
​string · minLength: 1 · maxLength: 255

Makes the request safe to retry. Once it starts running, its final response (2xx, 4xx or 5xx) is kept for 24 hours and the same key gets it back, without repeating the effect. A request rejected before it runs leaves the key free. A replayed create omits the secret. The same key with a different request is rejected with 409 idempotency_key_reused.

Cancel a run › Responses

Run
object
​string · enum · required
Enum values:
run
id
​string · required
agentId
​string · required
status
​string · enum · required

running: working, or in the queue. waiting_for_answer: paused to ask; question has it, answer it with POST /v2/runs/{id}/answer. completed_unverified: the agent says it finished and nobody has checked it, so do not read it as done. completed: a verifier checked it (it does not happen yet). stopped: the run was cut before the agent declared the job done, by a limit (rounds, time or the spending limit Lelemon sets for every run) or because the agent never concluded (no_conclusion) or repeated itself (loop); stopReason says which and result.partial keeps the last thing the agent wrote. failed: an error; result.error says what, or stopReason abandoned if nobody answered the pause in 30 days. canceled: you canceled it.

Enum values:
running
waiting_for_answer
completed_unverified
stopped
failed
canceled
stopReason
​string | null · enum · required

Why the run ended without finishing. Set with status stopped, and with status failed for abandoned. rounds: the run used all the rounds allowed by limits.maxRounds. cost: the run reached the spending limit Lelemon sets for every run. time: the run lasted all the minutes allowed by limits.maxMinutes. no_conclusion: the agent answered four times in a row without calling its finish action, so it never declared the job done. Its last answer is in result.partial. loop: the agent kept repeating the same action, so the run was cut. abandoned: with status failed: the agent asked a question and nobody answered it in 30 days.

Enum values:
rounds
cost
time
no_conclusion
loop
abandoned
question
​string | null · required

With status waiting_for_answer, what the agent asked. Answer it with POST /v2/runs/{id}/answer.

rounds
​integer · required

Rounds taken so far.

​RunLimits · required
​required
cancelRequested
​boolean · required

true if a cancel was asked. While a worker runs it, the run stops at the start of its next round.

schedule
​string | null · required

The scheduled task that started this run. null for a run you created with POST /v2/agents/{id}/runs.

​required

The person the run works for, as declared by the key that created it. null when the run works as the key itself.

createdAt
​string · date-time · required
startedAt
​string | null · date-time · required
finishedAt
​string | null · date-time · required
updatedAt
​string · date-time · required
POST/v2/runs/{id}/cancel
curl https://api.lelemon.cl/v2/runs/:id/cancel \ --request POST \ --header 'Authorization: Bearer <token>'
Example Responses
{ "object": "run", "id": "run_5RvP2aKq9XwLmN3tYbZc01", "agentId": "agt_5RvP2aKq9XwLmN3tYbZc01", "status": "running", "stopReason": "rounds", "question": "question", "rounds": 0, "limits": { "maxRounds": 0, "maxMinutes": 0 }, "result": { "summary": "summary", "checks": [ "string" ], "partial": "partial", "error": "error", "errorCode": "budget_exceeded" }, "cancelRequested": true, "schedule": "sch_5RvP2aKq9XwLmN3tYbZc01", "actor": { "id": "user_8841", "role": "end_user", "name": "Ana Pérez", "declaredBy": "key_5RvP2aKq9XwLmN3tYbZc01" }, "createdAt": "2024-08-25T15:00:00Z", "startedAt": "2024-08-25T15:00:00Z", "finishedAt": "2024-08-25T15:00:00Z", "updatedAt": "2024-08-25T15:00:00Z" }
json
application/json

Answer a run that asked something

POST
https://api.lelemon.cl
/v2/runs/{id}/answer
Bearer (API key)

The paused run resumes with your answer as context for its next round, and the agent sees who answered. Not idempotent: a question is answered once, and answering a run that is not paused answers 409 run_not_waiting.

Required scope: runs:write.

Answer a run that asked something › path Parameters

id
​string · pattern: ^run_[0-9A-Za-z]{22}… · required

The id of the run (run_…).

Answer a run that asked something › Headers

Lelemon-Subaccount
​string · pattern: ^sub_[0-9A-Za-z]{22}…

The subaccount (sub_…) this request acts on. Only for the keys of a platform account; without it the request acts on the account itself.

Idempotency-Key
​string · minLength: 1 · maxLength: 255

Makes the request safe to retry. Once it starts running, its final response (2xx, 4xx or 5xx) is kept for 24 hours and the same key gets it back, without repeating the effect. A request rejected before it runs leaves the key free. A replayed create omits the secret. The same key with a different request is rejected with 409 idempotency_key_reused.

Answer a run that asked something › Request Body

AnswerRun
answer
​string · minLength: 1 · maxLength: 4000 · required

The answer to what the agent asked.

​object

The person in your system who answered. Lelemon records it as declared by this key, not verified, and the agent sees who answered. Without it the answer comes from your key.

Answer a run that asked something › Responses

Run
object
​string · enum · required
Enum values:
run
id
​string · required
agentId
​string · required
status
​string · enum · required

running: working, or in the queue. waiting_for_answer: paused to ask; question has it, answer it with POST /v2/runs/{id}/answer. completed_unverified: the agent says it finished and nobody has checked it, so do not read it as done. completed: a verifier checked it (it does not happen yet). stopped: the run was cut before the agent declared the job done, by a limit (rounds, time or the spending limit Lelemon sets for every run) or because the agent never concluded (no_conclusion) or repeated itself (loop); stopReason says which and result.partial keeps the last thing the agent wrote. failed: an error; result.error says what, or stopReason abandoned if nobody answered the pause in 30 days. canceled: you canceled it.

Enum values:
running
waiting_for_answer
completed_unverified
stopped
failed
canceled
stopReason
​string | null · enum · required

Why the run ended without finishing. Set with status stopped, and with status failed for abandoned. rounds: the run used all the rounds allowed by limits.maxRounds. cost: the run reached the spending limit Lelemon sets for every run. time: the run lasted all the minutes allowed by limits.maxMinutes. no_conclusion: the agent answered four times in a row without calling its finish action, so it never declared the job done. Its last answer is in result.partial. loop: the agent kept repeating the same action, so the run was cut. abandoned: with status failed: the agent asked a question and nobody answered it in 30 days.

Enum values:
rounds
cost
time
no_conclusion
loop
abandoned
question
​string | null · required

With status waiting_for_answer, what the agent asked. Answer it with POST /v2/runs/{id}/answer.

rounds
​integer · required

Rounds taken so far.

​RunLimits · required
​required
cancelRequested
​boolean · required

true if a cancel was asked. While a worker runs it, the run stops at the start of its next round.

schedule
​string | null · required

The scheduled task that started this run. null for a run you created with POST /v2/agents/{id}/runs.

​required

The person the run works for, as declared by the key that created it. null when the run works as the key itself.

createdAt
​string · date-time · required
startedAt
​string | null · date-time · required
finishedAt
​string | null · date-time · required
updatedAt
​string · date-time · required
POST/v2/runs/{id}/answer
curl https://api.lelemon.cl/v2/runs/:id/answer \ --request POST \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <token>' \ --data '{ "answer": "Use the checking account.", "actor": { "id": "user_9020", "role": "staff" } }'
Example Request Body
{ "answer": "Use the checking account.", "actor": { "id": "user_9020", "role": "staff" } }
json
application/json
Example Responses
{ "object": "run", "id": "run_5RvP2aKq9XwLmN3tYbZc01", "agentId": "agt_5RvP2aKq9XwLmN3tYbZc01", "status": "running", "stopReason": "rounds", "question": "question", "rounds": 0, "limits": { "maxRounds": 0, "maxMinutes": 0 }, "result": { "summary": "summary", "checks": [ "string" ], "partial": "partial", "error": "error", "errorCode": "budget_exceeded" }, "cancelRequested": true, "schedule": "sch_5RvP2aKq9XwLmN3tYbZc01", "actor": { "id": "user_8841", "role": "end_user", "name": "Ana Pérez", "declaredBy": "key_5RvP2aKq9XwLmN3tYbZc01" }, "createdAt": "2024-08-25T15:00:00Z", "startedAt": "2024-08-25T15:00:00Z", "finishedAt": "2024-08-25T15:00:00Z", "updatedAt": "2024-08-25T15:00:00Z" }
json
application/json

Team questionsSchedules