# Set the component datasource

Sets the datasource for a specific component on a page. You can specify a new data source item or clear the existing one.

Endpoint: POST /api/v1/pages/{pageId}/components/{componentId}/datasource
Version: v2.0
Security: HTTPBearer

## Security:

  - `HTTPBearer` (unknown)
    http bearer JWT

## Path parameters:

  - `pageId` (string, required)
    The unique identifier of the page.To get this ID, use [List pages of a site](#operation/sites-get_all_pages_by_site).

  - `componentId` (string, required)
    The unique identifier of the component on the page. To get this ID, use [Retrieve components on a page](#operation/pages-get_components_on_page).

## 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):

  - `datasourceId` (string, required)
    The unique identifier of the datasource to set for the component. To get this ID, you can use the [List datasources](#operation/datasources-list_datasources_by_page) endpoint.
    Example: 3f2504e0-4f89-11d3-9a0c-0305e82c3301

  - `language` (any)
    The language for the datasource.
    Example: en

  - `variantId` (any)
    The unique identifier of personalization or A/B/n test variant to update. 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.
If you provide this value, the datasource update applies only to the specified variant. If you omit this value, the change applies to the base page.
    Example: 8bd7a9ec96b8490f9b894e3866fefb79_2a5c1e8c8d244f569a44d6b28cbecb05

## Response 200:

  - `200` (unknown)
    Successful response

## Response 200 fields (application/json):

  - `success` (boolean)
    Whether the datasource was set successfully.
    Example: true

  - `message` (string)
    A message providing additional information about the operation.
    Example: Datasource set successfully.

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

  - `pageId` (string)
    The unique identifier of the page.
    Example: 9f8c7e6d-5b4a-4c3d-8e7f-1a2b3c4d5e6f

  - `datasourceId` (string)
    The unique identifier of the datasource.
    Example: f0b81bcc-7388-46be-b109-6e73d1114470

## 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.

