Agent Quickstart
This guide is the fastest deterministic path for agents to run Auto end-to-end.
Use this with:
Required Sequence (Enforced)
For API key lifecycle calls, use this order exactly:
POST /v2/auto/queries/validatePOST /v2/auto/queriesPOST /v2/auto/queries/{queryId}/cancelonly when status isactiveorrecurringDELETE /v2/auto/queries/{queryId}only when status is terminal (triggered,expired,cancelled,failed)
If actions include market_order or limit_order, preflight GET /v2/auto/exchanges before create.
Intent Routing (Strict)
| Intent | Route to | Minimum payload contract |
|---|---|---|
| Account-anchored post intent | source: "tweet" | args.username (no @), args.text, args.minConfidence: 80 |
| World event intent | source: "news" | args.text, args.minConfidence: 80 |
| Fuzzy world-state predicate (not naturally tweet/news) | source: "llm" | method: "athena_condition", args.query, args.period >= "1h" |
1) Pick Access Mode
| Mode | Route Prefix | Primary Auth |
|---|---|---|
| API key | /v2/auto/* | x-elfa-api-key (+ HMAC on trade-action mutations and exchange linking; notification-only mutations skip HMAC) |
| x402 | /x402/v2/auto/* | x402 payment header (+ x-elfa-agent-secret on query lifecycle routes) |
2) Load Endpoint Metadata (Machine-Readable)
Manifest URL:
/agent/endpoints.manifest.json
Each entry provides:
- method/path
- docs route
- required headers
- HMAC requirement and mounted signature path template
- payment requirement
- request and response examples
3) Call Sequence (Recommended)
API key mode (/v2/auto/*)
- If query uses
market_orderorlimit_order, verify readiness first:GET /exchanges(and connect if needed via portal flow orPOST /exchanges). POST /chatPOST /queries/validatePOST /queriesGET /queries/{queryId}/stream(orGET /queries/{queryId}polling)GET /queries/{queryId}/sessionsandGET /queries/{queryId}/sessions/{sessionId}when usingllmaction
x402 mode (/x402/v2/auto/*)
POST /chatPOST /queries/validatePOST /queriesGET /queries/{queryId}/stream(orPOST /queries/{queryId}polling)POST /queries/{queryId}/sessionsandPOST /queries/{queryId}/sessions/{sessionId}when usingllmaction
4) Auth Rules You Must Enforce
API key mode
- Always send
x-elfa-api-key. - On mutation routes, also send
x-elfa-timestampandx-elfa-signature. - Sign payload as:
timestamp + method + mounted_path + body
Mounted path example:
- request URL:
/v2/auto/queries - signed path:
/queries
x402 mode
- Send payment header (
PAYMENT-SIGNATUREpreferred;X-PAYMENTlegacy). - Persist one stable
x-elfa-agent-secretper agent identity. - Do not rotate agent secret per request/session.
5) Runtime Pattern (Production)
- Validate before create.
- For trade actions, preflight
GET /exchangesand require active connection before create. - Prefer webhook/SSE for real-time delivery.
- Deduplicate by event ID.
- Hand off to a background runner for policy and execution.
Execution Monitoring (Trade Actions)
- Poll
GET /queries/{queryId}to inspect the latestexecutionsarray and error payloads. - Use
GET /executions(orGET /executions/{executionId}) for execution-centric views and debugging. - Treat failed execution entries as actionable operational events (credentials, balances, exchange readiness, policy guards).
For implementation details:
6) Failure Handling Order
- Retry transient network errors with backoff.
- On validation failure (
400/422), repair query and re-validate. - On auth failures (
401/403), refresh credentials or enablement state. - On x402 payment failure (
402), re-price and retry with valid payment payload.