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

# Deduct points

> Deducts raw points from a customer's balance (for store credit,
discounts applied in your own system, etc.). Fails if the balance is
insufficient. Supports `Idempotency-Key`.

To redeem a Rigaly **reward**, use the redemptions endpoints instead.




## OpenAPI

````yaml /openapi/v1.yaml post /api/v1/points/redeem
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/points/redeem:
    post:
      tags:
        - Points
      summary: Deduct points
      description: |
        Deducts raw points from a customer's balance (for store credit,
        discounts applied in your own system, etc.). Fails if the balance is
        insufficient. Supports `Idempotency-Key`.

        To redeem a Rigaly **reward**, use the redemptions endpoints instead.
      operationId: redeemPoints
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PointsRequest'
            example:
              user_id: 6f1c9f3a-0000-4000-8000-000000000000
              points: 1000
              description: $10 store credit
      responses:
        '200':
          description: Points deducted
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          customer:
                            $ref: '#/components/schemas/CustomerRef'
                          points_redeemed:
                            type: integer
                            example: 1000
                          balance:
                            type: integer
                            example: 4600
                          transaction:
                            $ref: '#/components/schemas/Transaction'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/CustomerNotFound'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        maxLength: 255
      description: >-
        Optional. Retries with the same key within 24h replay the original
        response instead of repeating the operation.
  schemas:
    PointsRequest:
      type: object
      required:
        - points
      description: Exactly one of `user_id` / `identifier` is required.
      properties:
        user_id:
          type: string
          format: uuid
          description: Rigaly customer ID
        identifier:
          type: string
          description: Email, phone, or a business-scoped external identifier
        points:
          type: integer
          minimum: 1
          maximum: 1000000
        description:
          type: string
          maxLength: 500
          description: Shown in the customer's transaction history
    SuccessEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: true
        message:
          type: string
        data:
          type: object
    CustomerRef:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          example: Jane Doe
    Transaction:
      type: object
      properties:
        id:
          type: string
          format: uuid
        user_id:
          type: string
          format: uuid
        business_id:
          type: string
          format: uuid
        type:
          type: string
          enum:
            - earn
            - redeem
        points:
          type: integer
          description: Signed ledger amount (negative for redeem)
        description:
          type: string
        points_multiplier:
          type: number
          example: 1
        created_at:
          type: string
          format: date-time
    ErrorEnvelope:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            message:
              type: string
  responses:
    BadRequest:
      description: Validation or business-rule error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            success: false
            error:
              message: Provide exactly one of "user_id" or "identifier"
    CustomerNotFound:
      description: No customer matches the reference
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            success: false
            error:
              message: Customer not found. Check the user_id or identifier.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: 'API key from the Rigaly dashboard: `Authorization: Bearer rgly_sk_...`'

````