> This page is for Gateway.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# Embedded Routing Stack

> Reference for the Embedded Routing API: manage per-end-customer Customers with their routing policies, vendor keys, API keys, budgets, controls, guardrails, and usage.

The Embedded Routing API lets a platform built on Gateway provision each end customer as a **Customer** with its own routing policies, BYOK vendor keys, budgets, and usage. Attach one to a model request with the `customer` field on [Create response](/merge-gateway/api-overview/responses/create) or any SDK-compatible surface. Walkthrough: [Embedded routing guide](/merge-gateway/embedded-routing-stack/overview).

## Base URL and authentication

```text
https://api-gateway.merge.dev
```

Authenticate with the `mg_` API key you send model requests with; the organization comes from the key.

```http
Authorization: Bearer mg_...
```

## Reference

| Endpoints under `/v1/customers`                                            | What it covers                                                                                                   |
| -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `/`, `/{customer_id}`                                                      | Create, list, update, and delete customers                                                                       |
| `/{customer_id}/routing-policies`, `/{customer_id}/default-routing-policy` | The customer's routing policies and its default                                                                  |
| `/{customer_id}/keys`                                                      | The customer's BYOK vendor keys. See [Customer keys](/merge-gateway/embedded-routing-stack/customer-keys).       |
| `/{customer_id}/api-keys`                                                  | [Customer API keys](/merge-gateway/embedded-routing-stack/customer-api-keys) bound to one customer, up to 5 each |
| `/{customer_id}/budgets`                                                   | The customer's [budgets](/merge-gateway/embedded-routing-stack/budgets)                                          |
| `/{customer_id}/controls`, `/{customer_id}/models`                         | The customer's ZDR, vendor, and region controls, and the models it can route to                                  |
| `/{customer_id}/pi-settings`, `/{customer_id}/dlp-settings`                | Per-customer prompt injection and DLP overrides                                                                  |
| `/usage`, `/{customer_id}/usage`                                           | Spend across customers or for one. See [Usage](/merge-gateway/embedded-routing-stack/usage).                     |

A customer API key can call only routes for its own customer, and changing budgets, controls, or anything but its own `name`, deleting itself, or minting keys returns `403`. Another customer's ID returns `404`. Errors use a [`detail` object](/merge-gateway/errors#management-and-platform-apis).

## Next steps

#### [Embedded routing overview](/merge-gateway/embedded-routing-stack/overview)

Scope requests and configuration to each customer

#### [Customer API keys](/merge-gateway/embedded-routing-stack/customer-api-keys)

Create keys scoped to one customer