Skip to main content
PUT
Update Sale Status

Authentication

This endpoint requires authentication with admin privileges.

Path Parameters

number
required
The unique identifier of the sale to update

Request Body

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

boolean
Indicates if the request was successful
object
The updated sale object
number
Sale ID
string
Sale date (ISO 8601 timestamp)
number
Total amount including shipping
string
Updated sale status
string
Payment method
string
Delivery type
number
Shipping cost
number
Customer ID
array
Array of line items
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:
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

Example Response

Example Request - Dispatch Sale

Example Response - Dispatch Sale

Example Request - Cancel Order

Example Response - Cancel Order

Error Responses

Invalid Status (400)

Missing Tracking Code (400) - Dispatch endpoint

Unauthorized (401)

Forbidden - Not Admin (403)

Sale Not Found (404)

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