Skip to main content

Reject Order

This endpoint allows vendors to reject an incoming order that they cannot fulfill.

Overview​

If you are unable to fulfill an incoming order (e.g., due to unavailable items, being too busy), you must reject it. Rejecting the order notifies Presto and the customer that the order will not be processed.

Endpoint Details​

Method: POST
URL: /api/developer/v1/orders/{orderId}/reject
Purpose: Inform Presto that you cannot fulfill the order

Time Limit

Similar to accepting, orders usually need to be rejected within a specific timeframe. Failure to reject (or accept) may lead to automatic cancellation.

Request Specification​

Path Parameters​

ParameterTypeRequiredDescription
orderIdstring / integerYesThe unique identifier of the order to reject

Request Body​

FieldTypeRequiredDescription
reason_codestringNoA standardized code indicating the reason for rejection (e.g., OUT_OF_STOCK, TOO_BUSY, CLOSING_SOON)
reason_textstringNoA free-text explanation for the rejection (may have length limits)

Example Request​

POST /api/developer/v1/orders/12345/reject
Authorization: Bearer <your-token>
Accept: application/json
Content-Type: application/json

{
"cancel_reason_id": 4
}

Cancel Reasons & Unavailable Items Workflow​

Retrieve Cancel Reasons​

Endpoint: GET /api/developer/v1/cancel-reasons

{
"data": [
{
"id": 4,
"name": "I am not available",
"should_select_items": false
},
{
"id": 5,
"name": "Items not available",
"should_select_items": true,
"options": {
"select_items_title": "Please select the unavailable items"
}
},
{
"id": 6,
"name": "Other",
"should_select_items": false
}
]
}

Rejecting with Item Selection​

If you use a cancel reason where should_select_items is true, include the unavailable items in your reject request:

POST /api/developer/v1/orders/{orderId}/reject
Authorization: Bearer <your-token>
Content-Type: application/json

{
"cancel_reason_id": 5,
"items": [
{ "id": 26417 }
]
}

Order Status Change​

When you reject an order and specify unavailable items, the order status will change to contact.
This change notifies the customer and enables them to modify their order (remove the unavailable items), reorder with the remaining or replacement items, or cancel the order entirely themselves.

Best Practices
  • Always fetch cancel reasons to present accurate options to vendors.
  • If items are unavailable, use the correct cancel reason and include affected items.

Response Specification​

Success Response​

200 OK

A successful response indicates the order was rejected.

{
"data": {
"id": "ORDER_123",
"service": "shop",
"status": {
"key": "pending",
// ...other status fields...
},
"total": 0,
"currency": "LYD",
"created_at": "2025-01-01T00:00:00+00:00"
// ...other fields...
}
}

Error Responses​

401 Unauthorized - Authentication issues

{
"status": "error",
"message": "Unauthenticated."
}

404 Not Found - Order not found

{
"status": "error",
"message": "Order not found"
}

400 Bad Request - Order state error

{
"status": "error",
"message": "Order cannot be rejected in its current state"
}

400 Bad Request - Invalid reason

{
"status": "error",
"message": "Invalid rejection reason provided"
}

Implementation Tips​

Best Practices
  • Reject orders promptly if you cannot fulfill them to provide a better customer experience
  • Include a clear reason for rejection to help with analytics and customer communication
  • Implement proper error handling for state conflicts

Next Steps​

After rejecting an order, no further action is required. The order will be marked as rejected in the Presto system, and the customer will be notified.