---
title: "Create experiment"
method: POST
path: "/api/v2/experiments"
tags: ["Experiments"]
---

# Create experiment

`POST /api/v2/experiments`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/experiments`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `product_analytics_experiments_write`
- TypeScript: <https://skmtc.dev/datadog/apis/datadog-api-v2-collection/docs/api/v2/experiments/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a draft experiment. `name` is required. `structured_metadata` identifies each metadata field by `field_key`; use `freetext_value` for free-text fields and `enum_values` for enum fields. When this attribute is present, the request must include a value for every required metadata field. When `protocol_id` is present, the published protocol supplies the subject type, decision metrics, analysis-plan defaults, and configuration and enforcement baselines. The request may also include hypothesis, tags, teams, related links, and assignment or event date overrides that satisfy the protocol's duration rules; omit subject_type_id, decision_metrics, variants, warehouse_exposure_configuration, datadog_flag_configuration, traffic_exposure, split_by_properties, and structured_metadata. The protocol association cannot be changed after creation. Without `protocol_id`, a complete Warehouse or Datadog configuration saves the experiment and its configuration in one transaction. For Datadog flag configuration, send `name`, `subject_type_id`, `decision_metrics`, `variants`, `traffic_exposure`, `assignments_start_date`, `assignments_end_date`, `events_start_date`, and `events_end_date`. The four date fields can be null. Inside `datadog_flag_configuration`, send `feature_flag_id`, `environment_id`, `targeting_rules`, and `entry_point`. Use `targeting_rules: []` and `entry_point: null` when unused. This creates one saved draft allocation that does not serve traffic. Omit all configuration fields to create an experiment without an allocation. This endpoint is not idempotent.

## Request body

- ExperimentsCreateExperimentV2Request: Request to create an experiment draft.
  - `data` ExperimentsCreateExperimentV2RequestData, required: Experiment resource to create.
    - `attributes` ExperimentsCreateExperimentV2RequestDataAttributes, required: Configuration and descriptive fields for the new experiment draft.
      - `assignments_end_date` string, date-time, nullable: End of the window assignments are read from. Optional; must be after assignments_start_date.
      - `assignments_start_date` string, date-time, nullable: Start of the window assignments are read from. Optional.
      - `datadog_flag_configuration` ExperimentsCreateExperimentV2RequestDataAttributesDatadogFlagConfiguration, nullable: Feature flag, environment, and targeting configuration for a Datadog experiment.
        - `entry_point` ExperimentsPatchExperimentV2ResponseDataAttributesDatadogFlagConfigurationEntryPoint, nullable, required: Datadog measure and filters used to select analyzed subjects.
          - `filters` ExperimentsDatadogEntryPointFilterGroup[], required: Complete Datadog OR-of-ANDs entry-point filter expression.
            - ExperimentsDatadogEntryPointFilter[]: Entry-point filters combined with AND.
              - …
          - `measure_id` string, required: Datadog measure UUID.
        - `environment_id` string, uuid, required: Identifier of the feature flag environment.
        - `feature_flag_id` string, uuid, required: Identifier of the Datadog feature flag used by the experiment.
        - `reset_on_feature_flag_change` boolean: Accepted on create but has no effect.
        - `targeting_rules` ExperimentsTargetingRule[], required: Use an empty array when no targeting rules apply.
          - `conditions` ExperimentsTargetingRuleCondition[], required: Conditions that must all match for this rule. Each condition must use exactly one shape: saved_filter_id alone or operator plus attribute plus value.
            - union: A saved-filter condition or a complete inline condition. The two forms cannot be combined.
              - …
      - `decision_metrics` ExperimentsCreateExperimentV2RequestDataAttributesDecisionMetricsItems[]: Metrics selected to support the experiment decision.
        - `is_primary` boolean, required: Whether this is the experiment primary metric.
        - `metric_id` string, uuid, required: Decision metric UUID.
      - `events_end_date` string, date-time, nullable: End of the window metric events are read from. Optional; must be after events_start_date.
      - `events_start_date` string, date-time, nullable: Start of the window metric events are read from. Optional; must fall within the assignments window.
      - `hypothesis` string: What the experiment is expected to show. Optional and free-form.
      - `migration_metadata` unknown
      - `name` string, required: Display name for the experiment. The only required attribute: a request carrying nothing but a name is accepted.
      - `protocol_id` string: Published protocol whose defaults create this draft. May be combined with hypothesis, tags, teams, related links, and date overrides. Omit subject_type_id, decision_metrics, variants, warehouse_exposure_configuration, datadog_flag_configuration, traffic_exposure, and structured_metadata.
      - `related_links` ExperimentsCreateExperimentV2RequestDataAttributesRelatedLinksItems[]: External links associated with the experiment.
        - `id` string, nullable: Link ID. Omit it when adding a link.
        - `title` string, nullable: Optional display title.
        - `url` string, required: Absolute URL.
      - `split_by_properties` ExperimentsCreateExperimentV2RequestDataAttributesSplitByPropertiesItems[]: Complete Datadog split-by selection. Identify each property by column_name. Omit this field to copy organization defaults.
        - `column_name` string, required: Exposure field that identifies the property.
        - `column_type` 'varchar' | 'int' | 'double' | 'boolean' | 'varchar_array' | 'int_array' | 'double_array' | 'raw': Data type of the column evaluated by the entry-point filter.
        - `name` string: Optional display name. Defaults to column_name for a new property.
      - `structured_metadata` ExperimentsCreateExperimentV2RequestDataAttributesStructuredMetadataItems[]: Custom metadata fields and their values for the experiment.
        - `enum_values` string[]: Selected values for an enumerated metadata field.
        - `field_key` string, required: Key that identifies the metadata field.
        - `freetext_value` string: Text value for a free-text metadata field.
      - `subject_type_id` string, uuid: Canonical ID of an existing subject type. Optional; defaults to the organization default.
      - `summary` string: Summary of the experiment. Optional and free-form.
      - `tags` string[]: Non-team tag names to apply. Optional.
      - `teams` string[]: Team handles that own the experiment. Optional.
      - `traffic_exposure` ExperimentsPatchExperimentV2ResponseDataAttributesTrafficExposure: Traffic exposure fraction or schedule configured for the experiment.
        - `fraction` number, double: STATIC exposure fraction. Draft experiments can change this value. After start only warehouse experiments without a Datadog flag can change a STATIC fraction through the public API.
        - `mode` 'STATIC' | 'STEPS', required: Whether exposure uses a fixed fraction or a sequence of steps.
        - `steps` ExperimentsCreateExperimentV2RequestDataAttributesTrafficExposureStepsItems[]: Configured exposure plan rather than wall-clock history. At least two steps must have strictly increasing fractions and no gaps. Warehouse steps start at assignments_start_date and can use different durations. New Datadog plans have at most five steps and a first fraction above zero. Their nonfinal durations must be equal and exclude time paused. Datadog steps start with the experiment. Running warehouse experiments can replace step fractions, durations, and the exposure mode. After start, Datadog exposure plans cannot change through the public API. The final duration is null and its fraction holds until assignment ends.
          - `duration_ms` integer, nullable, required: Positive step duration in milliseconds. Datadog durations exclude pauses. Send null for the final step.
          - `fraction` number, double, required: Fraction of traffic exposed during this step.
      - `variants` ExperimentsCreateExperimentV2RequestDataAttributesVariantsItems[]: Variants selected for the experiment and their traffic allocations.
        - `feature_flag_variant_id` string, uuid: Stable backing flag variant ID. Required for Datadog-backed experiments and omitted for Warehouse-only experiments.
        - `is_active` boolean: Whether this variant participates in the experiment. Responses always include this field. On writes an included variant defaults to active; omit its row to remove or unselect it. Explicit false supports sending an unchanged response back.
        - `is_control` boolean, required: Whether this is the single control variant.
        - `key` string, required: Assignment value. Datadog flag variant keys are server-owned.
        - `name` string, nullable: Display name. Datadog flag variant names are server-owned.
        - `weight` number, double, required: Traffic allocation percentage. Existing variant weights cannot change through the public API after the experiment starts.
      - `warehouse_exposure_configuration` ExperimentsCreateExperimentV2RequestDataAttributesWarehouseExposureConfiguration, nullable: Warehouse model and experiment key used to read assignment data.
        - `entry_point` ExperimentsWarehouseEntryPoint, nullable, required: Optional Warehouse measure that scopes analyzed subjects.
          - `filters` ExperimentsWarehouseExposureFilter[], required: Complete ordered Warehouse entry-point filter set.
            - `operation` 'IS' | 'IS_NOT', required: Comparison applied by the warehouse entry-point filter.
            - `property_id` string, required: Warehouse property UUID.
            - `values` string[], required: Ordered values used by the filter.
          - `measure_id` string, required: Warehouse measure UUID.
        - `experiment_key` string, required: Warehouse experiment key. Must not be blank.
        - `exposure_sql_model_id` string, required: ID of the exposure SQL model that provides assignment data.
    - `id` string: Optional JSON:API resource identifier field.
    - `type` 'experiments', required: Experiments resource type.

## Response `201`

Created

- ExperimentsExperimentV2DTO: Response containing an experiment and its configuration.
  - `data` ExperimentsExperimentV2DTOData, required: Experiment resource with its identifier and configuration.
    - `attributes` ExperimentsPatchExperimentV2ResponseDataAttributes: Details of the experiment.
      - `assignments_end_date` string, date-time, nullable: End of the time window for experiment assignments.
      - `assignments_start_date` string, date-time, nullable: Start of the time window for experiment assignments.
      - `concluded_at` string, date-time, nullable: Time when the experiment was concluded.
      - `conclusion` ExperimentsPatchExperimentV2ResponseDataAttributesConclusion: Outcome and supporting text recorded when the experiment is concluded.
        - `decision_reason` string, nullable: Reason for the recorded decision.
        - `outcome` 'POSITIVE' | 'NEGATIVE' | 'NEUTRAL' | 'INCONCLUSIVE' | 'MISCONFIGURED' | 'UNKNOWN', nullable: Recorded experiment outcome.
        - `summary` string, nullable: Summary of the experiment conclusion.
      - `created_at` string, date-time: Time when this resource was created.
      - `datadog_flag_configuration` ExperimentsPatchExperimentV2ResponseDataAttributesDatadogFlagConfiguration, nullable: Feature flag, environment, and targeting configuration for the experiment.
        - `allocation_key` string: Key of the feature flag allocation linked to the experiment. Matches the allocation key that SDKs report in flag evaluation results and exposure events.
        - `entry_point` ExperimentsPatchExperimentV2ResponseDataAttributesDatadogFlagConfigurationEntryPoint, nullable, required: Datadog measure and filters used to select analyzed subjects.
          - `filters` ExperimentsDatadogEntryPointFilterGroup[], required: Complete Datadog OR-of-ANDs entry-point filter expression.
            - ExperimentsDatadogEntryPointFilter[]: Entry-point filters combined with AND.
              - …
          - `measure_id` string, required: Datadog measure UUID.
        - `environment_id` string: ID of the feature flag environment used by the experiment.
        - `feature_flag_id` string: ID of the feature flag linked to the experiment.
        - `targeting_rules` ExperimentsTargetingRule[]: Rules that select subjects for the experiment.
          - `conditions` ExperimentsTargetingRuleCondition[], required: Conditions that must all match for this rule. Each condition must use exactly one shape: saved_filter_id alone or operator plus attribute plus value.
            - union: A saved-filter condition or a complete inline condition. The two forms cannot be combined.
              - …
      - `decision_metrics` ExperimentsCreateExperimentV2RequestDataAttributesDecisionMetricsItems[]: Metrics used to decide the experiment outcome.
        - `is_primary` boolean, required: Whether this is the experiment primary metric.
        - `metric_id` string, uuid, required: Decision metric UUID.
      - `decision_variant_key` string: Key of the variant selected in the experiment decision.
      - `events_end_date` string, date-time, nullable: End of the time window for metric events.
      - `events_start_date` string, date-time, nullable: Start of the time window for metric events.
      - `experiment_type` string: Kind of experiment. STANDARD is an ordinary experiment. Other values, such as CANARY and HOLDOUT, identify experiments owned by another workflow. New kinds may be added; treat unknown values as non-standard.
      - `hypothesis` string: Expected effect that the experiment is intended to test.
      - `migration_metadata` unknown
      - `name` string: Display name of the experiment.
      - `pipeline_table_suffix` string: Suffix used to identify the experiment's pipeline output table.
      - `protocol_id` string: ID of the protocol associated with the experiment.
      - `related_links` ExperimentsCreateExperimentV2RequestDataAttributesRelatedLinksItems[]: Links to supporting material for the experiment.
        - `id` string, nullable: Link ID. Omit it when adding a link.
        - `title` string, nullable: Optional display title.
        - `url` string, required: Absolute URL.
      - `results_last_updated` string, date-time, nullable: Time of the most recent update to the experiment's results.
      - `split_by_properties` ExperimentsExperimentV2DTODataAttributesSplitByPropertiesItems[]: Properties used to split the experiment results into groups.
        - `column_name` string, required: Exposure field or Warehouse column used for the analysis dimension.
        - `column_type` 'varchar' | 'int' | 'double' | 'boolean' | 'varchar_array' | 'int_array' | 'double_array' | 'raw' | 'STRING' | 'INTEGER' | 'FLOAT' | 'BOOLEAN' | 'DATE' | 'TIMESTAMP', required: Type of the Datadog exposure field or Warehouse column.
        - `id` string, required: Read-only property ID. Omit it from POST and PATCH; writes identify properties by column_name.
        - `name` string, required: Display name for the analysis dimension.
      - `status` 'DRAFT' | 'SCHEDULED' | 'IN_PROGRESS' | 'READY_FOR_DECISION' | 'DECISION_MADE' | 'CANCELLED' | 'UNKNOWN': Current stage in the experiment lifecycle.
      - `structured_metadata` ExperimentsStructuredMetadataResponse[]: Values of structured metadata fields attached to the experiment.
        - `enum_values` string[]: Selected values for an enumerated metadata field.
        - `field_display_name` string: Display name of the metadata field.
        - `field_key` string, required: Key that identifies the metadata field.
        - `field_type` 'FREETEXT' | 'ENUM': Type of value stored in the structured metadata field.
        - `freetext_value` string: Text value for a free-text metadata field.
      - `subject_type_id` string, nullable: ID of the subject type used by this configuration.
      - `summary` string: Summary text recorded for the experiment.
      - `tags` string[]: Tags attached to the experiment.
      - `teams` string[]: Teams associated with the experiment.
      - `traffic_exposure` ExperimentsPatchExperimentV2ResponseDataAttributesTrafficExposure: Traffic exposure fraction or schedule configured for the experiment.
        - `fraction` number, double: STATIC exposure fraction. Draft experiments can change this value. After start only warehouse experiments without a Datadog flag can change a STATIC fraction through the public API.
        - `mode` 'STATIC' | 'STEPS', required: Whether exposure uses a fixed fraction or a sequence of steps.
        - `steps` ExperimentsCreateExperimentV2RequestDataAttributesTrafficExposureStepsItems[]: Configured exposure plan rather than wall-clock history. At least two steps must have strictly increasing fractions and no gaps. Warehouse steps start at assignments_start_date and can use different durations. New Datadog plans have at most five steps and a first fraction above zero. Their nonfinal durations must be equal and exclude time paused. Datadog steps start with the experiment. Running warehouse experiments can replace step fractions, durations, and the exposure mode. After start, Datadog exposure plans cannot change through the public API. The final duration is null and its fraction holds until assignment ends.
          - `duration_ms` integer, nullable, required: Positive step duration in milliseconds. Datadog durations exclude pauses. Send null for the final step.
          - `fraction` number, double, required: Fraction of traffic exposed during this step.
      - `updated_at` string, date-time: Time when this resource was last updated.
      - `variants` ExperimentsExperimentV2DTODataAttributesVariantsItems[]: Variants configured for the experiment.
        - `feature_flag_variant_id` string: Backing feature flag variant ID. Present for Datadog feature flag experiments and omitted for Warehouse experiments.
        - `is_active` boolean, required: Whether this variant participates in the experiment.
        - `is_control` boolean, required: Whether this is the single control variant.
        - `key` string, required: Value recorded in exposure data for this variant.
        - `name` string, nullable: Display name of the experiment variant.
        - `weight` number, double, required: Traffic allocation percentage.
      - `warehouse_exposure_configuration` ExperimentsPatchExperimentV2ResponseDataAttributesWarehouseExposureConfiguration, nullable: Warehouse exposure model and settings used to identify experiment assignments.
        - `entry_point` ExperimentsWarehouseEntryPoint, nullable, required: Optional Warehouse measure that scopes analyzed subjects.
          - `filters` ExperimentsWarehouseExposureFilter[], required: Complete ordered Warehouse entry-point filter set.
            - `operation` 'IS' | 'IS_NOT', required: Comparison applied by the warehouse entry-point filter.
            - `property_id` string, required: Warehouse property UUID.
            - `values` string[], required: Ordered values used by the filter.
          - `measure_id` string, required: Warehouse measure UUID.
        - `experiment_key` string, nullable, required: Warehouse experiment key. Reads can return null for incomplete configuration; configuration writes require a value.
        - `exposure_sql_model_id` string, required: ID of the exposure SQL model that provides assignment data.
    - `id` string, uuid, required: Identifier of the experiment.
    - `type` 'experiments', required: Experiments resource type.

## Other responses

- `400`: Invalid request body: missing required field, malformed variants or decision_metrics, or an unresolvable analysis configuration.
- `401`: Missing or invalid authentication (dd-api-key + dd-application-key headers, or a valid user session).
- `403`: Authenticated caller lacks the product_analytics_experiments_write permission.
- `404`: The supplied protocol_id does not identify a protocol in this organization.
- `409`: The requested configuration is incompatible with the experiment (code: unsupported_configuration).
- `415`: Request body sent with a media type other than application/json or application/vnd.api+json.
- `422`: The supplied protocol is a draft or archived protocol and cannot be applied to a new experiment.
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/3f70db624329?raw)
