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

# Upload pool values

> Adds one-time values to a pool-sourced reward — 1–5000 per request, each
1–500 characters. Send as many requests as you need up to the reward's
`capacity` (100,000 stored values).

**Uploading is idempotent by value.** Duplicates inside the request and
values the pool already holds are counted and skipped, never stored
twice, so re-sending a file you are unsure about is safe.

**Refilling reopens the reward.** If the pool had emptied
(`deactivated_by_pool: true`), a successful upload switches the reward
back on — unless its redemption cap is also blocking, or you switched it
off by hand.




## OpenAPI

````yaml /openapi/v1.yaml post /api/v1/rewards/{id}/pool/codes
openapi: 3.1.0
info:
  title: Rigaly Business API
  version: '1.0'
  description: |
    Public API for businesses to manage their Rigaly loyalty programs: issue
    and redeem points, manage rewards, validate redemptions, and generate mass
    codes for physical products.

    All endpoints require an API key created in the Rigaly business dashboard
    (Tools → API Management), passed as `Authorization: Bearer rgly_sk_...`.
  contact:
    email: support@rigaly.com
servers:
  - url: https://api.rigaly.com
    description: Production
security:
  - apiKey: []
paths:
  /api/v1/rewards/{id}/pool/codes:
    post:
      tags:
        - Rewards
      summary: Upload pool values
      description: |
        Adds one-time values to a pool-sourced reward — 1–5000 per request, each
        1–500 characters. Send as many requests as you need up to the reward's
        `capacity` (100,000 stored values).

        **Uploading is idempotent by value.** Duplicates inside the request and
        values the pool already holds are counted and skipped, never stored
        twice, so re-sending a file you are unsure about is safe.

        **Refilling reopens the reward.** If the pool had emptied
        (`deactivated_by_pool: true`), a successful upload switches the reward
        back on — unless its redemption cap is also blocking, or you switched it
        off by hand.
      operationId: uploadRewardPoolCodes
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PoolCodesUpload'
      responses:
        '200':
          description: Upload result and the resulting pool counts
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/PoolUploadResult'
              example:
                success: true
                message: Pool codes uploaded successfully
                data:
                  reward_id: 3f2b1c9e-7d4a-4f1b-8c2e-9a0d1e2f3b4c
                  submitted: 5000
                  accepted: 4990
                  rejected_duplicates_in_request: 4
                  rejected_duplicates_existing: 6
                  rejected_invalid: 0
                  total: 4990
                  available: 4990
                  consumed: 0
                  capacity: 100000
        '400':
          description: |
            Nothing in the request was storable — every value blank, over 500
            characters, or already in the pool (`POOL_UPLOAD_EMPTY`); more than
            5000 values in one request (`POOL_UPLOAD_TOO_LARGE:<max>` — split
            the list); or the reward is not pool-sourced
            (`REWARD_NOT_POOL_SOURCED`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              example:
                success: false
                error:
                  message: POOL_UPLOAD_EMPTY
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: >-
            The upload would push the pool past its ceiling
            (`POOL_CAPACITY_EXCEEDED:<max>`). Nothing was stored — delete
            unconsumed values or split the upload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              example:
                success: false
                error:
                  message: POOL_CAPACITY_EXCEEDED:100000
components:
  parameters:
    ResourceId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
  schemas:
    PoolCodesUpload:
      type: object
      required:
        - codes
      description: One-time values to add to the reward's pool.
      properties:
        codes:
          type: array
          minItems: 1
          maxItems: 5000
          items:
            type: string
            minLength: 1
            maxLength: 500
          example:
            - NFLX-A1B2C3
            - NFLX-D4E5F6
            - NFLX-G7H8J9
          description: >-
            1–5000 values per request, each 1–500 characters. Duplicates (within
            the request or already stored) are reported, never stored twice.
    SuccessEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
        data:
          type: object
    PoolUploadResult:
      allOf:
        - $ref: '#/components/schemas/RewardPoolStats'
        - type: object
          description: >-
            The post-upload pool counts plus a breakdown of what happened to the
            submitted values.
          properties:
            submitted:
              type: integer
              example: 5000
              description: Values in the request.
            accepted:
              type: integer
              example: 4990
              description: Values actually stored.
            rejected_duplicates_in_request:
              type: integer
              example: 4
              description: >-
                Values that appeared more than once in this request; the first
                occurrence is kept.
            rejected_duplicates_existing:
              type: integer
              example: 6
              description: >-
                Values the pool already held. Uploading the same file twice is
                safe — nothing is stored twice.
            rejected_invalid:
              type: integer
              example: 0
              description: Blank values, or values over 500 characters.
    ErrorEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            message:
              type: string
    RewardPoolStats:
      type: object
      description: 'Counts for a `digital_asset_source: pool` reward.'
      properties:
        reward_id:
          type: string
          format: uuid
        total:
          type: integer
          example: 5000
          description: Every value currently stored — `available + consumed`.
        available:
          type: integer
          example: 4863
          description: >-
            Unconsumed values left. At 0 the reward switches itself off with
            `deactivated_by_pool: true`.
        consumed:
          type: integer
          example: 137
          description: >-
            Values already handed to a customer. Permanent — consumed values can
            never be deleted or edited.
        capacity:
          type: integer
          example: 100000
          description: Hard ceiling on `total` for one reward.
  responses:
    NotFound:
      description: Resource not found (or belongs to another business)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            success: false
            error:
              message: Reward not found
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: 'API key from the Rigaly dashboard: `Authorization: Bearer rgly_sk_...`'

````