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

# Get batch stats



## OpenAPI

````yaml /openapi/v1.yaml get /api/v1/code-batches/{id}
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/code-batches/{id}:
    get:
      tags:
        - Code batches
      summary: Get batch stats
      operationId: getCodeBatch
      parameters:
        - $ref: '#/components/parameters/ResourceId'
      responses:
        '200':
          description: Batch with stats
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          batch:
                            $ref: '#/components/schemas/CodeBatchStats'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    ResourceId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
  schemas:
    SuccessEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
        data:
          type: object
    CodeBatchStats:
      allOf:
        - $ref: '#/components/schemas/CodeBatch'
        - type: object
          properties:
            claimed:
              type: integer
              example: 1204
            remaining:
              type: integer
              example: 98796
            points_issued:
              type: integer
              example: 301000
    CodeBatch:
      type: object
      properties:
        id:
          type: string
          format: uuid
        business_id:
          type: string
          format: uuid
        batch_ref:
          type: string
          example: 595Y
        name:
          type: string
          example: Summer 2027 bottles
        prefix:
          type: string
          nullable: true
          example: SUMMER
        points:
          type: integer
          example: 250
        quantity:
          type: integer
          example: 30000
        expires_at:
          type: string
          format: date-time
        active:
          type: boolean
        created_via:
          type: string
          example: api
        created_at:
          type: string
          format: date-time
        failed_attempts:
          type: integer
          example: 0
          description: >-
            Claim attempts that failed signature verification — a
            counterfeiting-attempt signal. Deactivate the batch if it spikes
            unexpectedly.
    ErrorEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            message:
              type: string
  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_...`'

````