Execute a SQL query against your analytics data
Runs a single ClickHouse SELECT (or WITH … SELECT) against your organization's analytics views. Before writing a query, call getAnalyticsSchema (GET /schema) for the available views and columns, and getSignalsMetadata (GET /signals/metadata) for the JSON paths inside fact_signal.data. Results are automatically scoped to your organization — no org filter is needed or possible. Only SELECT/WITH statements are accepted.
Conventions: monetary amounts are minor units (cents — divide by 100 for the major unit); most are integers, but fact_cost.cost_amount is fractional cents (Decimal) since a single AI call usually costs less than a cent; 64-bit integers (counts, ids, amounts) are returned as JSON strings to preserve precision, so parse them client-side; Decimal columns (fractional cents, and credit amounts, which are counts of credits rather than cents and are never divided by 100) come back as JSON numbers instead, so a value beyond 2^53 is already rounded — select toString(col) when you need its exact digits. Query signal payloads via JSON paths, e.g. SELECT data.country::String AS country, count() FROM fact_signal GROUP BY country.
Limits: 30 seconds of execution time and 10,000 result rows (truncation is flagged via meta.truncated). Queries exceeding the 4 GB memory allowance return HTTP 422 with code QUERY_MEMORY_LIMIT_EXCEEDED. Prefer aggregates and a created_at date filter on large tables — this endpoint is for interactive analytics, not bulk export.
Request
- Base URL: https://api.agentpaid.io/api/v2
- URL: https://api.agentpaid.io/api/v2/analytics/query
- Auth: HTTP bearer
Request body
Response
200
Changes
No recorded changes to this operation across all 1 revision of this API.