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

# Listar devoluciones de ventas

> Obtiene una lista paginada de devoluciones con filtros opcionales.



## OpenAPI

````yaml /openapi.yaml get /returns
openapi: 3.0.0
info:
  title: SmartPYME External API
  description: >
    API Externa de SmartPYME para proveedores terceros.


    Permite consultar y registrar ventas, consultar inventario y devoluciones, e
    importar paquetes usando autenticación por API Key.


    ## Autenticación

    Todas las requests requieren un API Key válido en el header Authorization:

    ```

    Authorization: Bearer {tu_api_key}

    ```


    ## Rate Limiting

    - Sin filtros de fecha: 1000 requests/hora

    - Con filtros de fecha: 2000 requests/hora


    ## Paginación

    Todos los endpoints de lista soportan paginación:

    - `page`: Número de página (default: 1)

    - `per_page`: Registros por página (1-200, default: 100)
  version: 1.4.0
  contact:
    name: SmartPYME Support
    email: soporte@smartpyme.com
  license:
    name: Propietario
    url: https://smartpyme.com/terms
servers:
  - url: https://tu-dominio.com/api/external/v1
    description: Servidor de Producción
  - url: http://localhost/api/external/v1
    description: Servidor de Desarrollo
security:
  - ApiKeyAuth: []
paths:
  /returns:
    get:
      tags:
        - Devoluciones
      summary: Listar devoluciones de ventas
      description: Obtiene una lista paginada de devoluciones con filtros opcionales.
      parameters:
        - name: fecha_inicio
          in: query
          description: Fecha de inicio (Y-m-d)
          schema:
            type: string
            format: date
            example: '2024-01-01'
        - name: fecha_fin
          in: query
          description: Fecha de fin (Y-m-d)
          schema:
            type: string
            format: date
            example: '2024-12-31'
        - name: id_venta
          in: query
          description: ID de la venta original
          schema:
            type: integer
            example: 12345
        - name: page
          in: query
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: per_page
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 100
      responses:
        '200':
          description: Lista de devoluciones obtenida exitosamente
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReturnsListResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimitExceeded'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    ReturnsListResponse:
      allOf:
        - $ref: '#/components/schemas/BaseResponse'
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: '#/components/schemas/Return'
            pagination:
              $ref: '#/components/schemas/Pagination'
    BaseResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indica si la operación fue exitosa
        meta:
          $ref: '#/components/schemas/Meta'
      required:
        - success
    Return:
      type: object
      properties:
        id:
          type: integer
        fecha:
          type: string
          format: date
        correlativo:
          type: string
        tipo:
          type: string
        sub_total:
          type: number
        total:
          type: number
        iva:
          type: number
        observaciones:
          type: string
        estado:
          type: string
          enum:
            - Confirmada
            - Anulada
        id_venta:
          type: integer
        nombre_cliente:
          type: string
        nombre_usuario:
          type: string
        nombre_documento:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        detalles:
          type: array
          items:
            $ref: '#/components/schemas/ReturnDetail'
    Pagination:
      type: object
      properties:
        current_page:
          type: integer
          example: 1
        per_page:
          type: integer
          example: 100
        total:
          type: integer
          example: 1250
        total_pages:
          type: integer
          example: 13
        has_next:
          type: boolean
          example: true
        has_prev:
          type: boolean
          example: false
        from:
          type: integer
          nullable: true
          example: 1
        to:
          type: integer
          nullable: true
          example: 100
      required:
        - current_page
        - per_page
        - total
        - total_pages
        - has_next
        - has_prev
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
          description: Mensaje de error
        code:
          type: integer
          description: Código de error HTTP
      required:
        - success
        - error
        - code
    Meta:
      type: object
      properties:
        empresa:
          type: string
          description: Nombre de la empresa
          example: Mi Empresa S.A.
        timestamp:
          type: string
          format: date-time
          description: Timestamp de la respuesta
        filters_applied:
          type: object
          description: Filtros aplicados en la consulta
      required:
        - empresa
        - timestamp
    ReturnDetail:
      type: object
      properties:
        nombre_producto:
          type: string
        codigo_producto:
          type: string
        marca_producto:
          type: string
        cantidad:
          type: number
        precio:
          type: number
        total:
          type: number
  responses:
    Unauthorized:
      description: API Key inválido o faltante
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error: API key inválido o empresa inactiva
            code: 401
    RateLimitExceeded:
      description: Rate limit excedido
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error: >-
              Rate limit excedido. Máximo 1000 requests por hora (2000 con
              filtros de fecha).
            code: 429
    InternalServerError:
      description: Error interno del servidor
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            success: false
            error: Error interno del servidor
            code: 500
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: |
        API Key de la empresa en formato Bearer token.

        Ejemplo: `Authorization: Bearer G8RCjH11DabBNjnX7wO5`

````