---
id: GetBuyer
name: Get buyer
version: 1.0.0
badges:
  - content: Customer Management
    backgroundColor: orange
    textColor: orange
summary: Returns the Buyer profile selected by identifier, subject to the caller's authorization.
owners:
  - commerce-fulfillment-team
schemaPath: schema.json
operation:
  method: GET
  path: /api/v1/buyers/me
  statusCodes: ["200", "404"]
sidebar:
  badge: "GET"
---

`GetBuyer` queries [[service|order-api]] (`GET /ordering/api/v1/buyers/me`) to retrieve a buyer's profile (`id`, `name`, and `address`). Callers with the `admin` role retrieve the profile specified by the `Id` query parameter; all other authenticated callers are resolved to the buyer linked to their Microsoft Entra ID `NameIdentifier` claim.

## Overview

| Property                           | Value                                                                                                                             |
| :--------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------- |
| **Bounded Context**                | Ordering                                                                                                                          |
| **Owner Service**                  | [[service\|order-api]]                                                                                                            |
| **Protocol / Format**              | HTTP `GET`, `application/json` response                                                                                           |
| **Gateway Endpoint**               | `GET /ordering/api/v1/buyers/me` (service path `/api/v1/buyers/me`)                                                               |
| **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

### Query Parameters

| Name | Type              | Required | Constraints | Description                                                                                                                   |
| :--- | :---------------- | :------- | :---------- | :---------------------------------------------------------------------------------------------------------------------------- |
| `Id` | `string` (`uuid`) | Yes      | Valid UUID  | Buyer identifier requested by `admin` callers; ignored for non-admin callers whose buyer ID is resolved from `NameIdentifier` |

:::note
Because `Id` binds as a non-nullable UUID, non-admin clients must still supply a valid UUID query parameter even though the service resolves their own authenticated buyer ID.
:::

### Success Response (`200 OK`)

| Name      | Type              | Required | Constraints | Description                                    |
| :-------- | :---------------- | :------- | :---------- | :--------------------------------------------- |
| `id`      | `string` (`uuid`) | Yes      | Valid UUID  | Unique identifier of the buyer profile         |
| `name`    | `string \| null`  | Yes      | Nullable    | Buyer display name (`null` when unset)         |
| `address` | `string \| null`  | Yes      | Nullable    | Formatted shipping address (`null` when unset) |

## Behavior & Side Effects

- **Role-scoped resolution:** Administrators query by the supplied `Id` parameter; standard customers always resolve their own profile from their token's `NameIdentifier` claim.
- **No state mutation:** Pure read query with no database writes or integration events.

## Error Responses

| Status / Code           | Condition                                                 | Client Recovery Action                                                  |
| :---------------------- | :-------------------------------------------------------- | :---------------------------------------------------------------------- |
| `400 Bad Request`       | Missing or malformed `Id` UUID query parameter            | Supply a valid UUID in the `Id` query parameter; do not retry unchanged |
| `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`         | No buyer profile exists for the resolved buyer ID         | Prompt the user to create a buyer profile via [[command\|CreateBuyer]]  |
| `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|buyer]] — Buyer entity model.
- [[query|ListBuyers]] — Admin-only paginated listing of all buyer profiles.
- [[command|CreateBuyer]] — Create a new buyer profile.
- [[command|UpdateAddress]] — Update a buyer's shipping address.

<NodeGraph />

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


 ## Raw Schema:schema.json

{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"title": "BuyerDto",
	"description": "Buyer profile response documented by the Ordering API OpenAPI contract.",
	"type": "object",
	"required": ["id", "name", "address"],
	"properties": {
		"id": {
			"type": "string",
			"format": "uuid"
		},
		"name": {
			"type": ["string", "null"]
		},
		"address": {
			"type": ["string", "null"]
		}
	}
}
