Skip to main content
POST
Run a scoped analytics query

Authorizations

x-api-key
string
header
required

A server-side Bily API key created under Settings > AI tools > Access keys. Select the intended workspace before creating it.

Headers

x-bily-organization-id
string

An organization ID returned by GET /context or GET /organizations. Omit it when a scoped key supplies the organization. Otherwise provide it when no organization is selected.

Example:

"org_01J8W7T9G3E6ZQ4M2K5N8P1R0S"

Path Parameters

resourceUrl
string
required

The canonical website or Shopify hostname returned by customer context. The hostname determines the resource type.

Example:

"store.example.com"

Body

application/json
dataset
enum<string>
required
Available options:
customer_ltv,
cohorts
sql
string
required

Read-only SQL that starts with SELECT or WITH and reads from the scoped _ alias.

Maximum string length: 5000
Example:

"SELECT customer_id, total_revenue FROM _ ORDER BY total_revenue DESC LIMIT 10"

maxRows
integer
default:250
Required range: 1 <= x <= 2000
inputLimit
integer

customer_ltv defaults to 50000 and allows at most 100000; cohorts defaults to 1000 and allows at most 5000. Small LTV limits select a top-revenue sample rather than the full customer population.

Required range: 1 <= x <= 100000
page
integer
default:1
deprecated

Compatibility field echoed in the response. It does not paginate this query; use SQL and maxRows to bound the returned rows.

Required range: 1 <= x <= 10000
startDate
string<date>
required if dataset = cohorts

Required for cohorts. For customer_ltv, scopes customers by first-order date; revenue remains lifetime revenue.

endDate
string<date>
required if dataset = cohorts

Required for cohorts. Must be on or after startDate.

Response

Request completed successfully.

dataset
enum<string>
required
Available options:
customer_ltv,
cohorts
resourceUrl
string
required
resourceType
enum<string>
required
Available options:
website,
shopify-store
storeUrl
string
required
maxRows
integer
required
inputLimit
integer
required
page
integer
required
adAccountScope
integer
required
Required range: x >= 0
meta
object[]
required
data
object[]
required
rows
integer
required
statistics
object | null
required