> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Variant

> Creates a new variant and add it to the given flag. A variant is a named
 value that typically represents a group of settings that can be used to
 control part of an application.

 Before you can create a variant the flag must have a schema, and the
 variant must satisfy the schema.



## OpenAPI

````yaml /api/flags/api/flag.openapi.json post /v1/flags/{flag}/variants
openapi: 3.1.0
info:
  title: Confidence Flag API
  version: 1.0.0
  description: API documentation for flag
servers: []
security: []
paths:
  /v1/flags/{flag}/variants:
    post:
      summary: Create Variant
      description: |-
        Creates a new variant and add it to the given flag. A variant is a named
         value that typically represents a group of settings that can be used to
         control part of an application.

         Before you can create a variant the flag must have a schema, and the
         variant must satisfy the schema.
      operationId: Variant.create
      parameters:
        - name: flag
          in: path
          required: true
          schema:
            type: string
        - name: variantId
          in: query
          required: false
          description: >-
            The ID to use for the variant, which will become the final component
            of
             the variant's resource name.

             This value should be 4-63 characters, and valid characters
             are /[a-z][0-9]-/.
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: |-
                    The resource name of the variant.
                     For example:
                     `flags/my-flag/variants/control`
                value:
                  type: object
                  description: >-
                    The value that this variant represents. A possibly nested
                    json object.
                labels:
                  type: array
                  items:
                    type: object
                    additionalProperties:
                      type: string
                  description: General set of labels for this resource.
                description:
                  type: string
                  description: A human-friendly description of the variant.
                imageUri:
                  type: string
                  description: An image URL or path for the variant.
              required:
                - name
                - value
        required: true
      responses:
        '200':
          description: Returns a [Flag.Variant](/api-reference/schemas/flag-variant).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/confidence.flags.admin.v1.Flag.Variant'
      security:
        - admin: []
      servers:
        - url: https://flags.eu.confidence.dev
        - url: https://flags.us.confidence.dev
        - url: https://flags.confidence.dev
components:
  schemas:
    confidence.flags.admin.v1.Flag.Variant:
      title: Flag.Variant
      type: object
      description: A possible named value the flag can assign.
      properties:
        name:
          type: string
          description: |-
            The resource name of the variant.
             For example:
             `flags/my-flag/variants/control`
        value:
          type: object
          description: >-
            The value that this variant represents. A possibly nested json
            object.
        labels:
          type: array
          items:
            type: object
            additionalProperties:
              type: string
          description: General set of labels for this resource.
        description:
          type: string
          description: A human-friendly description of the variant.
        imageUri:
          type: string
          description: An image URL or path for the variant.
        createTime:
          type: object
          description: Time when the flag was first created.
        updateTime:
          type: object
          description: Time when the flag was last updated.
        creator:
          type: string
          description: Reference to the identity that created this variant.
        updater:
          type: string
          description: Reference to the identity that last updated this variant.
      required:
        - name
        - value
        - createTime
        - updateTime
        - creator
        - updater
  securitySchemes:
    admin:
      type: http
      scheme: bearer

````