---
title: "Create experiment"
method: POST
path: "/v1/projects/{projectSlug}/experiments"
tags: ["Experiments"]
---

# Create experiment

`POST /v1/projects/{projectSlug}/experiments`

Creates an experiment. The slug is derived from `name`. Omit `variants` to seed two defaults.

## Path parameters

- `projectSlug` string, required — Project slug (human-readable identifier)

## Request body

- CreateExperimentBody
  - `name` string, required — Human-readable name. Used to derive the slug.
  - `description` string — Optional free-form description.
  - `variants` object[] — Variant definitions. Omit to seed two default variants (`Variant A` baseline + `Variant B`); pass `[]` to create an empty experiment.
    - `id` string — Existing variant id to preserve. Omit to mint a new variant.
    - `name` string, required — Variant name. Unique within the experiment.
    - `baseline` boolean, required — `true` for the baseline variant. Exactly one variant must be the baseline.
    - `filterSet` object, required — Session filters selecting this variant's population.
    - `query` string, nullable, required — Free-text / semantic search, or `null`.
    - `timeRange` union, required — Time window, or `null` for the default last-30-days window.
      - object
        - `type` 'relative', required
        - `seconds` integer, required — Length of the live window in seconds.
      - object
        - `type` 'absolute', required
        - `fromIso` string, required — ISO-8601 start of the window (inclusive).
        - `toIso` string, required — ISO-8601 end of the window (inclusive).

## Response `201`

Experiment created

- Experiment
  - `id` string, required — Stable experiment identifier.
  - `organizationId` string, required — Organization that owns this experiment.
  - `projectId` string, required — Project this experiment belongs to.
  - `slug` string, required — URL-safe slug derived from `name`. Unique within the project.
  - `name` string, required — Human-readable name.
  - `description` string, required — Free-form description. Empty string when not set.
  - `variants` ExperimentVariant[], required — Ordered variants. Exactly one carries the baseline flag when the list is non-empty.
    - `id` string, required — Stable variant identifier, unique within the experiment.
    - `name` string, required — Human-readable variant name (e.g. "Variant A"). Unique within the experiment.
    - `baseline` boolean, required — `true` for the single baseline variant that every other variant is compared against.
    - `filterSet` object, required — Session filters selecting this variant's population.
    - `query` string, nullable, required — Free-text / semantic search applied to the population, or `null`.
    - `timeRange` union, required — Time window the variant is measured over. `null` uses the default last-30-days window.
      - RelativeVariantTimeRange
        - `type` 'relative', required — A live window ending now, spanning the last `seconds`.
        - `seconds` integer, required — Length of the live window in seconds (e.g. 2592000 for the last 30 days).
      - AbsoluteVariantTimeRange
        - `type` 'absolute', required — A fixed window between two instants.
        - `fromIso` string, required — ISO-8601 start of the window (inclusive).
        - `toIso` string, required — ISO-8601 end of the window (inclusive).
  - `createdAt` string, required — ISO-8601 timestamp of creation.
  - `updatedAt` string, required — ISO-8601 timestamp of the last update.

## Other responses

- `400` — Validation error
- `401` — Unauthorized
- `404` — Not found

---

[API](https://skmtc.net/latitude-dev/apis/latitude.md) · [All operations](https://skmtc.net/latitude-dev/apis/latitude/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/latitude-dev/latitude/versions/6a8789c59a5c/schema)
