Experiments
Sticky A/B variant assignment and exposure logging for the signed-in user.
Client-facing A/B experiment surface: fetch the signed-in user's sticky variant
and record an exposure when they actually see it. Both calls require a client
session (X-Api-Key + session bearer). Defining experiments and reading results is
on the admin surface. See the
Experiments guide for the end-to-end flow.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /client/experiments/:key/assignment | Sticky variant assignment for the current user. |
| POST | /client/experiments/:key/exposure | Record that the user was shown their assigned variant. |
GET /client/experiments/:key/assignment
Returns the user's variant for the experiment. The assignment is sticky — the
first call buckets the user (deterministic hash of user_id + experiment_key,
weighted by the variant weights) and persists it; every later call returns that same
variant, even after the experiment is re-weighted. Only active experiments create
new assignments; a paused or ended experiment still serves an existing assignment
so in-flight users keep their bucket.
Response 200
Errors
404 EXPERIMENT_NOT_FOUND— no experiment with that key.409 EXPERIMENT_INACTIVE— the user has no assignment yet and the experiment isn'tactive.error.details.statuscarries the current status.422 NO_VALID_VARIANTS— the experiment has no assignable (positive-weight) variants.500 ASSIGNMENT_FAILED.
Try it:
/client/experiments/checkout_button_v2/assignmentcurl -X GET 'https://api.amba.dev/v1/client/experiments/checkout_button_v2/assignment'Curl:
POST /client/experiments/:key/exposure
Record an exposure — the analytics signal that the user was actually shown the
variant (vs. merely assigned). Append-only: each call inserts a row. The caller must
already have an assignment (call assignment first). Not gated on status — recording
a late exposure for a paused/ended experiment is a legitimate signal.
Request
| Field | Type | Required | Description |
|---|---|---|---|
variant | string | no | Overrides the recorded variant; defaults to the user's assignment. |
An empty or absent body is fine — the exposure is recorded against the user's current assignment.
Response 201
Errors
400 INVALID_JSON— body present but not valid JSON.400 INVALID_VARIANT—variantpresent but not a non-empty string.404 EXPERIMENT_NOT_FOUND— no experiment with that key.404 ASSIGNMENT_REQUIRED— the user has no assignment to expose — callassignmentfirst.500 EXPOSURE_FAILED.
Try it:
/client/experiments/checkout_button_v2/exposurecurl -X POST 'https://api.amba.dev/v1/client/experiments/checkout_button_v2/exposure'Curl: