# Set up a component variant

Sets up a variant for a specific A/B/n test or personalization by copying, hiding, or swapping the original component.

Endpoint: POST /api/v1/flows/{flowId}/variants/{variantId}
Version: v2.0
Security: HTTPBearer

## Security:

  - `HTTPBearer` (unknown)
    http bearer JWT

## Path parameters:

  - `flowId` (string, required)
    The unique identifier of the A/B/n test or personalization to set up. To get this ID, you can use the [List flow definitions](#/operation/flows-list_flow_definitions_by_page) endpoint for the page and use the flow `ref` value.

  - `variantId` (string, required)
    The unique identifier of the personalization or A/B/n test variant to set up. To get this ID, you can use the [List flow definitions](#/operation/flows-list_flow_definitions_by_page) endpoint. Use the `transpiledVariants[].ref`, or `variants[].ref` when available.

## Header parameters:

  - `x-sc-job-id` (any)
    A unique identifier for the job, used to trace, audit, and revert actions performed by an AI agent through the Agent API.

## Request fields (application/json):

  - `page_id` (string, required)
    The unique identifier of the page containing the component.
    Example: 3f2504e0-4f89-11d3-9a0c-0305e82c3301

  - `component_id` (string, required)
    The unique identifier of the component to set up as a variant.
    Example: d290f1ee-6c54-4b01-90e6-d701748f0851

  - `variant_strategy` (string, required)
    Enum: "HIDE", "SWAP", "COPY"

  - `language` (string)
    The language code for the variant setup.
    Example: en

  - `page_version` (any)
    The version of the page to use, or null for the latest version.
    Example: 1

  - `swapped_component` (any)
    The replacement component details when the variant strategy is SWAP, or null otherwise.

  - `swapped_component.componentRenderingId` (string, required)
    The unique identifier of the replacement component rendering definition.
    Example: 86a03271-dff4-470a-92bd-b68c67de2e25

  - `swapped_component.datasourcePath` (string, required)
    The path to the datasource used by the swapped component.
    Example: /sitecore/content/Verticals/SkatePark/Data/Promos/Summer Sale

## Response 201:

  - `201` (unknown)
    Successful response

## Response 201 fields (application/json):

  - `pageId` (string)
    The unique identifier of the page.
    Example: 3f2504e0-4f89-11d3-9a0c-0305e82c3301

  - `componentId` (string)
    The unique identifier of the component set up as a variant.
    Example: d290f1ee-6c54-4b01-90e6-d701748f0851

  - `componentRenderingId` (string)
    The unique identifier of the component rendering definition.
    Example: 86a03271-dff4-470a-92bd-b68c67de2e25

  - `flowId` (string)
    The unique identifier of the A/B/n test or personalization.
    Example: 1fdfbc60-9646-469d-b971-2b0f4c033fbc

  - `variantId` (string)
    The unique identifier of the A/B/n test or personalization variant.
    Example: 8ea2cb6f-a92a-4c05-88a3-a4c0b29c63a8

  - `datasource` (any)
    The path to the datasource used by the variant, or null if not applicable.
    Example: /sitecore/content/Verticals/SkatePark/Data/Promos/Summer Sale

## Response 422:

  - `422` (unknown)
    Unprocessable entity

## Response 422 fields (application/json):

  - `detail` (array)

  - `detail.loc` (array)
    The location of the error in the request.

  - `detail.msg` (string)
    The error message.

  - `detail.type` (string)
    The type of error.

  - `detail.input` (any)
    The input that caused the error.

  - `detail.ctx` (object)
    The context in which the error occurred.

