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 associateddetalles line items.
Query parameters
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.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.Filter by sale status. Accepted values:
Completada, Pendiente, Anulada, Cotizacion.Page number to retrieve. Defaults to
1.Number of records per page. Accepts values between
1 and 200. Defaults to 100.Field to sort results by. Accepted values:
fecha, total, correlativo, created_at.Sort direction. Accepted values:
asc, desc.Response example
Response fields
Indicates whether the request completed successfully.
Array of sale objects matching the applied filters.
POST /sales
Creates and processes a sale through the same invoicing logic the SmartPyme UI uses. Use this endpoint to push transactions into SmartPyme from external POS, e-commerce, or marketplace systems, or to generate quotations programmatically. The endpoint runs the full business pipeline — stock movements, tax breakdown, document correlatives, and document of sale generation — so the sale you create here is indistinguishable from one entered manually in the app.When to use it
- A confirmed sale needs to be registered immediately and marked as paid (
PagadaorCompletada). - A pending sale needs to be opened and finalized later from the SmartPyme UI (
Pendiente). - A quotation needs to be created from an external quoting tool (
Cotizacion).
Idempotency
Pass an external identifier throughreferencia_externa (or referencia) to make the request idempotent. If a sale with the same referencia already exists for your company, the API returns the existing record with HTTP 200 and meta.idempotent: true instead of creating a duplicate. New sales return HTTP 201. Always set this field when retrying requests or syncing from systems that may resend the same transaction.
Body parameters
External identifier from your system. When provided, the endpoint becomes idempotent for this value (see Idempotency). Alias:
referencia. Maximum 255 characters.Sale date, in
Y-m-d format (e.g. 2025-01-15).Initial state of the sale. Accepted values:
Pagada, Completada, Pendiente, Cotizacion. Use Pendiente for sales that will be finalized later; Pendiente requires id_cliente. Cotizacion creates a quotation rather than a confirmed sale.Branch identifier. Required if
sucursal is not provided.Branch name. Resolved server-side to the matching
id_sucursal. Required if id_sucursal is not provided.Warehouse identifier that stock movements will be applied to. Must belong to your company.
Sales document type identifier (e.g. invoice, ticket). The correlativo is taken from this document.
Sales channel identifier (e.g. counter, online). Required unless
estado is Cotizacion.Customer identifier. Required when
estado is Pendiente. Optional for other states.Payment method (e.g.
Efectivo, Tarjeta, Transferencia). Defaults to Efectivo. Maximum 100 characters.Amount tendered by the customer. Defaults to the sale total when
estado is Pagada.Change returned to the customer. Defaults to
0.Expiration date for the sale or quotation, in
Y-m-d format.Free-text notes recorded on the sale. Maximum 1000 characters.
Marks the sale as a quotation. Automatically set to
true when estado is Cotizacion.Line items for the sale. Must contain at least 1 and at most 100 entries.
Response
On success, the response wraps the full Sale object underdata — identical to the structure returned by GET /sales. The meta.idempotent flag indicates whether the record was newly created or returned from a prior request:
201 Created— a new sale was created (meta.idempotent: false).200 OK— the request matched an existingreferenciaand the previously created sale is returned (meta.idempotent: true).
422 and a details object listing the failing fields.
GET /sales/{id}
Retrieves a single sale record by its numeric ID. The response returns the same full Sale object described above, including thedetalles array of line items.
Path parameter
The unique numeric identifier of the sale you want to retrieve.
data key with "success": true. All fields, including detalles, are identical to the structure documented in the GET /sales response above.
PUT /sales/{id}
Updates an existing sale or quotation that has not yet been finalized. Use this endpoint to adjust line items, change the customer, switch the branch or warehouse, or transition a quotation into a confirmed sale.When to use it
- Edit a
Pendiente,Cotizacion, orPre-ventarecord before it is finalized — for example, to add or remove items, fix the customer, or update the payment method. - Convert a quotation into a sale by sending
estado: "Pagada"or"Completada"together with the final line items.
Restrictions
- Only sales in state
Pendiente,Cotizacion, orPre-ventacan be updated. Attempting to update a sale in any other state returns HTTP422. - Sales that already have a fiscal document emitted cannot be updated and return HTTP
422. - Annulled sales (
Anulada) cannot be updated and return HTTP422. - The same 100-line maximum applies to the
detallesarray.
Path parameter
The numeric identifier of the sale to update.
Body parameters
All body fields are optional. Send only the fields you want to change; omitted fields keep their current value. Ifdetalles is omitted, the existing line items are preserved.
Sale date, in
Y-m-d format.New state for the sale. Accepted values:
Pagada, Completada, Pendiente, Cotizacion, Pre-venta.Branch identifier.
Branch name. Resolved server-side to the matching
id_sucursal.Warehouse identifier.
Sales document type identifier.
Sales channel identifier.
Customer identifier. Required when transitioning the sale to
Pendiente.Payment method.
Amount tendered by the customer.
Change returned to the customer.
Expiration date, in
Y-m-d format.Free-text notes. Maximum 1000 characters.
Marks the sale as a quotation.
Replacement line items. When provided, must contain between 1 and 100 entries. Pass an existing line’s
id to update it in place; omit the id to add a new line. Lines not included in the new array are removed.200 and the updated Sale object under data, using the same structure as GET /sales.
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.Query parameters
Start date for the summary period, in
Y-m-d format. Omit to include all records from the beginning.End date for the summary period, in
Y-m-d format. Omit to include all records up to the current date.Limit the summary to a specific sale status. Accepted values:
Completada, Pendiente, Anulada, Cotizacion.Response example
Response fields
Total number of sale records within the requested period.
Gross revenue across all sales in the period.
Total tax collected across all sales in the period.
Total discount amount applied across all sales in the period.
Average sale value for the period, calculated as
total_ventas / cantidad_ventas.Breakdown of sales count and total revenue grouped by status.
Display name of the company associated with your API key.
ISO 8601 timestamp indicating when the summary was generated.
Echo of the filters used to compute the summary, useful for confirming the request parameters.