---
id: DeleteOrder
name: Delete order
version: 1.0.0
badges:
  - content: Order Lifecycle
    backgroundColor: blue
    textColor: blue
summary: Soft-deletes an Order by its identifier without changing its business status.
owners:
  - commerce-fulfillment-team
schemaPath: schema.json
operation:
  method: DELETE
  path: /api/v1/orders/{id}
  statusCodes: ["204", "404"]
sidebar:
  badge: "DELETE"
---

`DeleteOrder` soft-deletes an [[entity|order]] in [[service|order-api]] (`DELETE /ordering/api/v1/orders/{id}`) while leaving its business status unchanged. Access is restricted to callers holding the Microsoft Entra ID `admin` role.

## Overview

| Property                           | Value                                                                                                                             |
| :--------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                | Ordering                                                                                                                          |
| **Owner Service**                  | [[service\|order-api]]                                                                                                            |
| **Protocol / Format**              | HTTP `DELETE`, path parameter only, empty response (`204 No Content`)                                                             |
| **Gateway Endpoint**               | `DELETE /ordering/api/v1/orders/{id}` (service path `/api/v1/orders/{id}`)                                                        |
| **Authentication & Authorization** | Microsoft Entra ID JWT — `admin` policy (role `admin` plus scopes `ordering_read`, `ordering_write`)                              |
| **Idempotency / Concurrency**      | Not idempotent across retries; repeat calls return `404 Not Found`; no `x-request-id` header is required                          |
| **Rate Limit / Caching**           | Global concurrency (`100`), per-IP fixed-window (`30 req/min`), and per-user token bucket (`30` burst, `20` per `10s`, queue `5`) |
| **Contract Version**               | `1.0.0` (`ApiVersions.V1`)                                                                                                        |

## Request & Response Contract

### Path Parameters

Accepts no request body and requires no `x-request-id` header.

| Name | Type              | Required | Constraints                | Description                                   |
| :--- | :---------------- | :------- | :------------------------- | :-------------------------------------------- |
| `id` | `string` (`uuid`) | Yes      | Path parameter; valid UUID | Unique identifier of the order to soft-delete |

### Success Response (`204 No Content`)

Empty response body confirms the order was soft-deleted.

## Behavior & Side Effects

- **Soft-delete without status transition:** Sets `isDeleted = true` without changing the order's `status` (`New`, `Completed`, or `Cancelled`).
- **Global query filter:** Soft-deleted orders are hidden from standard read queries and subsequent `DELETE` calls (`404 Not Found`).
- **No events emitted:** Raises no domain events and publishes no Kafka integration events. To cancel an active order and notify downstream workflows, use [[command|CancelOrder]].

## Error Responses

| Status / Code               | Condition                                                                | Client Recovery Action                                                              |
| :-------------------------- | :----------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
| `400 Bad Request`           | Path parameter `{id}` is not a valid UUID                                | Supply a valid UUID; do not retry unchanged                                         |
| `401 Unauthorized`          | Missing, expired, or invalid Entra ID bearer token                       | Acquire a fresh Entra ID access token and retry                                     |
| `403 Forbidden`             | Caller lacks the `admin` role or `ordering_read`/`ordering_write` scopes | Authenticate with an `admin` token that includes the required scopes                |
| `404 Not Found`             | Order does not exist or was already soft-deleted                         | Verify the order identifier; treat as already soft-deleted if retrying a prior call |
| `429 Too Many Requests`     | Rate limit quota exceeded (`Retry-After` header included)                | Wait for the `Retry-After` interval before retrying                                 |
| `500 Internal Server Error` | Unhandled database failure                                               | Retry with backoff and inspect service logs                                         |

## Related Documentation

- [[service|order-api]] — Service architecture, persistence, and endpoints.
- [[entity|order]] — Order aggregate schema and soft-delete behavior.
- [[command|CancelOrder]] — Transition a `New` order to `Cancelled` and notify downstream workflows.
- [[command|DeleteBasketFailedCommand]] — Automated compensation command that also soft-deletes an order.

<NodeGraph />

<SchemaViewer file="schema.json" title="Delete order schema" maxHeight="500" search="true" />


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "DeleteOrderRequest",
	"description": "Path identifier for the Order to soft-delete. The operation has no request body.",
	"type": "string"
}
