---
title: "Get Experiment Assignment"
method: POST
path: "/experiments/assignments/{experiment_key}"
tags: ["OursPrivacy"]
---

# Get Experiment Assignment

`POST /experiments/assignments/{experiment_key}`

Return the server-side variant assignment for a visitor in a single A/B or multivariate experiment, identified by its experiment key. Bucketing is deterministic on `visitor_id` and is sticky across calls. Tracking an impression is the default — pass `track_impression: false` to read without recording. The browser SDK and this endpoint converge on the same variant for the same visitor.

## Path parameters

- `experiment_key` string, required — The experiment's stable key. Surfaced in the dashboard under each experiment's setup tab.

## Request body

- object
  - `token` string, required — The experiment token (`exp_*`) for the experiment settings holding this experiment. Available from the dashboard.
  - `visitor_id` string, required — Stable identifier for the visitor — typically the Ours visitor id from your browser cookie, or your own server-side user id if you keep the same id consistent across browser and server.
  - `context` object, nullable — Optional page context for URL + query-param eligibility. Variant bucketing is deterministic on `visitor_id` regardless of context.
    - `url` string, nullable — The current page URL. When provided, the experiment's URL patterns are evaluated for eligibility — visitors on non-matching URLs are returned `in_experiment: false`. Omit when the caller is pre-gating the request.
    - `search` string, nullable — The current query string (e.g. `?utm_source=meta`). When provided, the experiment's query-param conditions are evaluated for eligibility. If omitted, the query string is parsed from `url`.
  - `track_impression` boolean, nullable — When true (default), an `$experiment_impression` event is enqueued and the visitor's `experiment_assignments` map is updated. Set to false to read the assignment without recording an impression — useful for in-test diagnostics.

## Response `200`

The assignment outcome — including out-of-experiment results.

- union
  - object
    - `success` true, required
    - `in_experiment` true, required
    - `experiment_id` string, required
    - `experiment_key` string, nullable
    - `experiment_name` string, nullable
    - `variant_id` string, required
    - `variant_name` string, nullable
    - `is_control` boolean, nullable
    - `type` string, nullable
    - `redirect` string, nullable — Redirect destination for redirect (split-URL) variants — a same-domain relative path or an absolute https:// URL. Present only when the assigned variant is a redirect; absent for on-page (DOM-modification) variants. Read it straight off the payload and issue the redirect server-side.
  - object
    - `success` true, required
    - `in_experiment` false, required

## Other responses

- `400` — Bad Request - Something about the body of your request is invalid. Please update your payload and try again.
- `401` — Unauthorized - you are not authorized to send events to Ours. Please contact support.
- `404` — The experiment key is unknown or not currently running.
- `500` — Internal Server Error.

---

[API](https://skmtc.dev/oursprivacy/apis/ours.md) · [All operations](https://skmtc.dev/oursprivacy/apis/ours/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/oursprivacy/ours/revisions/dc169f9305c2/schema)
