---
title: "Cancel experiment"
method: POST
path: "/api/v2/experiments/{experiment_id}/cancel"
tags: ["Experiments"]
---

# Cancel experiment

`POST /api/v2/experiments/{experiment_id}/cancel`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/experiments/{experiment_id}/cancel`
- 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/:experiment_id/cancel/post.ts> (a function with typed inputs; its response is checked against the schema)

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.

## Path parameters

- `experiment_id` string, uuid, required: The UUID of the experiment.

## Request body

- ExperimentsCancelExperimentV2Request: Request to cancel an experiment and record a reason.
  - `data` ExperimentsCancelExperimentV2RequestData, required: Experiment cancellation resource with the experiment identifier and reason.
    - `attributes` ExperimentsCancelExperimentV2RequestDataAttributes, required: Reason to record when canceling the experiment.
      - `reason` string, required: Reason the experiment was canceled. Stored as the decision reason on the experiment conclusion. Must not be blank.
    - `id` string: Identifier of the experiment to cancel.
    - `type` 'cancel-experiment-request', required: Cancel experiment request resource type.

## Response `204`

The experiment was canceled and unlinked from its feature flag allocations.

## Other responses

- `400`: Malformed experiment ID, malformed request body, or a missing/blank reason.
- `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, lacks permission to edit this experiment, or lacks contribute permission on the feature flag owning its allocation.
- `404`: No experiment with this ID exists for the organization.
- `409`: The experiment cannot be canceled in its current state.
- `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)
