Skip to main content
POST
Create a custom result query

Authorizations

Authorization
string
header
required

Bearer tokens created in the ABConvert admin under Settings → MCP & API Access. Scopes: read_experiments and write_experiments (write implies read; the default is read). See Authentication for which scope each request needs.

Path Parameters

id
string
required

The test's numeric ID as a string, for example "3021".

Pattern: ^[0-9]+$
Example:

"3021"

Body

application/json
breakdown
enum<string>[]

Group the rows by one or two dimensions. Order doesn't matter: it names a query, and the same pair in either order is the same query. Naming the same dimension twice returns 422 duplicate_breakdown_dimension. Grouping by product_id also needs product_group_id (that group is what the products are resolved from), and without it the request returns 422 product_id_requires_product_group.

Required array length: 1 - 2 elements

A dimension a custom result query can group by. product_id requires product_group_id, which scopes it to that product group's products. page_url, template, and click_destination require metricSet: engagement.

Available options:
date,
country,
market,
device,
visitor_type,
traffic_channel,
traffic_platform,
referral_domain,
landing_page,
utm_source,
utm_medium,
utm_campaign,
utm_term,
utm_content,
product_id,
page_url,
template,
click_destination
metricSet
enum<string>
default:core

Selects the metric registry. engagement returns page views, click-throughs, bounce rate, and average staying time, and enables page/template/destination breakdowns. Any other value returns 422 invalid_metric_set.

Available options:
core,
engagement
customEventMetricId
string

Rule id for the custom-event metric the caller intends to inspect. The query response still returns the complete custom_events collection, so this selector needs no query-job state and does not replace the experiment's configured primary metric. For backward compatibility, it also supplies the segment rule when customEventSegment is present and customEventRuleId is omitted. An unknown or ineligible rule returns 400 invalid_custom_event_metric. If custom-event analytics are unavailable for the shop, the same code returns 404.

Pattern: ^[a-z0-9_]+$
customEventRuleId
string

Rule id for a custom-event visitor segment. Supply together with customEventSegment; it may differ from customEventMetricId.

Pattern: ^[a-z0-9_]+$
customEventSegment
enum<string>

Include or exclude visitors who triggered customEventRuleId. Supplying only one selector returns 400 invalid_custom_event_segment.

Available options:
include,
exclude
sample_basis
enum<string>

Which visitors count. assignment includes every visitor put in a test group; exposure only those the test actually reached. exposure is only available on tests measured that way; asking for it elsewhere returns 422 sample_basis_unsupported.

Available options:
assignment,
exposure
product_group_id
string

Scope the query to one product group. Read the id from a test's product_group; any other value returns 422 product_group_not_found.

Pattern: ^[a-fA-F0-9]{24}$
date_range
object

Inclusive window, both bounds required. Defaults to the test's own lifetime. An unknown key here returns 422 invalid_date_range.

The window is narrowed to the days that can hold data: no earlier than the day the test started, no later than today. Asking for more isn't an error. The window isn't narrowed to the day the test ended: orders count on the day they were placed, so a window past the end date picks up conversions from visitors assigned before it.

A window that can hold nothing at all (ending before the test started, or beginning after today) returns 422 date_range_out_of_bounds.

Response

A computed snapshot already answers this query.

A custom result query job. Beta.

status is pending until the snapshot is computed, then completed or failed. The result fields are present only when completed.

object
string
required
Allowed value: "results_query"
id
string
required

Treat as opaque. Never parse it.

Example:

"66d3b91c4f2a7e5081c9a3b7"

experiment_id
string
required
Example:

"3021"

status
enum<string>
required
Available options:
pending,
completed,
failed
failure_reason
string | null

Why the query failed, in plain language. Present only when status is failed. Run the query again; if it fails again, send support this text and the query id.

computed_at
string<date-time> | null
metric_set
enum<string>

The registry used to compute these rows.

Available options:
core,
engagement
customEvents
object[]

Custom-event analytics already computed in the snapshot.

warnings
string[]
filterStale
boolean
isRefreshing
boolean
date_range
object | null

The effective inclusive local-date window after safety clamping.

test_groups
object[]

Whole-test totals. Present on a query with no breakdown; a dimensional query answers with breakdown.rows instead, and carries no separate totals.

breakdown
object | null

Present when the query named a breakdown.