---
title: "Add a variant to a feature flag"
method: POST
path: "/api/v2/feature-flags/{feature_flag_id}/variants"
tags: ["Feature Flags"]
---

# Add a variant to a feature flag

`POST /api/v2/feature-flags/{feature_flag_id}/variants`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/feature-flags/{feature_flag_id}/variants`
- Auth: API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`

Adds a single new variant to an existing feature flag. This endpoint is
additive-only: it never modifies existing variants. A request whose `key`
already exists on the flag is rejected with `409 Conflict`; a `value`
whose type does not match the flag's `value_type` is rejected with `400`.
The server generates the variant UUID and returns it in the response body;
callers (for example, the flag-migration tool) need this UUID to reference
the new variant in subsequent allocation syncs.

## Path parameters

- `feature_flag_id` string, uuid, required

## Request body

- CreateVariant: Request to create a variant.
  - `key` string, required: The unique key of the variant.
  - `name` string, required: The name of the variant.
  - `value` string, required: The value of the variant as a string.

## Response `201`

Created

- Variant: A variant of a feature flag.
  - `created_at` string, date-time: The timestamp when the variant was created.
  - `id` string, uuid, required: The unique identifier of the variant.
  - `key` string, required: The unique key of the variant.
  - `name` string, required: The name of the variant.
  - `updated_at` string, date-time: The timestamp when the variant was last updated.
  - `value` string, required: The value of the variant as a string.

## Other responses

- `400`: Bad Request
- `403`: Forbidden
- `404`: Not Found
- `409`: Conflict - A variant with this key already exists on the flag.
- `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/da68bf029e4c?raw)
