Easymailing
A I agents

Ask an AI agent to do a task

POST /ai_agents/{uuid}/runs

POST/ai_agents/{uuid}/runs

Gives a task to a published agent and starts it. It is ASYNCHRONOUS: the answer is immediate with the run in queued state (202); the agent works in the background, searching, reading pages and reading the CRM within its limits, and the result is read with get_ai_agent_run until state is completed or stopped. A task usually takes under two minutes.

The answer is free text, or, with response_format: fields, one validated value per field you define. The agent always gives the sources it used and the tools it called.

When to use: When the user asks to delegate research or analysis to an agent: «ask the Investigador to look at arenalsalud.es». Pass record when the task is about a contact, company or opportunity. Use version: draft to try an agent that is still being improved.

When not to use: For a single answer that needs no tools or search, use the AI of the product directly. To have the result written into the CRM, create a note or update the record yourself with the answer (create_note, update_company): through the API an agent only reads. For automatic processing of every new lead, use an automation with an «AI agent» step in Easymailing, not repeated calls here. Do not repeat the call when it seems slow: poll get_ai_agent_run, or send a client_request_id.

Side effects: IT SPENDS AI BALANCE. The agent is charged after each turn, in the same shared balance as Maia and the automations, up to limits.max_cost for this task, up to the cap of the agent (period_cap) and up to the cap for all agents of the account; extra spending is used only up to its limit. Before starting, the balance, the caps and the plan are checked, and there must be at least max_cost left. A run of the draft is charged as a test. The agent only reads: searching the web and opening pages sends nothing to anyone and writes nothing in the CRM. Its tools that write never write in a run asked through the API, whatever their mode: as in the «Test» panel of Easymailing, they say what they would have done (in tools_used), and the run never waits for an approval. Runs are kept for 30 days. At most 5 agents work at the same time per account; the rest wait in queued.

Permissions: Requires the automations.read capability. It also needs AI in the plan (maia.access) and CRM Pro, and the person must be allowed to use the agent: with access team, the automations.work capability; with access managers, automations.manage. version: draft always needs automations.manage. The agent works with the permissions of the person who owns the token (never more): with crm_read it only sees the records that person can see.

Authorization

X-Auth-Token<token>

Value for the X-Auth-Token header parameter.

In: header

Path Parameters

uuid*string

UUID of the agent. Get it from list_ai_agents.

Formatuuid

Request Body

The new AiAgentRun resource

TypeScript Definitions

Use the request body type in TypeScript.

Runs of an AI agent asked through the public API (ADR-0195): asynchronous tasks on the same engine as the «Test» panel and the «AI agent» step (AiAgentTestRun with origin api and its AiAgentRun). Generated from the approved proposal (2026-11-16) by trabajo/2026-11-15-agentes-ia/fase-4-api-publica/tools/gen_ai_agents_api.py; the texts are the proposal's, with the deviations the code imposes (notas.md § 10). agentUuid is only the path.

Response Body

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

curl -X POST "https://api.easymailing.com/ai_agents/6e2f0a97-4b1c-4d35-9a8e-2c7d5f1b3e40/runs" \  -H "X-Auth-Token: YOUR_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "task": "string",    "record": "/entity/1",    "response_format": "text",    "fields": [      {}    ],    "version": "published",    "client_request_id": "string",    "confirmed": false  }'
{  "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",  "agent": "/entity/1",  "agent_version": 1,  "source": "published",  "state": "queued",  "stop_cause": "ai_credits_exhausted",  "limit_reached": "cost",  "task": "string",  "record": "/entity/1",  "response_format": "text",  "answer_text": "string",  "answer_fields": {},  "sources": [    {}  ],  "tools_used": [    {}  ],  "spent": {},  "duration_ms": 0,  "retry_after_ms": 0,  "created_by": {},  "created_at": "2019-08-24T14:15:22Z",  "started_at": "2019-08-24T14:15:22Z",  "finished_at": "2019-08-24T14:15:22Z",  "kept_until": "string"}