Response Format
All endpoints return a consistent JSON envelope:
{
"success": true,
"data": { ... },
"error": "...",
"timestamp": "2026-12-05T19:06:27.486Z"
}Authentication
Each endpoint lists the credentials it accepts:
Authorization: Bearer <key> header or x-api-key header. Used by the SDK for assignment and event endpoints. Keys belong to one environment: a key from the development dashboard works only against the development base URL, and a production key only against production.Limits & Quotas
Volume is not metered, but each account has a per-minute request limit on the SDK routes so a runaway integration can't flood it. Individual requests are also bounded by payload-size and batch-size limits.
Rate limits
Up to 6,000 requests a minute per account for serving (/assignments), and another 6,000 for tracking (/events, /events/batch, /exposures, funnel rewards). Counted per Cloudflare location, so the effective ceiling is higher for global traffic. Over the limit returns 429 with a Retry-After header in seconds.
Idempotent retries
Send an Idempotency-Key header (1 to 255 characters, unique per logical request) on POST /events, /events/batch, /exposures and /funnels/:id/reward. A retry with the same key within 24 hours returns the first successful response, marked Idempotent-Replayed: true, and records nothing twice. A retry while the first is still running returns 409. Errors are not kept, so a retry after one runs again. The JavaScript SDK sends one key per event batch.
Request size
POST /assignmentsandPOST /events: max body size 100 KB. Over the limit returns 413.POST /events/batch: up to 1,000 events per request. Larger batches must be split client-side.
Monthly usage
There is no monthly event quota. Visitors and events are unmetered; only the request limits above apply.
Recommended client practices
- Use
POST /events/batchfor high-volume tracking instead of one request per event. - The JavaScript SDK batches events automatically — prefer it over hand-rolled fetches.
- On 429, wait for the seconds in
Retry-Afterbefore retrying. Retry on 500 with exponential backoff, reusing the sameIdempotency-Key. Do not retry on 400 / 401 / 413 — those are caller errors.
Assignments
Get treatment assignments for users in experiments
/api/assignmentsCreate assignment
Request a treatment assignment for a user in an experiment. The bandit algorithm selects the optimal treatment based on historical performance. If the user already has a cached assignment, it is returned instead. When the experiment belongs to a funnel, `funnelId` names it, so the caller can reward the funnel with `POST /funnels/{funnelId}/reward`. `trialOn` says when this experiment counts a trial: "served" (now) or "exposure" (once the visitor sees it, so report it with `POST /api/exposures`). A completed experiment with a winner returns the winner, and crawler requests and expired trials return the best-performing treatment; those responses carry no `trialOn`, `confidence` or `probabilityBest`, and a crawler response also sets `crawler: true`. A request body that fails validation returns 500 with the validation message.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| experimentId | string | required | ID of the experiment to assign |
| userId | string | required | Unique identifier for the user |
| context | Record<string, string | number | boolean> | optional | Optional context for contextual bandit algorithms (e.g. device type, location) |
| sessionId | string | optional | Session ID for event attribution (auto-generated by SDK) |
| pageUrl | string | optional | Address of the page the experiment runs on, up to 2048 characters, starting with http:// or https://. Used to capture the page for drafting new treatments; prefetch and crawler requests are ignored |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| assignmentId | string | required | Pass it to events and exposures to attribute them to this assignment |
| treatmentId | string | required | Empty when a bot is left on the page's own copy |
| treatment | { name: string; config: unknown } | optional | The served treatment, absent when it was deleted or when a bot is left on the page's own copy |
| confidence | number | optional | |
| probabilityBest | number | optional | Chance this treatment is the best, for Thompson sampling |
| funnelId | string | optional | The funnel the experiment belongs to |
| trialOn | "served" | "exposure" | optional | When this experiment counts a trial |
| crawler | true | optional | Set when the request came from a crawler |
Responses
Example
Request
{
"experimentId": "exp_abc123",
"userId": "user_42",
"context": {
"deviceType": "mobile",
"country": "US"
}
}Response
{
"success": true,
"data": {
"assignmentId": "asgn_xyz789",
"treatmentId": "trt_def456",
"treatment": {
"name": "Headline B",
"config": {
"content": "Start your free trial today"
}
},
"confidence": 0.87,
"probabilityBest": 0.81,
"funnelId": "fnl_abc123",
"trialOn": "served"
},
"timestamp": "2026-01-15T10:30:00.000Z"
}/api/assignments/:experimentIdGet assignment
Retrieve a treatment assignment for a user via query parameters. Functionally equivalent to the POST endpoint but useful for simple GET-based integrations. The response, including its errors, is the POST response; sessionId and pageUrl cannot be sent.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| experimentId | string | required | ID of the experiment |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | required | Unique identifier for the user |
| context | string | optional | JSON-encoded context object for contextual bandits, up to 10,000 characters |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| assignmentId | string | required | Pass it to events and exposures to attribute them to this assignment |
| treatmentId | string | required | Empty when a bot is left on the page's own copy |
| treatment | { name: string; config: unknown } | optional | The served treatment, absent when it was deleted or when a bot is left on the page's own copy |
| confidence | number | optional | |
| probabilityBest | number | optional | Chance this treatment is the best, for Thompson sampling |
| funnelId | string | optional | The funnel the experiment belongs to |
| trialOn | "served" | "exposure" | optional | When this experiment counts a trial |
| crawler | true | optional | Set when the request came from a crawler |
Responses
Events
Track events, report exposures and forward events from a customer data platform
/api/eventsTrack event
Track a single named event with optional value and metadata. Events are free-form and land in the event log. An event with cost or lineItems is an order and pays the funnels and campaigns of its visitor; any other event credits nothing. Orders need the secret key: a publishable key sending cost or lineItems gets 403 (send orders from your server, or use POST /api/orders). Funnel conversions come from convert(), funnel goals and source events. An event named "$exposure" with an assignmentId reports an exposure instead of a conversion, the same as POST /api/exposures. A body of the form { events: [...] } is handled as a batch, exactly like POST /api/events/batch. Requests from crawlers return 200 with data { crawler: true, recorded: 0 } and record nothing. Requires API key authentication. Send an Idempotency-Key header to make a retry safe.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | required | Free-form event name (e.g. "purchase", "signup", "button_click"). The name does not decide credit. |
| category | string | optional | Optional category to group related events |
| sessionId | string | required | Session identifier. Used for attribution only when neither assignmentId nor userId is set |
| userId | string | optional | Resolves to this visitor instead of the session's. Server-side callers sharing one session ID must set it per event |
| assignmentId | string | optional | The assignmentId returned by /api/assignments. Resolves the visitor and scope from exactly that assignment and takes precedence over userId and sessionId |
| value | number | optional | Numeric value for the event (e.g. revenue amount). On an order, a `count` funnel credits 1 whatever is sent |
| cost | number | optional | What the order cost you, in the same currency as value. An event with cost or lineItems is an order: it pays the funnels and campaigns of its visitor by their payout unit (a `margin` funnel gets value - cost in dollars, negative when sold below cost). Without a cost it pays no margin |
| lineItems | Array<{ id?: string; quantity?: number; price: number; discount?: number; unitCost?: number }> | optional | Per-line prices and unit costs instead of value and cost, up to 500 lines. Margin is known only when every line has a unitCost |
| metadata | Record<string, unknown> | optional | Arbitrary key-value metadata to attach to the event |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| processed | number | required | Events that were not exposures |
| rewarded | number | required | Funnel and campaign rewards the events paid |
| exposed | number | optional | New exposures from "$exposure" events; present only when the request had any |
Responses
Example
Request
{
"name": "purchase",
"category": "conversion",
"sessionId": "sess_abc123",
"value": 29.99,
"metadata": {
"product": "premium-plan",
"coupon": "SAVE10"
}
}Response
{
"success": true,
"data": {
"processed": 1,
"rewarded": 0
},
"timestamp": "2026-01-15T10:30:00.000Z"
}/api/events/:experimentIdList events
Check that an experiment exists and belongs to your company. Raw events live in the event log, not behind this API, so data is always an empty array and any query parameters are ignored. Requires the secret API key.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| experimentId | string | required | ID of the experiment |
Responses
/api/events/batchTrack events (batch)
Track multiple events in a single request for better performance and reduced network overhead. Accepts 1-1000 events per batch. The SDK automatically batches events — prefer it over hand-rolled batch requests. An event named "$exposure" with an assignmentId reports an exposure instead of a conversion, the same as POST /api/exposures. Requests from crawlers return 200 with data { crawler: true, recorded: 0 } and record nothing. Requires API key authentication; an event with cost or lineItems needs the secret key, and a publishable key sending one gets 403 for the whole batch. Send an Idempotency-Key header to make a retry safe. The batch succeeds or fails as a whole: a 4xx means the batch is malformed and retrying it will fail again; a 500 means a server failure, and the whole batch is safe to resend with the same Idempotency-Key (exposures are recorded first and are idempotent, and orders are paid in one step after them).
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| events | Array<{ name: string; category?: string; sessionId: string; userId?: string; assignmentId?: string; value?: number; cost?: number; lineItems?: Array<{ id?: string; quantity?: number; price: number; discount?: number; unitCost?: number }>; metadata?: Record<string, unknown> }> | required | Array of 1-1000 event objects. Each event has: name (required string), category (optional string), sessionId (required string), assignmentId (optional string), userId (optional string), value (optional number), cost (optional number), lineItems (optional array), metadata (optional object). |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| processed | number | required | Events that were not exposures |
| rewarded | number | required | Funnel and campaign rewards the events paid |
| exposed | number | optional | New exposures from "$exposure" events; present only when the request had any |
Responses
Example
Request
{
"events": [
{
"name": "page_view",
"category": "engagement",
"sessionId": "sess_abc123",
"metadata": {
"page": "/pricing"
}
},
{
"name": "button_click",
"category": "interaction",
"sessionId": "sess_abc123",
"metadata": {
"button": "cta-primary"
}
},
{
"name": "purchase",
"category": "conversion",
"sessionId": "sess_abc123",
"value": 49.99,
"metadata": {
"product": "pro-plan"
}
}
]
}Response
{
"success": true,
"data": {
"processed": 3,
"rewarded": 0
},
"timestamp": "2026-01-15T10:30:00.000Z"
}/api/exposuresReport exposures
Report that visitors actually saw the treatment they were served. An exposure is idempotent per assignment: only the first report counts. For an experiment whose trial rule is "exposure" (every picker experiment by default, or any experiment created with trialOn: "exposure"), the first exposure is what counts as a trial. For a "served" experiment it is tracked beside the trial. The SDK sends these for you through client.exposed() and client.observeExposure(). You can also send a "$exposure" event with an assignmentId to /api/events or /api/events/batch. Requests from crawlers return 200 with data { crawler: true, recorded: 0 } and record nothing. Requires API key authentication. Send an Idempotency-Key header to make a retry safe.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| exposures | Array<{ assignmentId: string; exposedAt?: number }> | required | Array of 1-1000 exposures. Each has: assignmentId (required string, the assignmentId returned by /api/assignments or your clientAssignmentId) and exposedAt (optional number, epoch milliseconds, defaults to now). |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| recorded | number | required | Exposures that were new |
Responses
Example
Request
{
"exposures": [
{
"assignmentId": "k57abc123def456",
"exposedAt": 1768473000000
}
]
}Response
{
"success": true,
"data": {
"recorded": 1
},
"timestamp": "2026-01-15T10:30:00.000Z"
}/api/sources/segmentReceive Segment-spec events from a CDP
Accepts events shaped like the Segment spec, so Segment (Webhooks Actions destination), RudderStack (Webhook destination) and PostHog (HTTP webhook destination) can forward data they already collect. A track is stored once per messageId and resolved to a visitor through the CDP alias join, then the identified user ID; one that resolves to nobody is kept as unmatched. An identify joins userId to the visitor and records string, number and boolean traits as visitor labels. page and unknown event types are ignored. Tracks do not credit rewards yet. Requires the secret key; publishable keys are refused. Do not rely on Segment's X-Signature header, which signs only the first event of a batch.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| source | "segment" | "rudderstack" | "posthog" | optional | The sending platform: segment (default), rudderstack or posthog. It picks which anonymous ID alias namespace is read. |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| batch | Array<unknown> | optional | Up to 1000 events. Omit it and send one event as the body instead. |
| type | string | optional | On a single event or each batch entry: track, identify, or anything else (ignored). |
| messageId | string | optional | Required on a track. A message delivered again never stores twice. |
| event | string | optional | Required on a track: the event name. |
| properties | Record<string, unknown> | optional | Track properties, stored as received. |
| anonymousId | string | optional | The platform anonymous ID, resolved through the visitor alias. |
| userId | string | optional | The identified user ID, used when the anonymous ID does not resolve. |
| traits | Record<string, unknown> | optional | On an identify: traits recorded as visitor labels, up to 20. |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| accepted | number | required | Events stored or applied |
| duplicates | number | required | Tracks already stored under the same messageId |
| unmatched | number | required | Accepted events that resolved to no visitor |
| ignored | number | required | Events skipped: page, unknown type, or failing validation |
Responses
Example
Request
{
"batch": [
{
"type": "track",
"messageId": "ajs-next-1d2c9a",
"event": "Order Completed",
"anonymousId": "7d3c9e55-1b0a-4f2c-8a46-5e7d0f3b9c21",
"properties": {
"revenue": 59.9,
"currency": "USD"
}
}
]
}Response
{
"success": true,
"data": {
"accepted": 1,
"duplicates": 0,
"unmatched": 0,
"ignored": 0
},
"timestamp": "2026-11-06T19:30:00.000Z"
}/api/sources/shopifyReceive a Shopify customer-events pixel event
Records one checkout or cart event from Bandit's Shopify customer-events pixel. The event is stored once per id, and a funnel whose goal is an event of that name is credited, with the order total when the goal reads one. Requires a publishable key. The pixel runs in Shopify's sandbox with no usable origin, so allowed origins are not checked; a secret key is refused. A request body over 10KB is refused. A GET answers 405.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| visitorId | string | required | The Bandit visitor ID the pixel read from the storefront |
| event | "checkout_completed" | "checkout_started" | "payment_info_submitted" | "product_added_to_cart" | required | The Shopify event name; any other is refused |
| id | string | required | Shopify's event ID; sending it again is a duplicate |
| orderId | string | optional | Shopify order ID |
| checkoutToken | string | optional | Shopify checkout token |
| total | number | optional | Order or cart total |
| currency | string | optional | Currency code of total |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| accepted | number | required | 1 when the event was stored, 0 for a duplicate |
| duplicates | number | required | 1 when the id was already stored |
| credited | number | required | Funnel rewards credited by this event |
Responses
Example
Request
{
"visitorId": "visitor-1",
"event": "checkout_completed",
"id": "e1",
"orderId": "gid://shopify/OrderIdentity/1",
"total": 42.5,
"currency": "USD"
}Response
{
"success": true,
"data": {
"accepted": 1,
"duplicates": 0,
"credited": 1
},
"timestamp": "2026-11-18T10:30:00.000Z"
}Experiments
Create and manage experiments
/api/experimentsList experiments
Retrieve all experiments belonging to the authenticated company, except archived ones. Returns experiments with their treatments.
Responses
/api/experimentsCreate experiment
Create a new experiment in DRAFT status inside a funnel or a campaign. Optionally include initial treatments. The experiment must be activated separately via PATCH after adding at least one treatment. Learning settings are not per experiment: forgetting, credit and serve by visitor belong to the parent funnel or campaign (Funnel modes).
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | required | Human-readable name for the experiment |
| funnelId | string | optional | Funnel the experiment joins. Exactly one of funnelId or campaignId is required |
| campaignId | string | optional | Campaign the experiment joins as a new slot. Exactly one of funnelId or campaignId is required |
| description | string | optional | Description of the experiment goals |
| status | string | optional | Initial status: draft, active, paused, completed or archived (default: draft) |
| contentType | string | required | Content type of treatments, for example plain_text |
| contentSubtype | string | optional | Content subtype (default: plain_text) |
| assignmentTtl | number | optional | Assignment cache TTL in seconds (default: 86400 = 24 hours) |
| trialOn | "served" | "exposure" | optional | When the bandit counts a trial. "served" counts one when the treatment is served. "exposure" counts one when the visitor actually sees it, reported with POST /api/exposures. Defaults to "served", and to "exposure" for point-and-click picker experiments. Fixed at creation. |
| informedPrior | boolean | optional | Ask for an informed prior; only legacy standalone experiments can use it |
| treatments | Array<{ name: string; description?: string; config: unknown; weight: number }> | optional | Optional initial treatments to create with the experiment |
Responses
Example
Request
{
"name": "Homepage Headline Test",
"funnelId": "k17a2b3c4d5e6f7g8h9j0",
"description": "Test different headlines on the landing page",
"contentType": "plain_text",
"treatments": [
{
"name": "Control",
"config": {
"content": "Welcome to our platform"
},
"weight": 1
},
{
"name": "Urgency",
"config": {
"content": "Limited time offer - start free today!"
},
"weight": 1
}
]
}Response
{
"success": true,
"data": {
"id": "exp_abc123",
"name": "Homepage Headline Test",
"algorithm": "thompson_sampling",
"status": "draft",
"treatments": [
"..."
]
},
"timestamp": "2026-01-15T10:00:00.000Z"
}/api/experiments/:idGet experiment
Retrieve a single experiment by ID or by name (an id containing a hyphen is looked up as a name), including all associated treatments and their configurations.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID or name of the experiment |
Responses
/api/experiments/:idUpdate experiment
Update experiment properties including name, description, status, and TTL. To activate an experiment, set status to active. Activation requires at least one treatment. Learning settings are not per experiment: forgetting, credit and serve by visitor belong to the parent funnel or campaign (Funnel modes).
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID of the experiment to update |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | optional | Updated name |
| description | string | optional | Updated description |
| status | string | optional | New status: draft, active, paused, completed, or archived |
| contentType | string | optional | Updated content type |
| contentSubtype | string | optional | Updated content subtype |
| assignmentTtl | number | optional | Updated assignment TTL in seconds |
| endAt | number | optional | Scheduled end of the experiment, in milliseconds since the Unix epoch |
| trialOn | "served" | "exposure" | optional | Rejected with 400 unless it equals the current rule, which is fixed at creation |
Responses
Treatments
List, add, edit and close the treatments of an experiment, the versions of the thing it tests
/api/treatmentsList treatments
Retrieve every treatment of one experiment, closed ones included.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| experimentId | string | required | ID of the experiment whose treatments to list |
Responses
/api/treatmentsCreate treatment
Add a treatment to an experiment of the authenticated company. The treatment's content goes in config, validated against the experiment's placement.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| experimentId | string | required | ID of the experiment to add the treatment to |
| name | string | required | Treatment name |
| description | string | optional | Optional description |
| config | unknown | optional | Treatment content, for example { content: "Welcome" } (default: {}) |
| weight | number | optional | Relative traffic weight (default: 1) |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| _id | string | required | Treatment ID |
| _creationTime | number | required | Creation time, in milliseconds since the Unix epoch |
| experimentId | string | required | The experiment this treatment belongs to |
| companyId | string | required | |
| name | string | required | |
| description | string | optional | |
| config | unknown | required | Treatment content, for example { content: "Welcome" } |
| weight | number | required | Relative traffic weight |
| closedAt | number | optional | When the treatment was closed; absent while it serves |
Responses
Example
Request
{
"experimentId": "k17a2b3c4d5e6f7g8h9j0",
"name": "Benefit-led",
"config": {
"content": "Ship twice as fast"
},
"weight": 1
}/api/treatments/:idUpdate treatment
Change the name, description, content or weight of a treatment. Set closed to true to stop serving it while keeping its history, or false to serve it again. Fields left out stay as they are.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID of the treatment |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | optional | Updated name |
| description | string | optional | Updated description |
| config | unknown | optional | Updated content |
| weight | number | optional | Updated relative traffic weight |
| closed | boolean | optional | true closes the treatment, false reopens it |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| _id | string | required | Treatment ID |
| _creationTime | number | required | Creation time, in milliseconds since the Unix epoch |
| experimentId | string | required | The experiment this treatment belongs to |
| companyId | string | required | |
| name | string | required | |
| description | string | optional | |
| config | unknown | required | Treatment content, for example { content: "Welcome" } |
| weight | number | required | Relative traffic weight |
| closedAt | number | optional | When the treatment was closed; absent while it serves |
Responses
Funnels
Create and manage multi-step experiment funnels
/api/funnelsList funnels
Retrieve all funnels belonging to the authenticated company. Each funnel links multiple experiments into a sequential conversion path.
Responses
/api/funnelsCreate funnel
Create a new funnel, optionally linking existing experiments into a multi-step conversion path. Omit `experimentIds` to create an empty funnel, then create experiments inside it with `POST /experiments` and its `funnelId`.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | required | Human-readable name for the funnel |
| description | string | optional | Description of the funnel goals |
| experimentIds | Array<string> | optional | Ordered list of existing experiment IDs that form the funnel steps. Defaults to none. |
| inactivityTimeoutMs | number | optional | Milliseconds a visitor can be idle before resolving to a $0 outcome |
| revisionWindowMs | number | optional | Milliseconds after resolution in which a real reward still replaces the $0 |
| payoutUnit | "count" | "revenue" | "margin" | optional | How a conversion is scored: `count` (default) credits 1 per conversion and ignores any value sent, for goals with no price like a booked demo call; `revenue` credits the order value sent with the reward; `margin` credits contribution margin (revenue minus cost) from orders sent to `POST /api/orders`, negative below cost. Changed behaviour: before `payoutUnit` existed every funnel credited the value sent; a new funnel now defaults to `count`, so a script that sends revenue must pass `payoutUnit: "revenue"` or each reward is stored as 1 |
Responses
Example
Request
{
"name": "Onboarding Flow",
"description": "Test headline → CTA → pricing across the onboarding funnel",
"experimentIds": [
"exp_headline",
"exp_cta",
"exp_pricing"
]
}Response
{
"success": true,
"data": {
"id": "fnl_abc123",
"name": "Onboarding Flow",
"description": "Test headline → CTA → pricing across the onboarding funnel",
"experimentIds": [
"exp_headline",
"exp_cta",
"exp_pricing"
],
"status": "draft"
},
"timestamp": "2026-01-15T12:00:00.000Z"
}/api/funnels/:idGet funnel
Retrieve a single funnel by ID, including details about its linked experiments and their current status, and `health`, the same object as GET /api/funnels/:id/health.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID of the funnel |
Responses
/api/funnels/:idUpdate funnel
Update funnel properties such as name, description, or status. `forgetting` sets how the funnel weighs old visitors and needs an admin token or a secret key; every model, fair credit and serve by visitor included, then learns from the forgotten data.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID of the funnel to update |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | optional | Updated name |
| description | string | optional | Updated description |
| status | "draft" | "active" | "paused" | "completed" | optional | New status: draft, active, paused, or completed |
| inactivityTimeoutMs | number | optional | Milliseconds a visitor can be idle before resolving to a $0 outcome |
| revisionWindowMs | number | optional | Milliseconds after resolution in which a real reward still replaces the $0 |
| forgetting | { mode: "none" } | { mode: "discounted"; halfLifeMs?: number } | { mode: "sliding_window"; windowMs?: number } | null | optional | Forgetting mode, or null for stationary: { "mode": "discounted", "halfLifeMs"?: number } (default 7 days), { "mode": "sliding_window", "windowMs"?: number } (default 14 days), or { "mode": "none" }. Spans run from 7 to 90 days. Only days older than the funnel inactivity timeout count, and the window or half-life is measured back from the newest settled day. Needs an admin token or a secret key. |
| thinDataFallback | boolean | optional | Default true. Under forgetting, check the kept data against the fair credit, interaction and serve-by-visitor minimums on each serve; below them, serve per-step credit (and the same treatment for every visitor) until the data grows back. The stored modes do not change. Needs an admin token or a secret key. |
| fallbackPriority | Array<"forgetting" | "credit" | "serveByVisitor"> | optional | Default ["forgetting", "credit", "serveByVisitor"]. With thinDataFallback on, the order to keep modes in when the kept data is too thin. A mode ranked above forgetting keeps running by pausing forgetting for the whole funnel (every model learns from full history); a mode ranked below forgetting falls back to per-step credit or the same treatment for everyone. Needs an admin token or a secret key. |
| contextualHistoryDays | number | optional | Default 60, from 14 to 598. Under forgetting, serve by visitor learns from at most this many settled days, which bounds each serving read. Needs an admin token or a secret key. |
Responses
/api/funnels/:idDelete funnel
Delete a funnel. This does not delete the linked experiments, only the funnel grouping.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID of the funnel to delete |
Responses
/api/funnels/:id/healthGet funnel model health
How much model detail the funnel data supports. `capacity` is the effective sample in visitors (all visitors when stationary; settled visitors per day times half-life / ln 2, or times the window, under forgetting). `bars` has one entry per active model (factored, fair_credit, interactions per pair, serve_by_visitor for the most demanding step) with the ideal need for a confident pick (`load` in visitors, `share` of capacity: 2 × (2 × payout sd / gap between the two leading treatments)² per treatment, the gap floored at 0.2 sd, scaled by the estimates each model makes), the enablement minimum (`minimum`, `minimumShare`, the binding `gate`), a `reason` with the numbers, and the `fallback` that applies when the minimum is past capacity. `idealByModel` gives the ideal of every model, whether it is on or not. `zone` (comfortable when the ideal fits, tight when only the minimum fits, overloaded when the minimum does not) and `score` (0 to 100) come from the worst bar; factored is the floor and never lowers them. `stillLearning` is true when even the factored ideal needs more visitors. `recommendations` (close_treatment, remove_experiment, drop_attribute, lengthen_forgetting) list ways to cut load when the zone is tight or overloaded, best first, with `loadFreed` and `shareAfter`. `attributes` gives, per serve-by-visitor step, the attribute values the data supports and the number used.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID of the funnel |
Responses
/api/funnels/:id/rewardRecord funnel reward
Record a reward (conversion value) for a user who completed the funnel. Updates the bandit algorithm state for all experiments in the funnel based on the treatments the user was assigned. Each user can only have one reward per funnel. Honors the `Idempotency-Key` header.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID of the funnel |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | required | ID of the user who completed the funnel |
| value | number | optional | Order value (>= 0). Used only when the funnel `payoutUnit` is `revenue` or `margin`; a `count` funnel credits 1 whatever is sent. For margin from revenue and cost, send the order to POST /api/orders instead |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| funnelId | string | required | ID of the funnel |
| userId | string | required | The canonical user ID the reward was recorded under |
| value | number | required | The value credited under the funnel payoutUnit |
Responses
Example
Request
{
"userId": "user_42",
"value": 49.99
}Response
{
"success": true,
"data": {
"funnelId": "fnl_abc123",
"userId": "user_42",
"value": 49.99
},
"timestamp": "2026-01-15T14:00:00.000Z"
}Identity
Link anonymous user IDs to identified users (email, account ID) with attribution
/api/aliasesAlias a visitor to its CDP anonymous IDs
Join the anonymous ID a customer data platform (Segment, RudderStack, PostHog) assigned to a browser to the Bandit visitor, so events forwarded from that platform credit the right visitor. The SDK and the site script send this for you when they find a platform ID in the page cookies or localStorage. Sending the same alias again changes nothing; if the same platform ID is sent for a different visitor, the latest visitor wins. Requires API key authentication; a publishable key may write aliases because they only create joins, never rewards.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| visitorId | string | required | The same visitor ID you pass to getAssignment() |
| aliases | Array<{ source: "segment" | "rudderstack" | "posthog"; externalId: string }> | required | One to three aliases. externalId is the platform anonymous ID, up to 256 characters. |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| received | number | required | Aliases in the request |
| changed | number | required | New or re-pointed aliases |
Responses
Example
Request
{
"visitorId": "9f1c2f0e-6c1d-4b7a-9d55-0c8f6a3b2e11",
"aliases": [
{
"source": "segment",
"externalId": "7d3c9e55-1b0a-4f2c-8a46-5e7d0f3b9c21"
}
]
}Response
{
"success": true,
"data": {
"received": 1,
"changed": 1
},
"timestamp": "2026-11-06T19:30:00.000Z"
}/api/arrivalsRecord how a visitor arrived
Record the UTM tags, ad click ID, and external referrer host a visitor landed with. The SDK and the site and storefront scripts send this for you. A tagged landing or an external referrer replaces the visitor's current arrival; a direct landing keeps it until 30 days after it started. Values are trimmed, lowercased, spaces and underscores become dashes, at most 40 characters. Requires API key authentication. Unknown keys in touch are rejected, and a request body over 10KB is refused.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | required | The same user ID you pass to getAssignment() |
| touch | { utmSource?: string; utmMedium?: string; utmCampaign?: string; utmContent?: string; trackingParam?: string; klaviyoExchangeId?: string; referrerHost?: string } | required | Raw values from the landing URL and referrer. An empty object is a direct visit. Each value is at most 200 characters, trackingParam 40, referrerHost 255. |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| recorded | boolean | required | False when a direct visit kept the current arrival |
| arrival | { source?: string; medium?: string; campaign?: string; content?: string; referrerHost?: string; channel?: "ad" | "email" | "social" | "search" | "referral" | "direct" } | optional | The recorded arrival, absent when recorded is false |
Responses
Example
Request
{
"userId": "user-123",
"touch": {
"utmSource": "Facebook",
"utmCampaign": "Mothers_Day"
}
}Response
{
"success": true,
"data": {
"recorded": true,
"arrival": {
"source": "facebook",
"campaign": "mothers-day",
"channel": "social"
}
},
"timestamp": "2026-01-15T10:30:00.000Z"
}/api/identifyLink anonymous user to identified user
Link an anonymous user ID to a durable identity (email, account ID). All historical assignments and events for the anonymous ID are re-attributed to the identified user. Future calls to getAssignment() with either ID will resolve to the same assignment. Accepts the secret key, a publishable key (origin allowlist applies), or an admin personal access token with x-company-id.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| anonymousId | string | required | Temporary or anonymous user ID (e.g., crypto.randomUUID()) |
| identifiedUserId | string | required | Permanent user ID (e.g., email, database ID) |
| string | optional | The visitor email, a valid address of at most 320 characters. Never stored. When the company has connected Klaviyo, it is used once to look up the Klaviyo profile and link its ID to this visitor. | |
| mergeReason | "user_signup" | "email_verification" | "social_login" | "account_recovery" | "manual" | optional | Why the identification is happening: user_signup, email_verification, social_login, account_recovery, or manual (default: manual) |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| anonymousId | string | required | |
| identifiedUserId | string | required | |
| alreadyMapped | boolean | required | True when this anonymous ID was already linked to the identified user |
Responses
Example
Request
{
"anonymousId": "anon_550e8400-e29b-41d4-a716-446655440000",
"identifiedUserId": "user@example.com",
"mergeReason": "user_signup"
}Response
{
"success": true,
"data": {
"anonymousId": "anon_550e8400-e29b-41d4-a716-446655440000",
"identifiedUserId": "user@example.com",
"alreadyMapped": false
},
"timestamp": "2026-08-26T19:30:00.000Z"
}/api/labelsLabel a visitor
Record what a visitor told you about themselves (a survey answer, a signup field). Questions are free-form short keys; the latest answer to a question replaces the earlier one. Audiences use these answers to describe who is in each discovered group. Requires API key authentication. A request body over 100KB is refused.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | required | The same user ID you pass to getAssignment() |
| labels | Record<string, string | boolean> | required | Question to answer, one to 20 per call. Questions are trimmed, lowercased, at most 40 characters. Answers are trimmed, lowercased, at most 40 characters; booleans are stored as "true" or "false". |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| recorded | number | required | Labels stored; entries that normalize to nothing are skipped |
Responses
Example
Request
{
"userId": "user-123",
"labels": {
"role": "founder",
"team_size": "2-10"
}
}Response
{
"success": true,
"data": {
"recorded": 2
},
"timestamp": "2026-01-15T10:30:00.000Z"
}Campaigns
Create and manage campaigns, which hold experiments and learn from one reward per visitor
/api/campaignsList campaigns
Retrieve all campaigns belonging to the authenticated company.
Responses
/api/campaignsCreate campaign bundle
Create an empty bundle: the shared learning state (one payout unit, one reward per visitor) that an email campaign's experiments learn into. It does not create or send an email campaign, and the returned `_id` is a bundle ID, so `POST /experiments` does not accept it as `campaignId`. Create email campaigns at /emails in the dashboard and pass that campaign's ID.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | required | Human-readable name for the campaign |
| description | string | optional | Description of the campaign goals |
| payoutUnit | "count" | "revenue" | "margin" | optional | How a conversion is scored: `count` (default) credits 1 per conversion and ignores any value sent, for goals with no price like a booked demo call; `revenue` credits the order value sent with the reward; `margin` credits contribution margin (revenue minus cost) from orders sent to `POST /api/orders`, negative below cost. Changed behaviour: before `payoutUnit` existed every campaign credited the value sent; a new campaign now defaults to `count`, so a script that sends revenue must pass `payoutUnit: "revenue"` or each reward is stored as 1 |
Responses
Example
Request
{
"name": "Spring Launch",
"description": "Headline and CTA for the spring launch"
}Response
{
"success": true,
"data": {
"_id": "cmp_abc123",
"name": "Spring Launch",
"description": "Headline and CTA for the spring launch",
"status": "draft"
},
"timestamp": "2026-01-15T12:00:00.000Z"
}/api/campaigns/:idAdvance an email campaign
Move an email campaign forward. `sending` records the tracked destination links (fixed once sending starts) and unlocks `/email/render` and `/email/plan`. `sent` marks the send finished so the campaign can be folded up. Status only moves forward.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | ID of the email campaign |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| status | "sending" | "sent" | required | `sending` or `sent` |
| links | Array<string> | optional | With `sending`: http(s) destination URLs to tag for click attribution, up to 500. May be empty. Ignored with `sent`. |
Responses
Example
Request
{
"status": "sending",
"links": [
"https://example.com/sale"
]
}Response
{
"success": true,
"data": {
"campaignId": "cmp_abc123",
"status": "sending"
},
"timestamp": "2026-01-15T12:00:00.000Z"
}Orders
Send orders with revenue and cost from any store. Each order pays the funnels and campaigns its visitor is in, by their payout unit, so a margin funnel learns from contribution margin
/api/ordersRecord order
Record an order. The order is that visitor's funnel or campaign payout, scored by its `payoutUnit`: `count` credits 1, `revenue` credits net revenue, `margin` credits revenue minus cost minus discounts plus net shipping, negative when the order sold below cost, and waits until cost is known. Payouts are in dollars (an order of 120 with cost 45.50 pays a margin funnel 74.50). Send either `lines` or `revenue`, never both, and with `lines` send each line its own `unitCost` instead of an order `cost`. The order id is the idempotency key, across this API and the Shopify webhook: sending the same id again is a no-op, except that an order stored without a known cost is recomputed and its margin payouts credited once when you send it again with costs. Requires a secret API key.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| orderId | string | required | Your order id, at most 200 characters. Unique per company |
| assignmentId | string | optional | The assignmentId (or clientAssignmentId) the visitor was served. Pays that assignment's funnel or campaign. Takes precedence over userId |
| userId | string | optional | The visitor's user id. Pays every funnel and campaign the visitor (or a linked identity) has assignments in |
| currency | string | optional | ISO currency code, three letters. Defaults to USD |
| lines | Array<{ id?: string; quantity?: number; price: number; discount?: number; unitCost?: number }> | optional | Line items, one to 500: unit price, quantity (default 1), the discount on the whole line, and unit cost. Margin is known only when every line has a unitCost |
| revenue | number | optional | Order revenue after discounts, when you send no lines |
| cost | number | optional | Total cost of goods, with revenue. Omit when unknown and send the order again once you know it |
| shipping | number | optional | Shipping the customer paid |
| shippingCost | number | optional | What the shipping cost you. Shipping counts toward margin only when this is sent |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| orderId | string | required | The order id you sent |
| credited | boolean | required | Whether any funnel or campaign was paid by this call |
| marginMinor | number | required | Contribution margin in minor currency units (cents) |
| marginKnown | boolean | required | False while the order waits for its cost |
| duplicate | boolean | required | True when the order id was already recorded |
Responses
Example
Request
{
"orderId": "1042",
"assignmentId": "k57c2f0e3q9m",
"lines": [
{
"id": "mug",
"quantity": 2,
"price": 24,
"unitCost": 9.5
}
],
"shipping": 6,
"shippingCost": 4.25
}Response
{
"success": true,
"data": {
"orderId": "1042",
"credited": true,
"marginMinor": 3075,
"marginKnown": true,
"duplicate": false
},
"timestamp": "2026-11-02T12:00:00.000Z"
}/api/orders/:id/refundsRecord refund
Record a refund on an order sent to POST /api/orders. A funnel or campaign payout is revised down: a `revenue` payout by the amount refunded, a `margin` payout by the margin share of the revenue refunded plus refunded shipping, a `count` payout not at all; the original value stays on the reward as `grossValue`. Refunds are capped in total at the original payout. A refundId already applied is a no-op. Requires a secret API key.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | required | The orderId sent to POST /api/orders |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| refundId | string | required | Your refund id, at most 200 characters. A retry with the same id is ignored |
| amount | number | required | Revenue refunded, after discounts |
| shipping | number | optional | Shipping refunded |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| orderId | string | required | The order id from the path |
| applied | boolean | required | False when the refundId was already applied, the order was not sent through this API, or no payout needed revising |
| refundedMinor | number | required | Margin refunded by this call in minor currency units (cents); 0 when not applied |
Responses
Example
Request
{
"refundId": "r-77",
"amount": 24
}Response
{
"success": true,
"data": {
"orderId": "1042",
"applied": true,
"refundedMinor": 1538
},
"timestamp": "2026-11-02T12:00:00.000Z"
}Pick sessions
The short-lived session behind the point-and-click experiment picker. The dashboard opens one and hands its bpick_ token to the picker on the customer site, which uses it as a bearer token
/api/pick/integrationsList events received from each integration
For the picker goal step. Returns, for each built integration (segment, rudderstack, posthog, shopify), the event names received from it with count and last seen, and whether any carried a value. Also returns the planned integrations this company already asked for. Scoped to the session company.
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| requested | Array<string> | required | Planned integration ids this company already asked for |
| events | { segment: { sampled: number; names: Array<{ event: string; count: number; lastSeenAt: number; carriesValue: boolean }> }; rudderstack: { sampled: number; names: Array<{ event: string; count: number; lastSeenAt: number; carriesValue: boolean }> }; posthog: { sampled: number; names: Array<{ event: string; count: number; lastSeenAt: number; carriesValue: boolean }> }; shopify: { sampled: number; names: Array<{ event: string; count: number; lastSeenAt: number; carriesValue: boolean }> } } | required |
Responses
Example
Response
{
"success": true,
"data": {
"requested": [
"stripe"
],
"events": {
"segment": {
"sampled": 3,
"names": [
{
"event": "Order Completed",
"count": 3,
"lastSeenAt": 1790000000000,
"carriesValue": true
}
]
},
"rudderstack": {
"sampled": 0,
"names": []
},
"posthog": {
"sampled": 0,
"names": []
},
"shopify": {
"sampled": 0,
"names": []
}
}
}
}/api/pick/integrationsRequest a planned integration
Records that this company wants a connector that is not built yet, so it can be told when it ships. One row per company and integration, a repeat call only refreshes it. It never creates a goal.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| integration | string | required | The id of a planned integration, like stripe or calendly |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| integration | string | required | |
| requested | true | required |
Responses
Example
Request
{
"integration": "stripe"
}Response
{
"success": true,
"data": {
"integration": "stripe",
"requested": true
}
}/api/pick/nextOpen a new pick session after Start
Lets the visitor pick another element on the same site without going back to the dashboard. Ends the started session and returns a fresh token with an empty draft for the same funnel. The new session expires at the same hard limit as the first one, never later.
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| token | string | required | The new bpick_ token |
| expiresAt | number | required | When the new session ends, in milliseconds since the epoch |
Responses
Example
Response
{
"success": true,
"data": {
"token": "bpick_3f9a1c0d5e7b24681a3c5e7f9b0d2f4a6c8e0b1d3f5a7c9e",
"expiresAt": 1790000000000
}
}/api/pick/sessionGet the pick session state
Returns the draft the visitor is building, the funnel goal, and the experiment id once Start has run. The site script also calls this from the customer site to check that a token is still valid, so it allows any origin. Every call needs the pick token as a bearer token.
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| funnelId | string | required | |
| payoutUnit | "count" | "revenue" | "margin" | required | |
| siteHost | string | required | |
| expiresAt | number | required | When the session ends, in milliseconds since the epoch |
| draft | { target?: { page: string; selector: string; tag: string; kind: "text" | "image" | "order"; original: string }; alternatives: Array<string>; goal?: { kind: "page"; page: string } | { kind: "click"; page: string; selector: string; tag: string; label: string } | { kind: "event"; event: string; valueProperty?: string; source?: "segment" | "rudderstack" | "posthog" | "shopify" } } | required | |
| funnelGoal | { kind: "page"; page: string } | { kind: "click"; page: string; selector: string; tag: string; label: string } | { kind: "event"; event: string; valueProperty?: string; source?: "segment" | "rudderstack" | "posthog" | "shopify" } | null | required | The goal already saved on the funnel, or null |
| experimentId | string | null | required | Set once Start has run |
| runningExperiments | number | required |
Responses
Example
Response
{
"success": true,
"data": {
"funnelId": "k17abc123",
"payoutUnit": "count",
"siteHost": "example.com",
"expiresAt": 1790000000000,
"draft": {
"target": {
"page": "/",
"selector": "main > h1",
"tag": "h1",
"kind": "text",
"original": "Grow your business"
},
"alternatives": [
"Double your sales"
]
},
"funnelGoal": null,
"experimentId": null,
"runningExperiments": 0
}
}/api/pick/sessionSave the pick draft
Each field you send replaces that part of the draft. Picking a different element (a different selector or kind) clears the alternatives. Every save extends the session by 30 minutes, up to 2 hours after it opened. Returns the whole new state.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| target | { page: string; selector: string; tag: string; kind: "text" | "image" | "order"; original: string } | optional | The picked element: page, selector, tag, kind (text, image or order), original |
| alternatives | Array<string> | optional | The options to try against the original. Up to 20 are accepted here and a draft that keeps more than 5 is rejected with a message the visitor can read. Image options are https URLs |
| goal | { kind: "page"; page: string } | { kind: "click"; page: string; selector: string; tag: string; label: string } | { kind: "event"; event: string; valueProperty?: string; source?: "segment" | "rudderstack" | "posthog" | "shopify" } | optional | What counts as a win: a page visit ({ kind: "page", page }) or a click ({ kind: "click", page, selector, tag, label }), or an integration event ({ kind: "event", event, valueProperty?, source? }) |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| funnelId | string | required | |
| payoutUnit | "count" | "revenue" | "margin" | required | |
| siteHost | string | required | |
| expiresAt | number | required | When the session ends, in milliseconds since the epoch |
| draft | { target?: { page: string; selector: string; tag: string; kind: "text" | "image" | "order"; original: string }; alternatives: Array<string>; goal?: { kind: "page"; page: string } | { kind: "click"; page: string; selector: string; tag: string; label: string } | { kind: "event"; event: string; valueProperty?: string; source?: "segment" | "rudderstack" | "posthog" | "shopify" } } | required | |
| funnelGoal | { kind: "page"; page: string } | { kind: "click"; page: string; selector: string; tag: string; label: string } | { kind: "event"; event: string; valueProperty?: string; source?: "segment" | "rudderstack" | "posthog" | "shopify" } | null | required | The goal already saved on the funnel, or null |
| experimentId | string | null | required | Set once Start has run |
| runningExperiments | number | required |
Responses
Example
Request
{
"alternatives": [
"Double your sales"
]
}Response
{
"success": true,
"data": {
"funnelId": "k17abc123",
"payoutUnit": "count",
"siteHost": "example.com",
"expiresAt": 1790000000000,
"draft": {
"target": {
"page": "/",
"selector": "main > h1",
"tag": "h1",
"kind": "text",
"original": "Grow your business"
},
"alternatives": [
"Double your sales"
]
},
"funnelGoal": null,
"experimentId": null,
"runningExperiments": 0
}
}/api/pick/startStart the picked experiment
Creates the experiment as active in the setup funnel, with the original as Control and each alternative as an option, and saves the draft goal on the funnel. Safe to repeat: a second call returns the same experiment. Needs an element, at least one alternative, and a goal on the draft or the funnel.
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| experimentId | string | required | |
| state | { funnelId: string; payoutUnit: "count" | "revenue" | "margin"; siteHost: string; expiresAt: number; draft: { target?: { page: string; selector: string; tag: string; kind: "text" | "image" | "order"; original: string }; alternatives: Array<string>; goal?: { kind: "page"; page: string } | { kind: "click"; page: string; selector: string; tag: string; label: string } | { kind: "event"; event: string; valueProperty?: string; source?: "segment" | "rudderstack" | "posthog" | "shopify" } }; funnelGoal: { kind: "page"; page: string } | { kind: "click"; page: string; selector: string; tag: string; label: string } | { kind: "event"; event: string; valueProperty?: string; source?: "segment" | "rudderstack" | "posthog" | "shopify" } | null; experimentId: string | null; runningExperiments: number } | required |
Responses
Example
Response
{
"success": true,
"data": {
"experimentId": "jx7def456",
"state": {
"funnelId": "k17abc123",
"payoutUnit": "count",
"siteHost": "example.com",
"expiresAt": 1790000000000,
"draft": {
"target": {
"page": "/",
"selector": "main > h1",
"tag": "h1",
"kind": "text",
"original": "Grow your business"
},
"alternatives": [
"Double your sales"
],
"goal": {
"kind": "page",
"page": "/thank-you"
}
},
"funnelGoal": {
"kind": "page",
"page": "/thank-you"
},
"experimentId": "jx7def456",
"runningExperiments": 1
}
}
}/api/pick/uploadGet a signed URL to upload an image alternative
Returns a short-lived URL to PUT an image file to, and the public URL to use as the alternative once the upload finishes. Images only, up to 10MB. The file is stored under the session company.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| filename | string | required | File name with an extension, like hero.png |
| contentType | string | required | MIME type, which must start with image/ |
| size | number | required | File size in bytes |
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| uploadUrl | string | required | Short-lived URL to PUT the file to |
| publicUrl | string | required | The URL to use as the alternative once the upload finishes |
| key | string | required | The storage key |
Responses
Example
Request
{
"filename": "hero.png",
"contentType": "image/png",
"size": 48211
}Response
{
"success": true,
"data": {
"uploadUrl": "https://account.r2.cloudflarestorage.com/bucket/companies/k1/abc.png?X-Amz-Signature=...",
"publicUrl": "https://assets.runbandit.com/companies/k1/abc.png",
"key": "companies/k1/abc.png"
}
}Setup
Check how far a company is through installing Bandit and launching its first experiment
/api/setup/statusGet setup progress
Returns the ordered setup stages (funnel_created, sdk_seen, experiment_created, treatments_added, experiment_started, serving, conversion_tracked), whether each one is done, and the instruction for the first stage that is not. `bandit doctor` prints this after a line confirming the CLI is linked.
Response data
| Name | Type | Required | Description |
|---|---|---|---|
| stages | Array<{ id: "funnel_created" | "sdk_seen" | "experiment_created" | "treatments_added" | "experiment_started" | "serving" | "conversion_tracked"; label: string; done: boolean; instruction: string }> | required | |
| currentStageId | "funnel_created" | "sdk_seen" | "experiment_created" | "treatments_added" | "experiment_started" | "serving" | "conversion_tracked" | null | required | The first stage that is not done, or null when setup is complete |
| complete | boolean | required | |
| domain | string | null | required | The saved site address, or null |
| setup | { goal?: string; stack: string; funnelId?: string; conversionPath?: string } | null | required | The platform and setup funnel chosen on /setup, or null |
| funnelGoal | { kind: "page"; page: string } | { kind: "click"; page: string; selector: string; tag: string; label: string } | { kind: "event"; event: string; valueProperty?: string; source?: string } | null | required | The setup funnel goal, null until one is set |
| seenHosts | Array<string> | required | Hosts the script has been seen on |
| siteOrigin | string | null | required | The origin of the site as last seen with the script, null until a visit on the saved domain arrives |
| lastSeenOrigin | string | null | required | The origin of the most recent visit on any host, or null |
| runningExperiments | number | required | Experiments that are parented and active |
| shopifyPixelOutdated | boolean | required | True when a Shopify theme setup has rewards but its purchase pixel has never reported |
Responses
Example
Response
{
"success": true,
"data": {
"stages": [
{
"id": "funnel_created",
"label": "Site saved",
"done": true,
"instruction": "Choose your platform and enter your site address on /setup, which saves your site and creates your setup funnel."
}
],
"currentStageId": "sdk_seen",
"complete": false,
"domain": "example.com",
"setup": {
"stack": "webflow",
"funnelId": "k17abc123"
},
"funnelGoal": {
"kind": "page",
"page": "/thank-you"
},
"seenHosts": [
"localhost"
],
"siteOrigin": null,
"lastSeenOrigin": null,
"runningExperiments": 0,
"shopifyPixelOutdated": false
}
}