Loopfour
API reference

Agents API

Create and run agents with the Agents API, with the parameters, request bodies and responses of each endpoint and the scopes they require.

An agent is a saved AI configuration: a system prompt, a model and an optional output schema. Workflows use agents in the AI Agent block. These endpoints manage your company's custom agents and run them outside a workflow.

ScopeEndpoints
workflows:readList, get, list executions
workflows:writeCreate, update, delete
workflows:executeTest, execute

Core agents

Loopfour provides built-in core agents to every company. They can be read and used in an AI Agent step, but not changed, deleted or run through this API.

IDNameType
agent_extractionUniversal Extraction Agentextraction
agent_contentContent Generation Agentcontent
agent_transformData Transformation Agenttransform
agent_decisionDecision & Routing Agentdecision

Agent object

FieldTypeMeaning
idstringAgent ID. Core agents use the IDs above
namestring1 to 255 characters, unique within your company
descriptionstring or nullUp to 1,000 characters
typestringextraction, decision, content, transform, code, classification or custom
providerstringopenai or anthropic
modelstringgpt-5.6-sol (with openai) or claude-opus-5 (with anthropic)
statusstringactive or deprecated
versionintegerGoes up by 1 on each update
scopestringglobal for core agents, company for yours
isBuiltInbooleantrue for core agents

Get also returns the prompt and generation settings.

List agents

GET /api/v1/agents
Query parameterTypeDefaultMeaning
typestringAn agent type
statusstringactive or deprecated
searchstringMatch on the name
includeBuiltInbooleanfalsePut the core agents at the start of the first page
limitinteger201 to 100
cursorstringmeta.cursor from the previous page
curl 'https://workflow.loopfour.ai/api/v1/agents?type=extraction&includeBuiltIn=true' \
  -H 'x-api-key: wfk_live_your_api_key'

Create an agent

POST /api/v1/agents
FieldTypeRequiredMeaning
namestringYes1 to 255 characters. A name already used in your company returns 400
typestringYesAn agent type
systemPromptstringYes1 to 50,000 characters
descriptionstringNoUp to 1,000 characters
providerstringNoDefault openai
modelstringNoDefault gpt-5.6-sol. Must match the provider
userPromptstringNoUp to 50,000 characters
outputSchemaobjectNoJSON Schema for structured output
temperaturenumberNo0 to 2, default 0.7
maxTokensintegerNo1 to 128,000, default 4096
topPnumberNo0 to 1
curl -X POST 'https://workflow.loopfour.ai/api/v1/agents' \
  -H 'x-api-key: wfk_live_your_api_key' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Vendor bill extractor",
    "type": "extraction",
    "provider": "anthropic",
    "model": "claude-opus-5",
    "systemPrompt": "Extract the vendor name, bill number, bill date, due date and total from the vendor bill text.",
    "outputSchema": {
      "type": "object",
      "properties": {
        "vendorName": { "type": "string" },
        "billNumber": { "type": "string" },
        "billDate": { "type": "string" },
        "dueDate": { "type": "string" },
        "total": { "type": "number" }
      },
      "required": ["vendorName", "total"]
    },
    "temperature": 0
  }'

The response is 201 with the new agent. A provider and model that do not pair return 400.

Get an agent

GET /api/v1/agents/{id}

id is a custom agent ID or a core agent ID such as agent_extraction.

Update an agent

PUT /api/v1/agents/{id}

Send any of the create fields. Each update raises version by 1. Core agents and agents of another company return 400 (Cannot modify built-in agents, Cannot modify agents not owned by your company).

Delete an agent

DELETE /api/v1/agents/{id}

Marks a custom agent deprecated. The response is { "deleted": true }. Core agents return 400.

Test an agent

POST /api/v1/agents/{id}/test
FieldTypeRequiredMeaning
inputobjectYesInput variables for the prompt
userMessagestringNoMessage to send

Runs a custom agent once and records the execution. For a core agent the response is a message that core agents can be tested only in a workflow.

Execute an agent

POST /api/v1/agents/{id}/execute
FieldTypeRequiredMeaning
inputobjectYesInput variables for the prompt
userMessagestringNoMessage to send
workflowRunIdstring (UUID)NoLink the execution to a run
overridesobjectNotemperature, maxTokens, model, customInstructions (up to 10,000 characters) and examples (up to 10) for this execution only
curl -X POST 'https://workflow.loopfour.ai/api/v1/agents/7c9e6679-7425-40de-944b-e07fc1f90ae7/execute' \
  -H 'x-api-key: wfk_live_your_api_key' \
  -H 'Content-Type: application/json' \
  -d '{ "input": {}, "userMessage": "Bill INV-2291 from Acme Supplies, dated 2026-02-01, due 2026-03-03, total 4,180.00" }'
{
  "success": true,
  "data": {
    "executionId": "1b4e28ba-2fa1-41d2-883f-0016d3cca427",
    "status": "completed",
    "output": {
      "vendorName": "Acme Supplies",
      "billNumber": "INV-2291",
      "billDate": "2026-02-01",
      "dueDate": "2026-03-03",
      "total": 4180
    },
    "content": "...",
    "usage": { "promptTokens": 412, "completionTokens": 58, "totalTokens": 470 },
    "cost": { "inputCost": 0.0021, "outputCost": 0.0015, "totalCost": 0.0036, "currency": "USD" },
    "latencyMs": 1830,
    "model": "claude-opus-5",
    "provider": "anthropic"
  }
}

output is the structured result when the agent has an outputSchema, otherwise { "content": "..." }. A core agent returns 400 BUILT_IN_AGENT. A model failure returns 500 AGENT_EXECUTION_ERROR with error.executionId.

List executions

GET /api/v1/agents/{id}/executions

Takes limit (default 20, maximum 100) and cursor. Each entry has id, status, input, output, error, usage, estimatedCost, latencyMs, model, provider, workflowRunId and createdAt.

Errors

StatusCodeCause
400BAD_REQUESTDuplicate name, unsupported provider and model pair, or a change to a core or another company's agent
400BUILT_IN_AGENTExecute called on a core agent
400ZodError in error.nameBody or query does not match the schema
401UNAUTHORIZEDMissing or invalid API key
403FORBIDDENKey lacks the scope
404NOT_FOUNDAgent not found
500AGENT_EXECUTION_ERRORThe model call failed

On this page