---
title: "Creates an experiment in the draft state and returns the full document."
method: POST
path: "/campaign/experiments"
tags: ["Experiment"]
---

# Creates an experiment in the draft state and returns the full document.

`POST /campaign/experiments`

The split salt is generated server-side. Returns 409 with code
 experiment_key_exists when the key is already taken.

## Request body

- CreateExperimentEndpointInput
  - `key` string, required — Stable unique identifier; becomes the analysis key exp:<key>.
  - `description` string, required — Human-readable description of the hypothesis.
  - `flags` FeatureFlag[], required — Feature flags stamped on treatment sessions only.
    - `key` string, required
    - `value` string, required
  - `eligibility` ExperimentEligibility
    - `rapidTypes` ExperimentRapidType[], nullable
    - `assetKinds` ExperimentAssetKind[], nullable
    - `mediaContext` 'required' | 'absent' | 'null', nullable
    - `textContext` 'required' | 'absent' | 'null', nullable
    - `campaignTypes` ExperimentCampaignType[], nullable
    - `campaignIds` string[], nullable
    - `excludedCampaignIds` string[], nullable
    - `organizationIds` string[], nullable
    - `excludedOrganizationIds` string[], nullable
    - `countries` string[], nullable
    - `languages` string[], nullable
    - `user` object, nullable
      - `minScore` number, double, nullable
      - `maxScore` number, double, nullable
      - `newUsers` boolean, nullable
      - `deviceTypes` DeviceType[], nullable
      - `dspNames` string[], nullable
      - `globalAudienceGraduate` boolean, nullable
  - `userEnrollment` 'perSession' | 'sticky', nullable — Defaults to perSession.
  - `split` CreateExperimentEndpointSplit, required
    - `treatmentBps` integer, required
  - `startAt` string, date-time, nullable — Start of the experiment window.
  - `endAt` string, date-time, nullable — End of the experiment window.

## Response `200`

OK

- Experiment — A global serve-time A/B experiment. Every eligible session is stamped with exp:<key> = treatment|control; treatment sessions additionally receive the experiment's feature flags.
  - `id` string, required — The unique id of the experiment document.
  - `key` string, required — Stable unique identifier; the analysis key is exp:<key>.
  - `description` string, required — Human-readable description of the hypothesis.
  - `state` 'draft' | 'active' | 'paused' | 'completed', required
  - `flags` FeatureFlag[], required — Feature flags stamped on treatment sessions only.
    - `key` string, required
    - `value` string, required
  - `eligibility` ExperimentEligibility, required
    - `rapidTypes` ExperimentRapidType[], nullable
    - `assetKinds` ExperimentAssetKind[], nullable
    - `mediaContext` 'required' | 'absent' | 'null', nullable
    - `textContext` 'required' | 'absent' | 'null', nullable
    - `campaignTypes` ExperimentCampaignType[], nullable
    - `campaignIds` string[], nullable
    - `excludedCampaignIds` string[], nullable
    - `organizationIds` string[], nullable
    - `excludedOrganizationIds` string[], nullable
    - `countries` string[], nullable
    - `languages` string[], nullable
    - `user` object, nullable
      - `minScore` number, double, nullable
      - `maxScore` number, double, nullable
      - `newUsers` boolean, nullable
      - `deviceTypes` DeviceType[], nullable
      - `dspNames` string[], nullable
      - `globalAudienceGraduate` boolean, nullable
  - `userEnrollment` 'perSession' | 'sticky', required
  - `split` ExperimentSplit, required
    - `treatmentBps` integer, required
    - `salt` string, required
  - `startAt` string, date-time, nullable — Outside the [startAt, endAt) window the experiment is treated as inactive.
  - `endAt` string, date-time, nullable — End of the experiment window; the experiment auto-completes afterwards.
  - `createdBy` string, required — The email of the admin who created the experiment.
  - `createdAt` string, date-time, required — When the experiment was created.
  - `updatedAt` string, date-time, required — When the experiment was last changed.

## Other responses

- `400` — Bad Request
- `401` — Unauthenticated
- `403` — Forbidden

## Changes

- **2026-09-04** `9da534659e5f` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/rapidata/apis/rapidata-api/changes/campaign/experiments/post.md)

---

[API](https://skmtc.dev/rapidata/apis/rapidata-api.md) · [All operations](https://skmtc.dev/rapidata/apis/rapidata-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/rapidata/rapidata-api/revisions/9da534659e5f/schema)
