---
id: GetOrder
name: Get order
version: 1.0.0
badges:
  - content: Order Lifecycle
    backgroundColor: blue
    textColor: blue
summary: Returns Order details, including the recorded item quantities and prices.
owners:
  - commerce-fulfillment-team
schemaPath: schema.json
operation:
  method: GET
  path: /api/v1/orders/{id}
  statusCodes: ["200", "404"]
sidebar:
  badge: "GET"
---

`GetOrder` queries [[service|order-api]] (`GET /ordering/api/v1/orders/{id}`) to retrieve a single order's header metadata, purchase-time unit prices, quantities, and book display names. Standard customers can retrieve only their own orders, while administrators (`admin` role) can retrieve any order; nonexistent and out-of-scope orders both return `404 Not Found`.

## Overview

| Property                           | Value                                                                                                                             |
| :--------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                | Ordering                                                                                                                          |
| **Owner Service**                  | [[service\|order-api]]                                                                                                            |
| **Protocol / Format**              | HTTP `GET`, `application/json` response                                                                                           |
| **Gateway Endpoint**               | `GET /ordering/api/v1/orders/{id}` (service path `/api/v1/orders/{id}`)                                                           |
| **Authentication & Authorization** | Microsoft Entra ID JWT — `customer` or `admin` role plus scopes `ordering_read`, `ordering_write`                                 |
| **Idempotency / Concurrency**      | Read-only and naturally idempotent                                                                                                |
| **Rate Limit / Caching**           | Global concurrency (`100`), per-IP fixed-window (`30 req/min`), and per-user token bucket (`30` limit, `20` per `10s`, queue `5`) |
| **Contract Version**               | `1.0.0` (`ApiVersions.V1`)                                                                                                        |

## Request & Response Contract

### Path Parameters

| Name | Type              | Required | Constraints | Description                                |
| :--- | :---------------- | :------- | :---------- | :----------------------------------------- |
| `id` | `string` (`uuid`) | Yes      | Valid UUID  | Unique identifier of the order to retrieve |

### Success Response (`200 OK`)

| Name               | Type                   | Required | Constraints                           | Description                                                                    |
| :----------------- | :--------------------- | :------- | :------------------------------------ | :----------------------------------------------------------------------------- |
| `id`               | `string` (`uuid`)      | Yes      | Valid UUID                            | Unique identifier of the order                                                 |
| `date`             | `string` (`date-time`) | Yes      | ISO 8601 UTC timestamp                | UTC timestamp when the order was placed                                        |
| `total`            | `number`               | Yes      | Decimal currency amount               | Total order amount computed from recorded item prices and quantities           |
| `status`           | `string`               | Yes      | Enum: `New`, `Cancelled`, `Completed` | Current lifecycle status of the order                                          |
| `items`            | `object[]`             | Yes      | Array                                 | Line items recorded at checkout                                                |
| `items[].id`       | `string` (`uuid`)      | Yes      | Valid UUID                            | Catalog book identifier                                                        |
| `items[].quantity` | `integer`              | Yes      | `> 0`                                 | Purchased unit quantity                                                        |
| `items[].price`    | `number`               | Yes      | Decimal currency amount               | Unit price locked at checkout (does not change if Catalog prices update later) |
| `items[].name`     | `string \| null`       | No       | Nullable                              | Book title enriched via [[query\|GetBooksGrpc]] (`null` if unavailable)        |

## Behavior & Side Effects

- **Catalog enrichment:** Reads recorded order items from PostgreSQL and enriches `items[].name` via [[query|GetBooksGrpc]] when items exist.
- **No state mutation:** Pure read query with no database writes or integration events.

## Error Responses

| Status / Code           | Condition                                                                                          | Client Recovery Action                                                              |
| :---------------------- | :------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------- |
| `401 Unauthorized`      | Missing, expired, or invalid Entra ID bearer token                                                 | Re-authenticate and retry                                                           |
| `403 Forbidden`         | Caller lacks Ordering API roles or scopes                                                          | Request a token with `customer` or `admin` role and Ordering scopes                 |
| `404 Not Found`         | Order does not exist, is soft-deleted, or belongs to another buyer outside the caller's role scope | Display a not-found state; do not assume whether the ID belongs to another customer |
| `429 Too Many Requests` | Rate limit quota exceeded (`Retry-After` header included)                                          | Wait for the `Retry-After` duration before retrying                                 |

## Related Documentation

- [[service|order-api]] — Service overview, persistence, and endpoints.
- [[entity|order]] — Order entity model.
- [[query|ListOrders]] — Paginated and filterable order summary listing.
- [[query|GetBooksGrpc]] — Catalog API gRPC query used to enrich line-item names.
- [[command|CancelOrder]] — Transition an order to `Cancelled`.
- [[command|CompleteOrder]] — Transition an order to `Completed`.

<NodeGraph />

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


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "OrderDetailDto",
	"description": "Order detail response documented by the Ordering API OpenAPI contract.",
	"type": "object",
	"required": ["id", "date", "total", "status", "items"],
	"properties": {
		"id": {
			"type": "string",
			"format": "uuid"
		},
		"date": {
			"type": "string",
			"format": "date-time"
		},
		"total": {
			"type": "number"
		},
		"status": {
			"type": "string",
			"enum": ["New", "Cancelled", "Completed"]
		},
		"items": {
			"type": "array",
			"items": {
				"type": "object",
				"required": ["id", "quantity", "price"],
				"properties": {
					"id": {
						"type": "string",
						"format": "uuid"
					},
					"quantity": {
						"type": "integer"
					},
					"price": {
						"type": "number"
					},
					"name": {
						"type": ["string", "null"]
					}
				}
			}
		}
	}
}
