Skip to main content
The Returns endpoints expose all sales return transactions recorded in SmartPyme, allowing you to reconcile inventory adjustments, audit customer refund activity, and track returned merchandise at the line-item level. Each return record links back to its originating sale via id_venta and includes a full detalles breakdown of returned products. All requests must include your API key in the Authorization header.

GET /returns

Returns a paginated list of sales return records. Filter by date range to scope the results to a specific period. Each record includes header-level return information and a detalles array of the individual products that were returned.
curl --request GET \
  --url "https://api.smartpyme.site/api/external/v1/returns?fecha_inicio=2025-01-01&fecha_fin=2025-01-31&per_page=50" \
  --header "Authorization: Bearer {api_key}"

Query parameters

fecha_inicio
string
Start date for filtering returns, in Y-m-d format (e.g. 2025-01-01). Use together with fecha_fin to define a date range.
fecha_fin
string
End date for filtering returns, in Y-m-d format (e.g. 2025-01-31). Use together with fecha_inicio to define a date range.
page
integer
Page number to retrieve. Defaults to 1.
per_page
integer
Number of records per page. Accepts values between 1 and 200. Defaults to 100.

Response example

{
  "success": true,
  "data": [
    {
      "id": 789,
      "fecha": "2025-01-20",
      "correlativo": "DEV-001234",
      "tipo": "Devolucion",
      "sub_total": 130.00,
      "no_sujeta": 0.00,
      "exenta": 0.00,
      "cuenta_a_terceros": 0.00,
      "total": 149.50,
      "iva": 19.50,
      "iva_retenido": 0.00,
      "observaciones": "Producto defectuoso",
      "enable": 1,
      "id_venta": 12345,
      "nombre_cliente": "Juan Pérez",
      "nombre_usuario": "admin",
      "nombre_documento": "Nota de Crédito",
      "created_at": "2025-01-20T14:00:00Z",
      "updated_at": "2025-01-20T14:00:00Z",
      "detalles": [
        {
          "nombre_producto": "Laptop Dell Inspiron",
          "codigo_producto": "LAP-DELL-001",
          "marca_producto": "Dell",
          "descripcion": "Laptop Dell Inspiron 15",
          "cantidad": 1,
          "precio": 130.00,
          "costo": 100.00,
          "descuento": 0.00,
          "no_sujeta": 0.00,
          "cuenta_a_terceros": 0.00,
          "exenta": 0.00,
          "total": 149.50,
          "medida": "Unidad"
        }
      ]
    }
  ],
  "pagination": {
    "current_page": 1,
    "per_page": 50,
    "total": 45,
    "total_pages": 1,
    "has_next": false,
    "has_prev": false
  },
  "meta": {
    "empresa": "Mi Empresa S.A.",
    "timestamp": "2025-01-31T15:00:00Z",
    "filters_applied": {
      "fecha_inicio": "2025-01-01",
      "fecha_fin": "2025-01-31"
    }
  }
}

Response fields

success
boolean
Indicates whether the request completed successfully.
data
array
Array of return objects matching the applied filters.

GET /returns/{id}

Retrieves a single return record by its numeric ID. The response returns the same full Return object described above, including the detalles array of returned line items.

Path parameter

id
integer
required
The unique numeric identifier of the return record you want to retrieve.
curl --request GET \
  --url "https://api.smartpyme.site/api/external/v1/returns/789" \
  --header "Authorization: Bearer {api_key}"
The response wraps the Return object under a data key with "success": true. All fields, including detalles, are identical to the structure documented in the GET /returns response above.

GET /returns/summary

Returns aggregate statistics for your return activity over an optional date range. Use this endpoint to measure the volume and value of merchandise being returned, identify high-return periods, and quantify the financial impact of returns on your revenue.
curl --request GET \
  --url "https://api.smartpyme.site/api/external/v1/returns/summary?fecha_inicio=2025-01-01&fecha_fin=2025-01-31" \
  --header "Authorization: Bearer {api_key}"

Query parameters

fecha_inicio
string
Start date for the summary period, in Y-m-d format. Omit to include all return records from the beginning.
fecha_fin
string
End date for the summary period, in Y-m-d format. Omit to include all records up to the current date.

Response example

{
  "success": true,
  "data": {
    "cantidad_devoluciones": 45,
    "total_devuelto": 6750.00,
    "total_iva": 607.50,
    "total_descuentos": 125.00,
    "promedio_devolucion": 150.00,
    "devoluciones_por_tipo": [
      { "tipo": "Devolucion", "cantidad": 45, "total": 6750.00 }
    ]
  },
  "meta": {
    "empresa": "Mi Empresa S.A.",
    "timestamp": "2025-01-31T23:59:00Z",
    "filters_applied": {
      "fecha_inicio": "2025-01-01",
      "fecha_fin": "2025-01-31"
    }
  }
}

Response fields

data.cantidad_devoluciones
integer
Total number of return transactions processed within the requested period.
data.total_devuelto
number
Gross monetary value of all returns in the period, including tax.
data.total_iva
number
Total tax amount included across all return records in the period.
data.total_descuentos
number
Sum of all discounts applied to returned line items in the period.
data.promedio_devolucion
number
Average value per return transaction, calculated as total_devuelto / cantidad_devoluciones.
data.devoluciones_por_tipo
array
Breakdown of return count and total value grouped by document type.
meta.empresa
string
Display name of the company associated with your API key.
meta.timestamp
string
ISO 8601 timestamp indicating when the summary was generated.
meta.filters_applied
object
Echo of the date filters used to compute the summary, useful for confirming the request parameters.