Skip to main content
PUT
/
api
/
sales
/
:id
/
status
Update Sale Status
curl --request PUT \
  --url https://api.example.com/api/sales/:id/status \
  --header 'Content-Type: application/json' \
  --data '
{
  "status": "<string>",
  "trackingCode": "<string>"
}
'
{
  "success": true,
  "data": {
    "id": 123,
    "fecha": "<string>",
    "montoTotal": 123,
    "estado": "<string>",
    "medioPago": "<string>",
    "tipoEntrega": "<string>",
    "costoEnvio": 123,
    "clienteId": 123,
    "lineasVenta": [
      {}
    ]
  },
  "error": "<string>"
}

Authentication

This endpoint requires authentication with admin privileges.

Path Parameters

id
number
required
The unique identifier of the sale to update

Request Body

status
string
required
The new status for the sale. Must be one of:
  • PENDIENTE_PAGO - Pending payment
  • PENDIENTE_APROBACION - Pending approval (awaiting payment verification)
  • APROBADO - Approved and ready to be prepared
  • ENVIADO - Shipped/dispatched
  • ENTREGADO - Delivered to customer
  • RECHAZADO - Rejected (payment failed or order cancelled by admin)
  • CANCELADO - Cancelled by customer or admin

Response

success
boolean
Indicates if the request was successful
data
object
The updated sale object
id
number
Sale ID
fecha
string
Sale date (ISO 8601 timestamp)
montoTotal
number
Total amount including shipping
estado
string
Updated sale status
medioPago
string
Payment method
tipoEntrega
string
Delivery type
costoEnvio
number
Shipping cost
clienteId
number
Customer ID
lineasVenta
array
Array of line items
error
string
Error message if the request failed

Dispatch Sale

PUT /api/sales/:id/dispatch Specialized endpoint to mark a sale as dispatched with tracking information. Request Body:
trackingCode
string
required
Tracking code for the shipment
This endpoint automatically updates the status to ENVIADO and sets the tracking code.

Cancel Order

PUT /api/sales/:id/cancel Allows users to cancel their own order. Updates the status to CANCELADO and restores product stock. Authentication: Regular user authentication (users can cancel their own orders)

Sale Status Workflow

Typical status progression:
  1. PENDIENTE_PAGO - Initial state after sale creation
  2. PENDIENTE_APROBACION - Payment proof uploaded, awaiting verification
  3. APROBADO - Payment confirmed, order ready for preparation
  4. ENVIADO - Order shipped with tracking code
  5. ENTREGADO - Order delivered to customer
Alternative flows:
  • RECHAZADO - Payment failed or order rejected
  • CANCELADO - Order cancelled by customer or admin

Example Request

{
  "status": "APROBADO"
}

Example Response

{
  "success": true,
  "data": {
    "id": 789,
    "fecha": "2026-03-05T10:30:00.000Z",
    "montoTotal": 50000,
    "estado": "APROBADO",
    "medioPago": "TRANSFERENCIA",
    "tipoEntrega": "ENVIO",
    "costoEnvio": 5000,
    "clienteId": 42,
    "direccionEnvio": "Av. Corrientes 1234",
    "lineasVenta": [
      {
        "id": 1,
        "productoId": 123,
        "cantidad": 2,
        "subTotal": 30000
      },
      {
        "id": 2,
        "productoId": 456,
        "cantidad": 1,
        "subTotal": 15000
      }
    ]
  }
}

Example Request - Dispatch Sale

PUT /api/sales/789/dispatch
{
  "trackingCode": "AR123456789"
}

Example Response - Dispatch Sale

{
  "success": true,
  "data": {
    "id": 789,
    "estado": "ENVIADO",
    "codigoSeguimiento": "AR123456789",
    "montoTotal": 50000,
    "fecha": "2026-03-05T10:30:00.000Z"
  }
}

Example Request - Cancel Order

PUT /api/sales/789/cancel

Example Response - Cancel Order

{
  "success": true,
  "data": {
    "id": 789,
    "estado": "CANCELADO",
    "montoTotal": 50000,
    "fecha": "2026-03-05T10:30:00.000Z"
  }
}

Error Responses

Invalid Status (400)

{
  "success": false,
  "error": "Invalid status"
}

Missing Tracking Code (400) - Dispatch endpoint

{
  "success": false,
  "error": "Tracking required"
}

Unauthorized (401)

{
  "success": false,
  "error": "Unauthorized"
}

Forbidden - Not Admin (403)

{
  "success": false,
  "error": "Admin access required"
}

Sale Not Found (404)

{
  "success": false,
  "error": "Venta no encontrada"
}

Notes

  • Only admin users can update sale status via /api/sales/:id/status
  • The /api/sales/:id/dispatch endpoint is a convenience method for shipping orders
  • The /api/sales/:id/cancel endpoint can be used by regular users to cancel their own orders
  • Cancelling an order restores the product stock that was reserved
  • Status changes may trigger email notifications to customers
  • Once a sale is marked as ENTREGADO, it should not be changed to other statuses
  • Status transitions should follow the logical workflow to maintain data integrity

Build docs developers (and LLMs) love