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
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.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.string
Filter by sale status. Accepted values:
Completada, Pendiente, Anulada, Cotizacion.integer
Page number to retrieve. Defaults to
1.integer
Number of records per page. Accepts values between
1 and 200. Defaults to 100.string
Field to sort results by. Accepted values:
fecha, total, correlativo, created_at.string
Sort direction. Accepted values:
asc, desc.Response example
Response fields
boolean
Indicates whether the request completed successfully.
array
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
string
External identifier from your system. When provided, the endpoint becomes idempotent for this value (see Idempotency). Alias:
referencia. Maximum 255 characters.string
required
Sale date, in
Y-m-d format (e.g. 2025-01-15).string
required
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.integer
Branch identifier. Required if
sucursal is not provided.string
Branch name. Resolved server-side to the matching
id_sucursal. Required if id_sucursal is not provided.integer
required
Warehouse identifier that stock movements will be applied to. Must belong to your company.
integer
required
Sales document type identifier (e.g. invoice, ticket). The correlativo is taken from this document.
integer
Sales channel identifier (e.g. counter, online). Required unless
estado is Cotizacion.integer
Customer identifier. Required when
estado is Pendiente. Optional for other states.string
Payment method (e.g.
Efectivo, Tarjeta, Transferencia). Defaults to Efectivo. Maximum 100 characters.number
Amount tendered by the customer. Defaults to the sale total when
estado is Pagada.number
Change returned to the customer. Defaults to
0.string
Expiration date for the sale or quotation, in
Y-m-d format.string
Free-text notes recorded on the sale. Maximum 1000 characters.
boolean
Marks the sale as a quotation. Automatically set to
true when estado is Cotizacion.array
required
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
integer
required
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
integer
required
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.
string
Sale date, in
Y-m-d format.string
New state for the sale. Accepted values:
Pagada, Completada, Pendiente, Cotizacion, Pre-venta.integer
Branch identifier.
string
Branch name. Resolved server-side to the matching
id_sucursal.integer
Warehouse identifier.
integer
Sales document type identifier.
integer
Sales channel identifier.
integer
Customer identifier. Required when transitioning the sale to
Pendiente.string
Payment method.
number
Amount tendered by the customer.
number
Change returned to the customer.
string
Expiration date, in
Y-m-d format.string
Free-text notes. Maximum 1000 characters.
boolean
Marks the sale as a quotation.
array
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
string
Start date for the summary period, in
Y-m-d format. Omit to include all records from the beginning.string
End date for the summary period, in
Y-m-d format. Omit to include all records up to the current date.string
Limit the summary to a specific sale status. Accepted values:
Completada, Pendiente, Anulada, Cotizacion.Response example
Response fields
integer
Total number of sale records within the requested period.
number
Gross revenue across all sales in the period.
number
Total tax collected across all sales in the period.
number
Total discount amount applied across all sales in the period.
number
Average sale value for the period, calculated as
total_ventas / cantidad_ventas.array
Breakdown of sales count and total revenue grouped by status.
string
Display name of the company associated with your API key.
string
ISO 8601 timestamp indicating when the summary was generated.
object
Echo of the filters used to compute the summary, useful for confirming the request parameters.