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

# Assign a distribution details to a challenge

> Assign a distribution details to a challenge.



## OpenAPI

````yaml /openapi/admin.json post /challenges/{challengeId}/distribution
openapi: 3.1.0
info:
  title: Nudj Admin API
  version: 1.0.0
servers:
  - url: https://{subdomain}.nudj.cx/api/v2/admin
    description: Organization API Server
    variables:
      subdomain:
        description: Your organization's subdomain (required)
        default: your-org
security:
  - ApiToken: []
paths:
  /challenges/{challengeId}/distribution:
    post:
      tags:
        - Challenge
      summary: Assign a distribution details to a challenge
      description: Assign a distribution details to a challenge.
      operationId: assignDistributionDetailsForChallenge
      parameters:
        - in: path
          name: challengeId
          description: The id of the challenge to assign distribution details to
          schema:
            type: string
            description: The id of the challenge to assign distribution details to
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                rewardsConfig:
                  type: object
                  properties:
                    mechanism:
                      type: string
                      enum:
                        - all
                        - priority
                        - random
                        - select
                      description: The mechanism used to distribute the rewards
                    amountToDistribute:
                      type: number
                      minimum: 0
                      description: >-
                        The number of different reward allocations to select
                        from the allocations array. For example, if there are 5
                        allocations but amountToDistribute is 2, only 2 of those
                        5 allocations will be selected based on the specified
                        mechanism (all, priority or random).
                    allocations:
                      type: array
                      items:
                        type: object
                        properties:
                          allocationType:
                            type: string
                            enum:
                              - assets
                              - entries
                            description: >-
                              The type of allocation, either assets or entries.
                              If the reward has a type of assets-and-entries,
                              this allocation can have both assets and entries.
                              Otherwise, it can only have one type matching the
                              reward's allocation type.
                          amountToDistribute:
                            type: number
                            minimum: 1
                            description: >-
                              The quantity of this specific reward to distribute
                              when this allocation is selected. For example, if
                              amountToDistribute is 3, then 3 units of this
                              reward will be given to the recipient.
                          id:
                            type:
                              - string
                              - 'null'
                            description: Only required if updating an existing allocation
                          rewardId:
                            type: string
                            description: The id of the reward the allocation relates to
                          supply:
                            anyOf:
                              - type: number
                                minimum: 0
                              - type: string
                                const: Infinity
                            description: >-
                              The maximum number of rewards available for this
                              allocation. Set to 'Infinity' for unlimited
                              supply. This value is only used when the reward
                              has individual supply tracking
                              (isSharedAssetsSupply or isSharedEntriesSupply is
                              false).
                        required:
                          - allocationType
                          - amountToDistribute
                          - rewardId
                      description: >-
                        The reward allocations to distribute. If any of the
                        allocations are new, the id field should be null. If any
                        of the allocations are updates to existing allocations,
                        the id field should be the id of the allocation to
                        update. If an existing allocation is not included in the
                        array, it will be removed from the distribution event.
                  required:
                    - mechanism
                    - amountToDistribute
                    - allocations
                pointsToDistribute:
                  type: number
                  minimum: 0
                  description: The amount of points to distribute.
                bonusXpToDistribute:
                  type: number
                  minimum: 0
                  description: The amount of bonus xp to distribute
              required:
                - rewardsConfig
                - pointsToDistribute
                - bonusXpToDistribute
              description: The input required to assign distribution details to a challenge
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  pointsToDistribute:
                    type: number
                    minimum: 0
                    description: The amount of points to distribute.
                  bonusXpToDistribute:
                    type: number
                    minimum: 0
                    description: The amount of bonus xp to distribute
                  rewardsConfig:
                    type: object
                    properties:
                      mechanism:
                        type: string
                        enum:
                          - all
                          - priority
                          - random
                          - select
                        description: The mechanism used to distribute the rewards
                      amountToDistribute:
                        type: number
                        minimum: 0
                        description: >-
                          The number of different reward allocations to select
                          from the allocations array. For example, if there are
                          5 allocations but amountToDistribute is 2, only 2 of
                          those 5 allocations will be selected based on the
                          specified mechanism (all, priority or random).
                      allocations:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              description: The ID of this allocation
                            allocationType:
                              type: string
                              enum:
                                - assets
                                - entries
                              description: >-
                                The type of allocation, either assets or
                                entries. If the reward has a type of
                                assets-and-entries, this allocation can have
                                both assets and entries. Otherwise, it can only
                                have one type matching the reward's allocation
                                type.
                            supply:
                              anyOf:
                                - type: number
                                  minimum: 0
                                - type: string
                                  const: Infinity
                              description: >-
                                The total supply of this allocation. Only used
                                if isSharedAssetsSupply or isSharedEntriesSupply
                                is false on the reward.
                            amountToDistribute:
                              type: number
                              minimum: 1
                              description: >-
                                The quantity of this specific reward to
                                distribute when this allocation is selected. For
                                example, if amountToDistribute is 3, then 3
                                units of this reward will be given to the
                                recipient.
                            distributed:
                              type: number
                              minimum: 0
                              description: >-
                                The amount already distributed for this
                                allocation
                            isLive:
                              type: boolean
                              description: Whether this allocation is live
                            rewardId:
                              type: string
                              description: The id of the reward the allocation relates to.
                          required:
                            - id
                            - allocationType
                            - supply
                            - amountToDistribute
                            - distributed
                            - isLive
                            - rewardId
                        description: >-
                          The reward allocations to distribute. If any of the
                          allocations are new, the id field should be null. If
                          any of the allocations are updates to existing
                          allocations, the id field should be the id of the
                          allocation to update. If an existing allocation is not
                          included in the array, it will be removed from the
                          distribution event.
                    required:
                      - mechanism
                      - amountToDistribute
                      - allocations
                  challengeId:
                    type: string
                    description: The id of the challenge with assigned distribution details
                required:
                  - pointsToDistribute
                  - bonusXpToDistribute
                  - rewardsConfig
                  - challengeId
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
components:
  schemas:
    error.BAD_REQUEST:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Invalid input data
        code:
          type: string
          description: The error code
          example: BAD_REQUEST
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
    error.INTERNAL_SERVER_ERROR:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Internal server error
        code:
          type: string
          description: The error code
          example: INTERNAL_SERVER_ERROR
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
  securitySchemes:
    ApiToken:
      type: apiKey
      in: header
      name: x-api-token

````