Hierarchy

  • ExperimentsApi

Constructors

Properties

configuration: Configuration
requestFactory: ExperimentsApiRequestFactory
responseProcessor: ExperimentsApiResponseProcessor

Methods

  • Cancel an experiment, ending it without a winning variant. The experiment moves to CANCELLED status, the supplied reason is recorded in its conclusion as the decision reason, and the experiment is unlinked from the feature flag allocations that exposed it, which stops its exposure. An experiment that has already completed its rollout, had its code removed, or been canceled cannot be canceled again. Canceling is not reversible: an experiment cannot be returned to a running state afterward. It is also not idempotent: canceling an already-canceled experiment returns 409, so a retry after a timeout cannot be distinguished from a cancellation made by someone else.

    Parameters

    Returns Promise<void>

  • Conclude an experiment on a winning variant. The experiment moves to DECISION_MADE status, the outcome is recorded in its conclusion, and for a flag-backed experiment the winning variant is rolled out to 100% of the linked feature flag allocation. decision_variant_key must match a variant in the experiment. Only an experiment that is currently running or ready for a decision can be concluded. Concluding is not reversible and is not idempotent: concluding an already-concluded experiment returns 409.

    Parameters

    Returns Promise<void>

  • 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.

    Parameters

    Returns Promise<ExperimentsExperimentV2DTO>

  • Update mutable experiment fields. State and protocol restrictions apply.

    PATCH behavior

    • Omitted fields stay unchanged, including fields inside datadog_flag_configuration.
    • Supplied tags, teams, related_links, decision_metrics, and variants replace their stored lists.
    • Validation can return several field errors before saving any changes. The response is HTTP 400 if any error concerns invalid input. It is HTTP 409 if all errors concern state or protocol conflicts.

    Result refreshes

    This endpoint does not start a pipeline run. meta.needs_pipeline_refresh states whether the edit requires a run. When true, POST to meta.refresh_endpoint after finishing your edits. Its full_refresh query parameter selects the run type.

    Keep refresh requirements across edits. A later false value does not clear an earlier requirement. Any full_refresh=true requirement takes priority.

    After start, STATIC and STEPS exposure changes for warehouse experiments without a Datadog flag attempt to recalculate stored results. Changes to decision metrics or the control variant also attempt recalculation when results exist. If stored data is insufficient or recalculation fails, the edit stays saved and meta.needs_pipeline_refresh is true.

    Exposure rules

    • Draft experiments can replace the full STATIC or STEPS plan through traffic_exposure.
    • Warehouse steps start at assignments_start_date and can have different durations.
    • Running warehouse experiments can replace step fractions, durations, and exposure mode. Retained variant weights cannot change through this API. You can send unchanged values again.
    • After a warehouse experiment ends, configuration replacement supports only STATIC fraction changes.
    • New Datadog plans have at most five steps. The first fraction must be positive. All steps except the last have equal durations. Durations exclude pauses.
    • The last step has a null duration. Its fraction stays in effect until assignment ends.
    • After start, use the experiment UI to change traffic exposure for experiments linked to a Datadog flag.

    Metadata

    structured_metadata updates fields by field_key. Use freetext_value: "" or enum_values: [] to clear an optional field. Omitted fields stay unchanged. A null or empty structured_metadata attribute makes no change.

    Flag changes

    Before start, a Datadog update creates or edits the saved draft allocation. To add or replace a flag, send variants and traffic_exposure. Inside datadog_flag_configuration, send feature_flag_id, environment_id, targeting_rules, and entry_point. Use targeting_rules: [] and entry_point: null when unused.

    To replace a flag, also set reset_on_feature_flag_change: true inside that object. The server deletes the old draft and creates a new one in the same transaction. The response includes a datadog_flag_configuration_reset warning in meta.warnings.

    Set datadog_flag_configuration: null to delete the draft allocation. This also clears the experiment's flag association, variants, assignment sources, and entry point. The experiment remains.

    Flag replacement and removal require a draft experiment without warehouse exposure. These actions do not convert hybrid experiments.

    Parameters

    Returns Promise<ExperimentsPatchExperimentV2Response>

  • Start an experiment. The experiment is started exactly as it is configured; this endpoint accepts no attributes, and a request body carrying any is rejected rather than ignored. Set the run window, duration, or variants with PATCH /api/v2/experiments/{experiment_id} before starting. An unconfigured draft returns HTTP 409. Configure either warehouse_exposure_configuration or datadog_flag_configuration, plus the required experiment fields, before starting. Start validation errors can include meta.configuration_pointer to identify a field on the experiment to correct. For a flag-backed experiment this enables the linked feature flag's environment, clears any stored variant override on it, and starts the allocation's rollout. The request is idempotent: an experiment that is already running or ready for a decision still returns 204, so a retry after a timeout is safe. One exception: an experiment scheduled to start is accepted only when it is backed by your own feature flag; a Datadog-flag experiment in that state returns 409 because its stored state and flag allocation disagree. Cancel and conclude are not idempotent and return 409 when repeated.

    Parameters

    Returns Promise<void>

  • Update a metric. Certified metrics are read-only through this endpoint. This is a partial update: every attribute is optional and an omitted attribute keeps its stored value, so a body carrying only the fields being changed is enough. guardrail_cutoff_threshold is nullable -- send null to clear it, omit it to leave it alone. Omitting the aggregation leaves the metric's definition untouched; supplying one replaces it wholesale, and the metric's type is re-derived from the shape supplied. Property filters use property_id or measure_id UUIDs from the aggregation's data source. Attributes that are computed rather than stored (short_id, metric_type, certified_at, experiment_count, created_at, updated_at) are rejected rather than ignored, so a body copied from GET must have them removed. The is_certified attribute is rejected. Certification cannot be changed through this endpoint.

    Parameters

    Returns Promise<ExperimentsMetricV2DTO>

Generated using TypeDoc