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

# Purchase a points product

> Purchase a points product on behalf of a customer in the Smile REST API.

export const scope_0 = "points_purchase:write"

<Callout icon="key" iconType="regular">
  This endpoint requires the **{scope_0}** scope.
</Callout>


## OpenAPI

````yaml schemas/rest-api.json POST /points_products/{id}/purchase
openapi: 3.1.0
info:
  title: Smile.io REST API
  version: 1.0.0
  description: A RESTful interface for interacting with Smile.io loyalty programs.
servers:
  - url: https://api.smile.io/v1
security:
  - bearerAuth: []
paths:
  /points_products/{id}/purchase:
    post:
      tags:
        - Points Products
      summary: Purchase a points product
      description: >-
        Exchanges a customer's points for a reward by purchasing a points
        product.
      operationId: post__points_products_id_purchase
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
            description: ID of the points product to purchase.
            example: 132456921
          description: ID of the points product to purchase.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customer_id:
                  type: integer
                  description: ID of the customer who is purchasing the points product.
                  example: 304169228
                points_to_spend:
                  type: integer
                  description: >-
                    The number of points that will be spent on behalf of the
                    customer. Only applies when purchasing a points product
                    whose `exchange_type` is `variable`, otherwise should be
                    left blank.
                  example: 500
              required:
                - customer_id
      responses:
        '201':
          description: The points product was successfully purchased.
          content:
            application/json:
              schema:
                type: object
                properties:
                  points_purchase:
                    $ref: '#/components/schemas/PointsPurchase'
components:
  schemas:
    PointsPurchase:
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the points purchase.
          example: 665523890
        customer_id:
          type: integer
          description: The ID of the customer who performed the points purchase.
          example: 304169228
        points_product_id:
          type: integer
          description: The ID of the points product that was purchased.
          example: 132456921
        points_spent:
          type: integer
          description: The total points spent by the customer.
          example: 500
          minimum: 0
        reward_fulfillment:
          $ref: '#/components/schemas/RewardFulfillment'
          description: A record of a reward that was issued to a customer.
        created_at:
          type: string
          description: The date and time when the points purchase was created.
          format: date-time
          example: '2024-04-04T15:10:42.030Z'
        updated_at:
          type: string
          description: The date and time when the points purchase was last updated.
          format: date-time
          example: '2024-04-04T15:10:42.030Z'
    RewardFulfillment:
      type: object
      properties:
        id:
          type: integer
          example: 625478984
          description: Unique identifier for the reward fulfillment.
        name:
          type: string
          example: $5 off coupon
          description: The name of the reward fulfillment.
        code:
          type: string
          example: 5off-e26d02e39149
          description: >-
            A unique code for the customer to use or apply the reward
            fulfillment. This is commonly a discount code the customer applies
            at checkout on their next order, but it can be a unique code they
            use for other purposes like accessing an exclusive page on the
            merchant's website.
        customer_id:
          type: integer
          example: 304169228
          description: The ID of the customer that the reward fulfillment belongs to.
        fulfillment_status:
          type: string
          enum:
            - pending
            - issued
            - cancelled
            - failed
          example: issued
          description: >-
            The fulfillment status of the reward fulfillment, indicating whether
            the reward is available to the customer.
        image_url:
          type: string
          example: https://platform-images.smilecdn.co/9283449.png
          description: An image for the reward fulfillment.
        action_text:
          type:
            - string
            - 'null'
          description: >-
            A short call-to-action style text, appropriate for use in buttons or
            links, guiding the customer on how to use the reward fulfillment.
            This field may be blank
        action_url:
          type:
            - string
            - 'null'
          description: >-
            A URL destination guiding the customer on how to use the reward,
            often paired with the `action_text` for use in buttons or links.
            This field may be blank.
        usage_instructions:
          type:
            - string
            - 'null'
          example: Use this discount code on your next order!
          description: >-
            A description of how the customer can use or apply the reward
            fulfillment.
        terms_and_conditions:
          type:
            - string
            - 'null'
          example: >-
            Reward expires on June 7, 2025. Reward can only be used on purchase
            of $50 or more. Reward can only be used on select product
            collections.
          description: >-
            A description of the reward fulfillment's limitations or
            restrictions. When the reward is a discount code, this commonly
            includes expiry date, minimum order amounts, or applicability to
            specific product collections.
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2025-06-07T23:59:59.999Z'
          description: >-
            The date and time when the reward fulfillment expires. When the
            reward is a discount code, this refers to the expiry date of the
            discount, and a `null` value indicates that the discount code does
            not expire.
        usage_status:
          type: string
          enum:
            - used
            - unused
            - untracked
          example: unused
          description: >-
            The usage status of the reward fulfillment, indicating whether the
            generated reward has been used by the customer.
        used_at:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            The date and time when the reward fulfillment was used by the
            customer. If the reward fulfillments does not support usage
            tracking, this field may be `null` even after the reward fulfillment
            has been used.
        created_at:
          type: string
          format: date-time
          example: '2024-12-07T20:15:27.893Z'
          description: The date and time when the reward fulfillment was created.
        updated_at:
          type: string
          format: date-time
          example: '2024-12-07T20:15:27.893Z'
          description: The date and time when the reward fulfillment was last updated.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````