Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/ecommerce-delivery/llms.txt

Use this file to discover all available pages before exploring further.

This page covers the four endpoints used to retrieve and export sales data. A buyer can list their own orders, admins can view and filter all sales across the platform, a dedicated search endpoint supports lookup by status name or customer identification, and an export endpoint generates a downloadable .xlsx report using the same filters as the admin list.

1. List Own Sales

Returns a paginated list of sales belonging to the currently authenticated user.

Endpoint

POST /api/sale/list-sale/:pag?/:perpage?

Authentication

Requires a valid user Token.

Path Parameters

pag
number
Page number to retrieve (optional, defaults to 1).
perpage
number
Number of results per page (optional, uses server default if omitted).

Response — 200

{
  "msj": "Cargando todas las ventas...",
  "status": true,
  "data": [ ],
  "pagination": {
    "pag": "1",
    "perpage": 10,
    "pags": 3
  }
}

Example Request

curl -X POST https://your-api.com/api/sale/list-sale/1/10 \
  -H "Authorization: Bearer <your_token>"

2. List All Sales (Admin)

Returns a paginated list of all sales across all users. Supports optional text search and month-based date filtering.

Endpoint

POST /api/sale/all-list/:pag?/:perpage?

Authentication

Requires a valid user Token.

Path Parameters

pag
number
Page number to retrieve (optional).
perpage
number
Number of results per page (optional).

Request Body (Optional Filters)

general
string
Free-text search string. Performs a case-insensitive regex match across the following fields: name_client, lastName_client, typeIdentification, identification, phone_number, address, email, codeseller, zipCode, city, products.title, deliveryStatus.description, and status.name.
date
string
Month filter in "YYYY/MM" format (e.g., "2024/05"). Returns all sales whose createdAt timestamp falls within that calendar month.

Response — 200

{
  "msj": "Cargando ventas relacionadas...",
  "status": true,
  "data": [ ],
  "pagination": {
    "pag": "1",
    "perpage": 10,
    "pags": 12
  }
}

Example Request

curl -X POST https://your-api.com/api/sale/all-list/1/10 \
  -H "Authorization: Bearer <your_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "general": "Bogotá",
    "date": "2024/05"
  }'

3. Search Sales

Searches all sales by payment status name or customer identification number.

Endpoint

POST /api/sale/get-search/:query/:pag?/:perpage?

Authentication

Requires a valid user Token and an admin TokenAdmin role.

Path Parameters

query
string
required
The search string. Matched case-insensitively against status.name and identification fields.
pag
number
Page number to retrieve (optional).
perpage
number
Number of results per page (optional).

Response — 200

{
  "msj": "Cargando venta",
  "status": true,
  "data": [ ],
  "pagination": {
    "pag": "1",
    "perpage": 10,
    "pags": 2
  }
}

Example Request

curl -X POST https://your-api.com/api/sale/get-search/Pendiente/1/10 \
  -H "Authorization: Bearer <your_token>" \
  -H "TokenAdmin: <your_admin_token>"

4. Export Sales to XLSX

Applies the same filters as the List All Sales endpoint and returns a downloadable Excel (.xlsx) file containing the full matching sales dataset.

Endpoint

POST /api/sale/export-list-sale-xlsx

Authentication

Requires a valid user Token.

Request Body (Optional Filters)

general
string
Free-text search string (see List All Sales for matched fields).
date
string
Month filter in "YYYY/MM" format.

Response

Returns a binary file with content type application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. The exported workbook contains a sheet named Sales Report with the following columns:
Column HeaderSource Field
Estadostatus.name
Totaltotal
Domicilioaddress
Ciudadcity
Codigo postalzipCode
FechacreatedAt
Correoemail
Tipo de identificaciontypeIdentification
Identificationidentification
Nombrename_client
ApellidolastName_client
Telefonophone_number
The .xlsx file is written to a temporary path (private/temp/{userId}/Sales_report.xlsx) on the server and is automatically deleted 60 seconds after it is sent. Download the file promptly after receiving the response.

Example Request

curl -X POST https://your-api.com/api/sale/export-list-sale-xlsx \
  -H "Authorization: Bearer <your_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "date": "2024/05"
  }' \
  --output Sales_report.xlsx

Sale Response Object

The data array returned by the listing endpoints contains Sale documents. The full structure is described below.
data
array
Array of sale objects.
pagination
object
Pagination metadata.

Build docs developers (and LLMs) love