v2 Auto

Create Query

Create and activate a conditional query.

Required Sequence (Enforced)

Call POST /v2/auto/queries/validate immediately before create.

Lifecycle after create:

  1. POST /v2/auto/queries/{queryId}/cancel while status is active.
  2. DELETE /v2/auto/queries/{queryId} only when status is terminal (triggered, expired, cancelled, failed).

Allowed action types (API key mode): webhook, notify, telegram_bot, llm.

Cost

Simulation-driven estimate (reference values):

  • baseline: 5 credits ($0.0725)
  • fast call: +5 credits (+$0.0725)
  • expert call: +18 credits (+$0.261)

Auth

Required header:

x-elfa-api-key: <api_key>

Request Example

{
  "query": {
    "conditions": {
      "AND": [
        {
          "source": "price",
          "method": "current",
          "args": { "symbol": "BTC" },
          "operator": ">",
          "value": 100000
        }
      ]
    },
    "actions": [
      {
        "stepId": "step_1",
        "type": "notify",
        "params": { "message": "BTC crossed target" }
      }
    ],
    "expiresIn": "24h"
  },
  "title": "BTC breakout alert",
  "description": "Notify when BTC is above 100k"
}

Response Example (201)

{
  "queryId": "a12d20ff-6cb2-433e-afed-cc2e6a0380b6",
  "status": "active",
  "estimatedCredits": 116,
  "simulationLlmCallsEstimate": {
    "conditionCallsUpperBound": 1,
    "actionCallsUpperBound": 0,
    "conditionCallsBySpeed": {"fast": 1, "expert": 0, "adaptive": 0},
    "actionCallsBySpeed": {"fast": 0, "expert": 0, "adaptive": 0},
    "autoActionCallsBySpeed": {"fast": 0, "expert": 0, "adaptive": 0}
  }
}

Best practice: call validate first, then create. After creation, wire notifications (webhook, telegram_bot, or SSE) to a background runner.

post/v2/auto/queries

Request

  • Base URL: https://api.elfa.ai
  • URL: https://api.elfa.ai/v2/auto/queries
  • Auth: API key in header x-elfa-api-key

Request body

queryJsonObject required

Construct a type with a set of properties K of type T

titlestring

Short human-readable title for the query.

Surfaced back in outbound notifications (Telegram, webhook, notify) so the recipient immediately recognizes what fired — recipients often see an alert hours or days after the query was created. Strongly recommended for agent-built queries.

descriptionstring

1–2 sentence description of the thesis or intent behind the trigger.

Surfaced alongside the title in outbound notifications so the recipient understands why the trigger was set up. Write it as if the recipient has forgotten they set this up — because they often have.

Example request

{
  "title": "BTC breakout alert",
  "description": "Notify when BTC is above 100k so I can review the breakout setup."
}

Response

Ok

ApiKeyCreateQueryResponse required

Changes

No recorded changes to this operation across all 1 revision of this API.