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

# Set the datasource-driven assignment of an experiment

> Adding it switches the experiment to datasource-driven assignment (draft or ready
only). Its datasource, its conditions and their order stay editable until the experiment is
decided, inconclusive or archived. The datasource must be an active datasource of the company.
Conditions may be incomplete in draft; from ready on they must be complete.



## OpenAPI

````yaml https://openapi.production.reelevant.io/v1/render/statistics put /experiments/{id}/datasource-assignment
openapi: 3.0.0
info:
  title: statistics
  version: unknown
  description: >-
    # Errors

    | Error code | Message | HTTP status code | Payload |

    | :--- | :--- | :--- | :--- |

    |
    9000,9001,9002,9003,9004,9006,9007,9008,9009,9010,9011,9012,9013,9014,9015,9016,9018,9019,9020,9021,9022,9023,9024,9025,9026,9027,9028,9029,9030,9031,9032,9033,9034,9035,9036,9037,9038,9039,9040,9043,9041,9042,9044,9045
    | The experiment configuration is invalid | 422 | ```{"reason":"string"}```
    |
servers:
  - url: https://api.reelevant.com/v2/statistics/
    description: production
security: []
paths:
  /experiments/{id}/datasource-assignment:
    put:
      tags:
        - Experiments
      summary: Set the datasource-driven assignment of an experiment
      description: >-
        Adding it switches the experiment to datasource-driven assignment (draft
        or ready

        only). Its datasource, its conditions and their order stay editable
        until the experiment is

        decided, inconclusive or archived. The datasource must be an active
        datasource of the company.

        Conditions may be incomplete in draft; from ready on they must be
        complete.
      operationId: set-datasource-assignment
      parameters:
        - name: id
          in: path
          schema:
            type: string
            pattern: ^[0-9a-fA-F]{24}$
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                datasourceId:
                  type: string
                conditions:
                  type: array
                  items:
                    type: object
                    properties:
                      variantId:
                        type: string
                      type:
                        oneOf:
                          - type: string
                            enum:
                              - and
                          - type: string
                            enum:
                              - or
                      rules:
                        type: array
                        items:
                          type: object
                          properties:
                            field:
                              type: string
                            operation:
                              oneOf:
                                - type: string
                                  enum:
                                    - $eq
                                - type: string
                                  enum:
                                    - $ne
                                - type: string
                                  enum:
                                    - $gt
                                - type: string
                                  enum:
                                    - $lt
                                - type: string
                                  enum:
                                    - $lte
                                - type: string
                                  enum:
                                    - $gte
                                - type: string
                                  enum:
                                    - $empty
                                - type: string
                                  enum:
                                    - $nempty
                                - type: string
                                  enum:
                                    - $contains
                                - type: string
                                  enum:
                                    - $notcontains
                                - type: string
                                  enum:
                                    - $rangefuture
                                - type: string
                                  enum:
                                    - $rangepast
                                - type: string
                                  enum:
                                    - $nrangefuture
                                - type: string
                                  enum:
                                    - $nrangepast
                            values:
                              type: array
                              items:
                                oneOf:
                                  - type: string
                                  - type: number
                                  - type: boolean
                                    enum:
                                      - 'false'
                                  - type: boolean
                                    enum:
                                      - 'true'
                          required:
                            - field
                            - operation
                            - values
                          additionalProperties: false
                    required:
                      - variantId
                      - type
                      - rules
                    additionalProperties: false
              required:
                - datasourceId
                - conditions
              additionalProperties: false
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - success
                    required:
                      - status
                    additionalProperties: false
                  - $ref: >-
                      #/components/schemas/InternalResponse_Union_Intersection_type_holdout_unit_user_SerializedExperimentBase_Intersection_type_continuous_unit_Union_user_display_scheduledEnd_Union_undefined_ScheduledEndBody_SerializedExperimentBase
        '404':
          description: ''
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/InternalResponse_'
                  - type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - fail
                      error_code:
                        $ref: '#/components/schemas/StatisticsErrorCode'
                      code:
                        type: number
                        enum:
                          - 404
                      message:
                        type: string
                        enum:
                          - Unable to find experiment
                      data:
                        type: object
                        properties:
                          id:
                            type: string
                        required:
                          - id
                        additionalProperties: false
                    required:
                      - status
                      - error_code
                      - code
                      - message
                    additionalProperties: false
        '409':
          description: ''
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/InternalResponse_'
                  - type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - fail
                      error_code:
                        $ref: '#/components/schemas/StatisticsErrorCode'
                      code:
                        type: number
                        enum:
                          - 409
                      message:
                        type: string
                        enum:
                          - >-
                            Some fields are locked in the current status of the
                            experiment, see `fields`
                      data:
                        type: object
                        properties:
                          id:
                            type: string
                          status:
                            type: string
                          fields:
                            type: array
                            items:
                              oneOf:
                                - type: string
                                  enum:
                                    - name
                                - type: string
                                  enum:
                                    - hypothesis
                                - type: string
                                  enum:
                                    - variantName
                                - type: string
                                  enum:
                                    - variantSet
                                - type: string
                                  enum:
                                    - successMetric
                                - type: string
                                  enum:
                                    - unit
                                - type: string
                                  enum:
                                    - baselineVariantId
                                - type: string
                                  enum:
                                    - variantOrder
                                - type: string
                                  enum:
                                    - allocation
                                - type: string
                                  enum:
                                    - assignmentMode
                                - type: string
                                  enum:
                                    - scheduledEnd
                                - type: string
                                  enum:
                                    - datasourceAssignment
                        required:
                          - id
                          - status
                          - fields
                        additionalProperties: false
                    required:
                      - status
                      - error_code
                      - code
                      - message
                    additionalProperties: false
        '422':
          description: ''
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/InternalResponse_'
                  - type: object
                    properties:
                      status:
                        type: string
                        enum:
                          - fail
                      error_code:
                        $ref: '#/components/schemas/StatisticsErrorCode'
                      code:
                        type: number
                        enum:
                          - 422
                      message:
                        type: string
                        enum:
                          - The experiment configuration is invalid
                      data:
                        type: object
                        properties:
                          reason:
                            type: string
                        required:
                          - reason
                        additionalProperties: false
                    required:
                      - status
                      - error_code
                      - code
                      - message
                    additionalProperties: false
      security:
        - password_auth: []
components:
  schemas:
    InternalResponse_Union_Intersection_type_holdout_unit_user_SerializedExperimentBase_Intersection_type_continuous_unit_Union_user_display_scheduledEnd_Union_undefined_ScheduledEndBody_SerializedExperimentBase:
      type: object
      properties:
        program:
          type: string
        version:
          type: string
        datetime:
          type: string
        status:
          type: string
        code:
          type: number
        message:
          type: string
        data:
          oneOf:
            - allOf:
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - holdout
                    unit:
                      type: string
                      enum:
                        - user
                  required:
                    - type
                    - unit
                  additionalProperties: false
                - $ref: '#/components/schemas/SerializedExperimentBase'
            - allOf:
                - type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - continuous
                    unit:
                      oneOf:
                        - type: string
                          enum:
                            - user
                        - type: string
                          enum:
                            - display
                    scheduledEnd:
                      $ref: '#/components/schemas/ScheduledEndBody'
                  required:
                    - type
                    - unit
                  additionalProperties: false
                - $ref: '#/components/schemas/SerializedExperimentBase'
      required:
        - program
        - version
        - datetime
        - status
        - message
        - data
      additionalProperties: false
    InternalResponse_:
      type: object
      properties:
        program:
          type: string
        version:
          type: string
        datetime:
          type: string
        status:
          type: string
        code:
          type: number
        message:
          type: string
        data:
          type: object
          properties: {}
          additionalProperties: false
      required:
        - program
        - version
        - datetime
        - status
        - message
        - data
      additionalProperties: false
    StatisticsErrorCode:
      type: number
      enum:
        - 9000
        - 9001
        - 9002
        - 9003
        - 9004
        - 9006
        - 9007
        - 9008
        - 9009
        - 9010
        - 9011
        - 9012
        - 9013
        - 9014
        - 9015
        - 9016
        - 9018
        - 9019
        - 9020
        - 9021
        - 9022
        - 9023
        - 9024
        - 9025
        - 9026
        - 9027
        - 9028
        - 9029
        - 9030
        - 9031
        - 9032
        - 9033
        - 9034
        - 9035
        - 9036
        - 9037
        - 9038
        - 9039
        - 9040
        - 9043
        - 9041
        - 9042
        - 9044
        - 9045
    SerializedExperimentBase:
      type: object
      properties:
        _id:
          type: string
        companyId:
          type: string
        resourceGroupIds:
          type: array
          items:
            type: string
        name:
          type: string
        hypothesis:
          type: string
        successMetric:
          oneOf:
            - type: string
              enum:
                - unique_conversion
            - type: string
              enum:
                - unique_click
            - type: string
              enum:
                - revenue_per_user
            - type: string
              enum:
                - purchase_per_user
        systemTagKeyId:
          type: string
        status:
          oneOf:
            - type: string
              enum:
                - draft
            - type: string
              enum:
                - ready
            - type: string
              enum:
                - scheduled
            - type: string
              enum:
                - live
            - type: string
              enum:
                - maturing
            - type: string
              enum:
                - decided
            - type: string
              enum:
                - inconclusive
            - type: string
              enum:
                - archived
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/SerializedAttachment'
        scheduledAt:
          type: string
          format: date-time
        startedAt:
          type: string
          format: date-time
        readAt:
          type: string
          format: date-time
        endedAt:
          type: string
          format: date-time
        outcome:
          oneOf:
            - $ref: '#/components/schemas/SerializedDecidedOutcome'
            - $ref: '#/components/schemas/SerializedInconclusiveOutcome'
        createdBy:
          type: string
        archivedAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        variants:
          type: array
          items:
            $ref: '#/components/schemas/SerializedVariant'
        baselineVariantId:
          type: string
        datasourceAssignment:
          type: object
          properties:
            datasourceId:
              type: string
            conditions:
              type: array
              items:
                type: object
                properties:
                  variantId:
                    type: string
                  type:
                    oneOf:
                      - type: string
                        enum:
                          - and
                      - type: string
                        enum:
                          - or
                  rules:
                    type: array
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                        operation:
                          oneOf:
                            - type: string
                              enum:
                                - $eq
                            - type: string
                              enum:
                                - $ne
                            - type: string
                              enum:
                                - $gt
                            - type: string
                              enum:
                                - $lt
                            - type: string
                              enum:
                                - $lte
                            - type: string
                              enum:
                                - $gte
                            - type: string
                              enum:
                                - $empty
                            - type: string
                              enum:
                                - $nempty
                            - type: string
                              enum:
                                - $contains
                            - type: string
                              enum:
                                - $notcontains
                            - type: string
                              enum:
                                - $rangefuture
                            - type: string
                              enum:
                                - $rangepast
                            - type: string
                              enum:
                                - $nrangefuture
                            - type: string
                              enum:
                                - $nrangepast
                        values:
                          type: array
                          items:
                            oneOf:
                              - type: string
                              - type: number
                              - type: boolean
                                enum:
                                  - 'false'
                              - type: boolean
                                enum:
                                  - 'true'
                      required:
                        - field
                        - operation
                        - values
                      additionalProperties: false
                required:
                  - variantId
                  - type
                  - rules
                additionalProperties: false
          required:
            - datasourceId
            - conditions
          additionalProperties: false
      required:
        - _id
        - companyId
        - name
        - hypothesis
        - successMetric
        - status
        - attachments
        - createdBy
        - createdAt
        - updatedAt
        - variants
        - baselineVariantId
      additionalProperties: false
    ScheduledEndBody:
      type: object
      properties:
        at:
          type: string
          format: date-time
      required:
        - at
      additionalProperties: false
    SerializedAttachment:
      type: object
      properties:
        surface:
          oneOf:
            - type: string
              enum:
                - workflow
            - type: string
              enum:
                - content
            - type: string
              enum:
                - loop
        resourceId:
          type: string
        attachedAt:
          type: string
          format: date-time
      required:
        - surface
        - resourceId
        - attachedAt
      additionalProperties: false
    SerializedDecidedOutcome:
      type: object
      properties:
        status:
          type: string
          enum:
            - decided
        routingVariantId:
          type: string
        decidedBy:
          oneOf:
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - user
                userId:
                  type: string
              required:
                - type
                - userId
              additionalProperties: false
            - type: object
              properties:
                type:
                  type: string
                  enum:
                    - system
                trigger:
                  oneOf:
                    - type: string
                      enum:
                        - horizon
                    - type: string
                      enum:
                        - end-date
              required:
                - type
                - trigger
              additionalProperties: false
        validated:
          type: boolean
        confidence:
          type: number
        pValue:
          type: number
        lift:
          $ref: '#/components/schemas/SerializedLift'
      required:
        - status
        - routingVariantId
        - decidedBy
        - validated
      additionalProperties: false
    SerializedInconclusiveOutcome:
      type: object
      properties:
        status:
          type: string
          enum:
            - inconclusive
        trigger:
          oneOf:
            - type: string
              enum:
                - horizon
            - type: string
              enum:
                - end-date
        reason:
          oneOf:
            - type: string
              enum:
                - not-significant
            - type: string
              enum:
                - horizon-not-reached
        routingVariantId:
          type: string
      required:
        - status
        - trigger
        - reason
        - routingVariantId
      additionalProperties: false
    SerializedVariant:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        allocation:
          type: number
        tagValueId:
          type: string
      required:
        - id
        - name
        - allocation
      additionalProperties: false
    SerializedLift:
      type: object
      properties:
        estimate:
          type: number
        low:
          type: number
        high:
          type: number
      required:
        - estimate
        - low
        - high
      additionalProperties: false
  securitySchemes:
    password_auth:
      type: oauth2
      flows:
        password:
          tokenUrl: https://api.reelevant.com/v2/auth/token
          refreshUrl: https://api.reelevant.com/v2/auth/token
          scopes: {}

````