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

# Listar canjes

> Devuelve los canjes del comercio, paginados y ordenados por fecha. Si no se envían `startDate` y `endDate`, toma el último mes.

**Atención**: a diferencia del resto de la API, este endpoint devuelve el objeto de paginación directamente, sin el envelope `{ success, status, message, data }`.



## OpenAPI

````yaml /api-reference/openapi.json get /external/purchase
openapi: 3.0.0
info:
  title: API de Tienda de Puntos
  description: >-
    API pública de Tienda de Puntos. Permite sumar puntos por compra, consultar
    clientes, validar canjes y consumir cupones desde tu POS, ERP o e-commerce.


    Todas las llamadas se autentican con el header `x-api-key`.
  version: 0.0.1
  contact: {}
servers:
  - url: https://api.tiendadepuntos.com
    description: Producción
  - url: https://apidev.tiendadepuntos.com
    description: Desarrollo
security:
  - ApiKeyAuth: []
tags: []
paths:
  /external/purchase:
    get:
      tags:
        - Canjes
      summary: Listar canjes
      description: >-
        Devuelve los canjes del comercio, paginados y ordenados por fecha. Si no
        se envían `startDate` y `endDate`, toma el último mes.


        **Atención**: a diferencia del resto de la API, este endpoint devuelve
        el objeto de paginación directamente, sin el envelope `{ success,
        status, message, data }`.
      operationId: ExternalPurchaseController_findAll
      parameters:
        - name: page
          required: false
          in: query
          schema:
            type: integer
            default: 1
            example: 1
        - name: limit
          required: false
          in: query
          schema:
            type: integer
            default: 15
            example: 15
        - name: startDate
          required: false
          in: query
          description: Fecha de inicio (ISO 8601). Por defecto, un mes atrás.
          schema:
            type: string
            format: date-time
            example: '2026-07-01T00:00:00.000Z'
        - name: endDate
          required: false
          in: query
          description: Fecha de fin (ISO 8601). Por defecto, ahora.
          schema:
            type: string
            format: date-time
            example: '2026-07-31T23:59:59.000Z'
        - name: orderBy
          required: false
          in: query
          description: Orden por fecha de creación.
          schema:
            enum:
              - ASC
              - DESC
            type: string
      responses:
        '200':
          description: Página de canjes. Sin envelope.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: integer
                          example: 45012
                        code:
                          type: string
                          example: A1B2C3
                        points:
                          type: integer
                          example: 500
                        status:
                          type: string
                          example: PENDING
                        createdAt:
                          format: date-time
                          type: string
                          example: '2026-07-28T18:05:00.000Z'
                        redeemedAt:
                          type: string
                          format: date-time
                          nullable: true
                          example: '2026-07-29T10:12:00.000Z'
                        product:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 771
                            name:
                              type: string
                              example: Café gratis
                            points:
                              type: integer
                              example: 500
                        client:
                          type: object
                          properties:
                            id:
                              type: integer
                              example: 84213
                            firstName:
                              type: string
                              example: Juan Manuel
                            lastName:
                              type: string
                              example: Pérez
                            email:
                              type: string
                              example: juanma@mailinator.com
                  meta:
                    type: object
                    properties:
                      totalItems:
                        type: integer
                        example: 128
                      itemCount:
                        type: integer
                        example: 10
                      itemsPerPage:
                        type: integer
                        example: 10
                      totalPages:
                        type: integer
                        example: 13
                      currentPage:
                        type: integer
                        example: 1
                      from:
                        type: integer
                        example: 1
                      to:
                        type: integer
                        example: 10
                  links:
                    type: object
                    properties:
                      first:
                        type: string
                        example: external/purchase?page=1&limit=10
                      previous:
                        type: string
                        example: null
                        nullable: true
                      next:
                        type: string
                        nullable: true
                        example: external/purchase?page=2&limit=10
                      last:
                        type: string
                        example: external/purchase?page=13&limit=10
                      path:
                        type: string
                        example: external/purchase
                      firstPageUrl:
                        type: string
                        example: external/purchase?page=1&limit=10
                      lastPageUrl:
                        type: string
                        example: external/purchase?page=13&limit=10
        '400':
          description: El cuerpo o los parámetros no pasaron la validación.
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 400
                  timestamp:
                    type: string
                    format: date-time
                    example: '2026-07-31T14:05:12.431Z'
                  path:
                    type: string
                    example: /external/tags/add
                  method:
                    type: string
                    example: POST
                  message:
                    type: string
                    example: Error de validación
                  errors:
                    type: array
                    nullable: true
                    items:
                      type: object
                  data:
                    type: object
                    nullable: true
        '404':
          description: >-
            Falta el header `x-api-key` (`Api Key is required`) o la API key no
            corresponde a ningún comercio (`Business not found`). También se usa
            cuando el recurso pedido no existe.
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 404
                  timestamp:
                    type: string
                    format: date-time
                    example: '2026-07-31T14:05:12.431Z'
                  path:
                    type: string
                    example: /external/tags/add
                  method:
                    type: string
                    example: POST
                  message:
                    type: string
                    example: Api Key is required
                  errors:
                    type: array
                    nullable: true
                    items:
                      type: object
                  data:
                    type: object
                    nullable: true
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key del comercio. Se genera desde el panel de Tienda de Puntos, en
        Configuración → Integraciones.

````