Skip to main content

POST /api/orders/:id/confirm-commitment

Confirms the user’s commitment to pick up an order. This endpoint is required for users with a history of no-shows (trust tier “watch” or “restricted”) who have pending orders that require explicit commitment confirmation.

Authentication

Requires a valid JWT access token in the Authorization header. Allowed roles: student, faculty

Path parameters

id
string
required
The order ID

Response

success
boolean
Indicates if the commitment was confirmed successfully
message
string
Confirmation message
order
object
Updated order object with commitment confirmed

Example request

cURL
curl -X POST https://api.campusbite.com/api/orders/507f1f77bcf86cd799439011/confirm-commitment \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example responses

200 Success
{
  "success": true,
  "message": "Commitment confirmed. Your order will be processed.",
  "order": {
    "id": "507f1f77bcf86cd799439011",
    "orderNumber": "CB20240115001",
    "status": "placed",
    "requiresCommitment": true,
    "commitmentConfirmedAt": "2024-01-15T10:15:30.000Z",
    "commitmentDeadline": "2024-01-15T10:19:00.000Z",
    "totalAmount": 380,
    "paymentStatus": "pending"
  }
}
400 Already confirmed
{
  "success": false,
  "message": "Commitment already confirmed for this order."
}
400 Commitment expired
{
  "success": false,
  "message": "Commitment window has expired. Order has been cancelled."
}
400 No commitment required
{
  "success": false,
  "message": "This order does not require commitment confirmation."
}
403 Not your order
{
  "success": false,
  "message": "You are not authorized to confirm commitment for this order."
}
404 Order not found
{
  "success": false,
  "message": "Order not found."
}

How it works

Trust tier system

Users are assigned a trust tier based on their no-show history:
  • good: 0-1 no-shows (no commitment required)
  • watch: 2 no-shows (commitment required, 4-minute window)
  • restricted: 3+ no-shows (ordering temporarily blocked for 14 days)

Commitment workflow

  1. User with no-show history creates an order
  2. Order is created with requiresCommitment: true and status placed
  3. User must call this endpoint within 4 minutes of order creation
  4. If confirmed, order proceeds normally
  5. If not confirmed within 4 minutes, order is automatically cancelled

Automatic cancellation

Orders requiring commitment that are not confirmed within 4 minutes are automatically cancelled by the backend’s timeout sweep. This prevents users from placing orders they won’t pick up.
If you fail to confirm commitment within the deadline, the order will be automatically cancelled and counted as another no-show, potentially leading to ordering restrictions.
The commitment deadline is typically 4 minutes from order creation, but can be configured via the ORDER_COMMITMENT_TIMEOUT_MINUTES environment variable.

Build docs developers (and LLMs) love