Skip to main content
The Sales endpoints let you retrieve your full transaction history from SmartPyme, including individual line items, customer details, and payment information. Use these endpoints to build reporting dashboards, sync data to external systems, or audit completed and pending transactions. All requests must include your API key in the Authorization header.

GET /sales

Returns a paginated list of sales records. Apply query parameters to narrow results by date range, status, or sort order. Each record in the response includes the full sale object with its associated detalles line items.
curl --request GET \
  --url "https://api.smartpyme.site/api/external/v1/sales?fecha_inicio=2025-01-01&fecha_fin=2025-01-31&estado=Completada&per_page=50" \
  --header "Authorization: Bearer {api_key}"

Query parameters

fecha_inicio
string
Start date for filtering sales, in Y-m-d format (e.g. 2025-01-01). Used together with fecha_fin to define a date range.
fecha_fin
string
End date for filtering sales, in Y-m-d format (e.g. 2025-01-31). Used together with fecha_inicio to define a date range.
estado
string
Filter by sale status. Accepted values: Completada, Pendiente, Anulada, Cotizacion.
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.
order_by
string
Field to sort results by. Accepted values: fecha, total, correlativo, created_at.
order_direction
string
Sort direction. Accepted values: asc, desc.

Response example

{
  "success": true,
  "data": [
    {
      "id": 10421,
      "fecha": "2025-01-15",
      "correlativo": "FAC-002501",
      "estado": "Completada",
      "forma_pago": "Efectivo",
      "monto_pago": 200.00,
      "cambio": 20.00,
      "iva_percibido": 16.25,
      "iva_retenido": 0.00,
      "renta_retenida": 0.00,
      "iva": 16.25,
      "total_costo": 120.00,
      "descuento": 10.00,
      "sub_total": 163.75,
      "no_sujeta": 0.00,
      "exenta": 0.00,
      "gravada": 163.75,
      "cuenta_a_terceros": 0.00,
      "total": 180.00,
      "propina": 0.00,
      "observaciones": "Entrega en tienda",
      "recurrente": false,
      "cotizacion": false,
      "saldo": 0.00,
      "nombre_cliente": "María López",
      "nombre_usuario": "admin",
      "nombre_vendedor": "Carlos Díaz",
      "nombre_sucursal": "Sucursal Central",
      "nombre_canal": "Mostrador",
      "nombre_documento": "Factura",
      "created_at": "2025-01-15T10:35:00Z",
      "updated_at": "2025-01-15T10:35:00Z",
      "detalles": [
        {
          "nombre_producto": "Laptop Dell Inspiron 15",
          "codigo_producto": "LAP-DELL-015",
          "marca_producto": "Dell",
          "cantidad": 1,
          "precio": 163.75,
          "costo": 120.00,
          "descuento": 10.00,
          "total_costo": 120.00,
          "total": 163.75,
          "iva": 16.25
        }
      ]
    }
  ],
  "pagination": {
    "current_page": 1,
    "per_page": 50,
    "total": 120,
    "total_pages": 3,
    "has_next": true,
    "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",
      "estado": "Completada"
    }
  }
}

Response fields

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

GET /sales/{id}

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

Path parameter

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

GET /sales/summary

Returns aggregate statistics for your sales data over an optional date range. Use this endpoint to build high-level reporting widgets — total revenue, average transaction value, tax collected, and a breakdown of transaction counts and totals by status.
curl --request GET \
  --url "https://api.smartpyme.site/api/external/v1/sales/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 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.
estado
string
Limit the summary to a specific sale status. Accepted values: Completada, Pendiente, Anulada, Cotizacion.

Response example

{
  "success": true,
  "data": {
    "cantidad_ventas": 125,
    "total_ventas": 18750.50,
    "total_iva": 1687.55,
    "total_descuentos": 250.00,
    "promedio_venta": 150.00,
    "ventas_por_estado": [
      { "estado": "Completada", "cantidad": 120, "total": 18000.00 },
      { "estado": "Anulada",    "cantidad": 5,   "total": 750.50   }
    ]
  },
  "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_ventas
integer
Total number of sale records within the requested period.
data.total_ventas
number
Gross revenue across all sales in the period.
data.total_iva
number
Total tax collected across all sales in the period.
data.total_descuentos
number
Total discount amount applied across all sales in the period.
data.promedio_venta
number
Average sale value for the period, calculated as total_ventas / cantidad_ventas.
data.ventas_por_estado
array
Breakdown of sales count and total revenue grouped by status.
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 filters used to compute the summary, useful for confirming the request parameters.