---
title: "Cancel an order"
method: DELETE
path: "/orders/{orderId}"
tags: ["orders"]
---

# Cancel an order

`DELETE /orders/{orderId}`

Cancels an order if it has not yet been started (status must be 'pending').

The `userId` query parameter is required (e.g., `?userId=user123`).
If `userId` is missing or does not match the `userId` of the order, the request will be rejected.

## Path parameters

- `orderId` string, required

## Query parameters

- `userId` string, required

## Response `200`

Order cancelled successfully

- OrderResponse — Order object returned by the API (userId is omitted for privacy)
  - `id` string, required
  - `createdAt` string, date-time, required
  - `items` OrderItem[], required
    - `burgerId` string, required
    - `quantity` integer, required — Must be a positive integer (greater than 0). Orders with zero or negative quantity will be rejected with a 400 error.
    - `extraToppingIds` string[] — Optional list of extra topping IDs to add to the burger
  - `estimatedCompletionAt` string, date-time, required
  - `completedAt` string, date-time — ISO date string for when the order was completed (undefined until completed)
  - `nickname` string — Optional nickname for the order
  - `totalPrice` number, float, required
  - `status` 'pending' | 'in-preparation' | 'ready' | 'completed' | 'cancelled', required — - pending: Order has been created but not yet started - in-preparation: Order is being prepared - ready: Order is ready for pickup - completed: Order has been picked up - cancelled: Order has been cancelled

## Other responses

- `400` — Order ID or user ID is missing
- `403` — User is not authorized to cancel this order
- `404` — Order not found or cannot be cancelled (not in pending status)

## Changes

- **2025-10-09** `a7a88cd919bf` — 1 info
  - added the optional property `nickname` to the response with the `200` status
- **2025-07-01** `b938b8ad924a` — 1 warning
  - removed the optional property `nickname` from the response with the `200` status

[Change history](https://skmtc.dev/azure/apis/burger-api/changes/orders/:orderId/delete.md)

---

[API](https://skmtc.dev/azure/apis/burger-api.md) · [All operations](https://skmtc.dev/azure/apis/burger-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/azure/burger-api/revisions/9a320b046986/schema)
