Skip to content

API Reference — Agent Endpoints

All management endpoints require JWT authentication. The execution endpoint uses API key or public access.

Base URL: https://api.aerostack.dev/api/agent-endpoints

GET /api/agent-endpoints
Authorization: Bearer <JWT>

Returns all agent endpoints owned by the authenticated user.

Response (200):

{
"endpoints": [
{
"id": "aep_7f3a2b9c1d4e5f6a8b",
"owner_id": "usr_abc123",
"workspace_id": "ws_def456",
"name": "summarizer",
"slug": "summarizer",
"description": "Summarizes text input",
"agent_type": "extractor",
"system_prompt": "You are a concise summarizer...",
"llm_provider": "openai",
"llm_model": "gpt-4o-mini",
"max_tokens": 4096,
"temperature": 0.3,
"output_format": "text",
"max_tool_calls": 10,
"timeout_ms": 30000,
"enable_streaming": 0,
"async_mode": 0,
"auth_mode": "api_key",
"price_per_run_cents": 0,
"status": "active",
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
}
]
}

POST /api/agent-endpoints
Authorization: Bearer <JWT>
Content-Type: application/json

Request Body:

FieldTypeRequiredDefaultDescription
namestringYes1-100 characters
workspace_idstringYesMCP workspace ID (1-100 chars)
system_promptstringYesAgent instructions (1-10000 chars)
descriptionstringNonullShort description (max 500 chars)
slugstringNoauto from nameURL slug (max 60 chars)
agent_typestringNo"extractor"extractor, actor, or pipeline (informational)
llm_providerstringNo"openai"openai, anthropic, gemini, groq, workers-ai, custom
llm_modelstringNo"gpt-4o-mini"Model identifier (max 100 chars)
llm_api_keystringNoplatform keyYour LLM provider API key (stored securely)
max_tokensintegerNo4096100-32768
temperaturenumberNo0.30-2
input_schemaobjectNonullJSON Schema for expected input (informational)
output_schemaobjectNonullJSON Schema for structured output (used with json format)
output_formatstringNo"text"text, json, or markdown
max_tool_callsintegerNo101-50. Controls max agentic loop iterations
timeout_msintegerNo300001000-120000 (hard cap at 60000 during execution)
enable_streamingbooleanNofalseReturn SSE stream instead of JSON
async_modebooleanNofalseNot yet implemented (returns 501)
auth_modestringNo"api_key"api_key or public
price_per_run_centsintegerNo00-10000. Per-execution charge from owner’s wallet

Response (201):

{
"endpoint": { "id": "aep_...", "name": "...", "slug": "...", "..." : "..." },
"api_key": "aek_a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"run_url": "/api/run/summarizer"
}

GET /api/agent-endpoints/:id
Authorization: Bearer <JWT>

Returns a single endpoint. Returns 404 if not found or not owned by the authenticated user.

Response (200):

{
"endpoint": { "id": "aep_...", "..." : "..." }
}

PATCH /api/agent-endpoints/:id
Authorization: Bearer <JWT>
Content-Type: application/json

All fields from the create schema are optional. workspace_id cannot be changed after creation.

Request Body (all fields optional):

FieldTypeDescription
namestring1-100 characters
descriptionstringMax 500 chars
system_promptstring1-10000 chars
agent_typestringextractor, actor, or pipeline
llm_providerstringProvider enum
llm_modelstringModel identifier
max_tokensinteger100-32768
temperaturenumber0-2
input_schemaobjectJSON Schema
output_schemaobjectJSON Schema
output_formatstringtext, json, or markdown
max_tool_callsinteger1-50
timeout_msinteger1000-120000
enable_streamingbooleanSSE mode
async_modebooleanNot yet implemented
auth_modestringapi_key or public
price_per_run_centsinteger0-10000

Response (200):

{
"endpoint": { "id": "aep_...", "..." : "..." }
}

DELETE /api/agent-endpoints/:id
Authorization: Bearer <JWT>

Permanently deletes the endpoint and all its run history.

Response (200):

{
"deleted": true
}

POST /api/agent-endpoints/:id/activate
Authorization: Bearer <JWT>

Sets the endpoint status to active. Only active endpoints can be executed.

Response (200):

{
"status": "active"
}

POST /api/agent-endpoints/:id/regenerate-key
Authorization: Bearer <JWT>

Generates a new API key and invalidates the previous one.

Response (200):

{
"api_key": "aek_new_key_shown_once"
}

GET /api/agent-endpoints/:id/runs?limit=50
Authorization: Bearer <JWT>
Query ParamTypeDefaultMax
limitinteger50100

Response (200):

{
"runs": [
{
"id": "run_8e4f2a1b3c5d7e9f0a",
"endpoint_id": "aep_7f3a2b9c1d4e5f6a8b",
"input": "Summarize this...",
"output": "The article covers...",
"tool_calls": "[{\"name\":\"search\",\"success\":true}]",
"tokens_input": 312,
"tokens_output": 67,
"cost_cents": 0.08,
"latency_ms": 1456,
"status": "success",
"caller_ip": "203.0.113.42",
"created_at": "2026-03-15T10:23:45Z"
}
]
}

POST /api/agent-endpoints/:id/test
Authorization: Bearer <JWT>
Content-Type: application/json

Executes the endpoint using your JWT session (no API key needed). Rate limited to 10 per minute. Logged with status: "test" and caller_ip: "dashboard".

Request Body:

{
"input": "Your test input here"
}

Response (200):

{
"output": "Agent response...",
"usage": {
"tokens_input": 245,
"tokens_output": 89,
"cost_cents": 0.12,
"latency_ms": 1823
}
}

GET /api/agent-endpoints/templates/list?type=agent

No authentication required.

Query ParamTypeValues
typestringagent or webhook

Response (200):

{
"templates": [
{
"id": "tpl_invoice_parser",
"name": "Invoice Parser",
"description": "Extract structured data from invoice text",
"type": "agent",
"category": "extractor",
"system_prompt": "You are an invoice parser...",
"suggested_mcps": "[\"storage\"]",
"input_schema": null,
"output_schema": "{\"type\":\"object\",\"properties\":{...}}",
"popularity": 95,
"created_at": "2026-03-01T00:00:00Z"
}
]
}

Pre-built agent templates include: Invoice Parser, Lead Enricher, Support Ticket Classifier, PR Code Reviewer, Resume Screener, SQL Query Generator, and Email Drafter.


POST /api/run/:slug
Authorization: Bearer <API_KEY> (or X-API-Key header, or no auth for public)
Content-Type: application/json

Request Body:

{
"input": "Your input text or prompt"
}

Alternative input fields (all equivalent): message, text, prompt. If none are present, the entire body is stringified.

Maximum request body size: 2 MB.

Response (200) — Sync Mode:

{
"output": "Agent response text or parsed JSON object",
"raw_output": "Original LLM text (only present when output is parsed JSON)",
"tool_calls": [
{
"tool": "github_list_issues",
"success": true,
"latency_ms": 234
}
],
"usage": {
"tokens_input": 1245,
"tokens_output": 189,
"cost_cents": 0.34,
"latency_ms": 2891,
"iterations": 2
}
}

Response — Streaming Mode (SSE):

See SSE Streaming for the full event format.

Error Responses:

StatusBodyCondition
400{"error": "Input required..."}No input provided
401{"error": "API key required..."}Missing API key (api_key mode)
401{"error": "Invalid API key"}Wrong API key
403{"error": "...unsupported auth mode"}Auth mode not in allowlist
404{"error": "Agent endpoint not found or not active"}Invalid slug or inactive
413{"error": "Request body too large (max 2MB)"}Body exceeds 2 MB
429{"error": "Rate limited..."}Rate limit exceeded
501{"error": "Async mode is not yet available..."}async_mode enabled

CodeMeaning
400Validation failed or missing input
401Authentication failed
403Unsupported auth mode
404Not found or not owner
413Request body too large
429Rate limited
501Feature not yet implemented