---
title: "Create a flag"
method: PUT
path: "/v1/projects/{projectIdOrName}/feature-flags/flags"
tags: ["feature-flags"]
---

# Create a flag

`PUT /v1/projects/{projectIdOrName}/feature-flags/flags`

Create a new feature flag for a project. The flag must have a unique slug within the project and specify its kind (boolean, string, number, or json).

## Path parameters

- `projectIdOrName` string, required — The project id or name

## Query parameters

- `teamId` string
- `slug` string

## Request body

- object
  - `slug` string, required — A unique (per project) key for the flag, composed of letters, numbers, dashes, and underscores
  - `kind` 'boolean' | 'string' | 'number' | 'json', required — The kind of flag
  - `variants` object[] — The variants of the flag
    - `id` string, required — The id of the variant
    - `label` string — A label for the variant
    - `description` string — A description of the variant
    - `value` union, required
      - string
      - number
      - boolean
      - object
      - unknown[]
        - unknown
      - string
  - `environments` object, required — The configuration for the flag in different environments
  - `seed` number — A random seed to prevent split points in different flags from having the same targets
  - `description` string — A description of the flag
  - `state` 'active' | 'archived'
  - `maintainerIds` string[] — The user ids of the maintainers of the flag
  - `permanent` boolean — Whether this flag is marked as permanent, indicating it should not be removed
  - `tags` string[] — Tags for categorizing the flag

## Response `201`

- object
  - `description` string
  - `maintainerIds` string[]
  - `permanent` false | true
  - `tags` string[]
  - `experiment` object
    - `id` string
    - `name` string
    - `numVariants` number
    - `surfaceArea` string
    - `stickyRequirement` false | true
    - `layer` string
    - `guardrailMetrics` object[]
      - `description` string
      - `metricFormula` string
      - `name` string, required
      - `metricType` 'count' | 'currency' | 'percentage', required
      - `metricUnit` 'session' | 'user' | 'visitor', required
      - `directionality` 'decreaseIsGood' | 'increaseIsGood', required
    - `hypothesis` string
    - `device` 'android' | 'desktop' | 'ios' | 'mweb'
    - `controlVariantId` string
    - `startedAt` number
    - `endedAt` number
    - `decision` string
    - `decisionReason` string
    - `duration` number
    - `durationUnit` 'days' | 'exposures'
    - `allocationPercent` number
    - `allocationUnit` 'cookieId' | 'userId' | 'visitorId', required
    - `primaryMetrics` object[], required
      - `description` string
      - `metricFormula` string
      - `name` string, required
      - `metricType` 'count' | 'currency' | 'percentage', required
      - `metricUnit` 'session' | 'user' | 'visitor', required
      - `directionality` 'decreaseIsGood' | 'increaseIsGood', required
    - `status` 'closed' | 'draft' | 'paused' | 'running', required
  - `updatedBy` string
  - `variants` object[], required
  - `id` string, required
  - `environments` object, required
  - `kind` 'boolean' | 'json' | 'number' | 'string', required
  - `revision` number, required
  - `seed` number, required
  - `state` 'active' | 'archived', required
  - `slug` string, required
  - `createdAt` number, required
  - `updatedAt` number, required
  - `createdBy` string, required
  - `ownerId` string, required
  - `projectId` string, required
  - `typeName` 'flag', required

## Other responses

- `400` — One of the provided values in the request body is invalid. One of the provided values in the request query is invalid.
- `401` — The request is not authorized.
- `402` — The account is missing a payment so payment method must be updated
- `403` — You do not have permission to access this resource.
- `404`
- `409`
- `410`

---

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