# MCP server

Connect an AI agent to the UpDash Mail API through its remote Model Context Protocol server, and use its forty-two tools safely (and three more that only its proof view calls).

## Endpoint and auth

| Setting | Value |
| --- | --- |
| URL | `$API/api/mcp`: `https://api.updash.com/api/mcp`. `$API/mcp` is a second address of the same server. |
| Transport | Streamable HTTP (served by Vercel's `mcp-handler`) |
| Auth | OAuth 2.1 (the client signs in once through a consent page), or the header `Authorization: Bearer xm_test_...` / `Bearer xm_live_...`. One of them on every request. |
| Server name | `xcel-mail-api`, at the API's version (`version` on `GET /v1/health`) |
| Tool list, without a key | [`$API/mcp-tools.json`](../mcp-tools.json) |

There are two ways to authenticate, and both end in the same place: the partner and the mode of one API key.

| Way | For | What the client holds |
| --- | --- | --- |
| [OAuth](#connect-by-oauth) | Clients that add a server from its URL alone: Claude's custom connectors, connector directories, most desktop agents | An access token (1 hour) and a refresh token (30 days), bound to this server |
| [API key header](#connect-with-an-api-key-header) | Clients that let you set headers: Claude Code with `--header`, scripts, partner backends | The raw partner API key |

A request without valid credentials gets HTTP 401 before any tool runs, with the standard error body (`"code": "unauthorized"`) and this challenge, which tells an OAuth client where to start:

```text
WWW-Authenticate: Bearer realm="xcel-mail-api", resource_metadata="$API/.well-known/oauth-protected-resource", scope="mail:test mail:live"
```

When a token or key was sent but is not valid, the challenge also carries `error="invalid_token"`. The key decides the partner and the mode either way: a sandbox key (or a token made from one) works only on sandbox campaigns, a live one only on live ones.

### A key limited to some dealers

A key can be limited to some of your dealers, so an agent working for one dealer reaches only that dealer ([Keys for one dealer](partners.md#keys-for-one-dealer)). An OAuth token made from such a key has the same limit, and a refresh keeps it. The tool list is the same for every key.

| Tools | With a limited key |
| --- | --- |
| `list_dealers`, `list_campaigns`, `list_standing_orders` | Only its dealers, their campaigns and their standing orders. |
| `get_dealer_brand`, `get_dealer_profile`, `update_dealer_profile`, `upload_dealer_logo`, `upload_dealer_asset`, `list_dealer_assets`, `delete_dealer_asset`, `list_dealer_offers`, `save_dealer_offer`, `get_dealer_inbound_email`, `update_dealer_inbound_email`, `create_campaign`, `save_standing_order` and every tool that takes a `campaign_id` or a `standing_order_id` | Its dealers only. Anything else answers `not_found`, as another partner's dealer does. `update_dealer_profile` cannot change `links.website`: `dealer_scope_forbidden`, naming the field. |
| `preview_template` | Xcel's templates only. With `dealer_id`, its dealers only. Without, the sample dealer, counted against the first of its dealers. |
| `upsert_dealer` | Updates its own dealers by `external_id`. Any other `external_id` would create a dealer, so it answers `dealer_scope_forbidden`, whether or not that id exists. Its `profile` cannot change `links.website`: `dealer_scope_forbidden`, naming the field. An `approver` goes to Xcel's review after they confirm, whatever the address. |
| `save_template`, `retire_template`, `upload_partner_asset`, `delete_partner_asset` | Refused with `dealer_scope_forbidden`. |
| `list_partner_assets` | Open: the asset library is every dealer's. `can_change` is false. |
| `list_make_logos` | Open: the make logos are every dealer's. With `dealer_id`, its dealers only. |
| `list_mail_products`, `list_templates`, `get_template` | Open for Xcel's templates. Your saved templates need a key for every dealer: `list_templates` leaves them out and `get_template` answers `unknown_template`, as does `generate_creative`. |
| `preview_artwork` | Open: it names no dealer. Its `artwork_id` works for this key and list of dealers alone. |

Webhooks and `GET /v1/account` have no tools. An agent cannot widen its own limit.

## Connect by OAuth

Give the client the URL and nothing else. It discovers the rest:

1. It calls `/api/mcp`, gets the 401 above, and reads `$API/.well-known/oauth-protected-resource` (RFC 9728), which names this server as its own authorization server.
2. It reads `$API/.well-known/oauth-authorization-server` (RFC 8414) and identifies itself: with the https URL of its own [Client ID Metadata Document](#for-client-authors-a-client-id-metadata-document) as its `client_id`, or by registering at `POST /oauth/register` (dynamic client registration, RFC 7591).
3. It opens your browser on `/oauth/authorize`. The consent page shows the app's name (unverified; for a metadata document, also the host that publishes it and its logo), the host it will send you back to and the access it asks for.
4. You sign in with your UpDash console account (your password, or a sign-in link by email) and choose **Approve**: there is no key to copy. Choose **Sandbox** or **Live**; live is offered once Xcel has turned on live ordering for your company, and the console's Viewer role cannot connect an app. The app gets its own key, named for the app and you (`Claude · connected by you@dealer.example`), which reaches the dealers you reach in the console, or fewer if you name them in **Limit to these dealers**. Connecting the same app again reuses that key, and revoking it in the console disconnects the app. The app never sees the key.
   - **New to UpDash?** **Create a free sandbox** on the same page: name, company and work email. The email that follows sets your password; sign in and approve.
   - **Use a partner API key instead** still works: paste it and approve. The key decides the access: an `xm_test_` key grants `mail:test`, an `xm_live_` key grants `mail:live`, and a key limited to some dealers grants those dealers only, or fewer if you name them.
5. The client exchanges the one-time code for tokens at `POST /oauth/token` and uses the access token as its Bearer token. It refreshes on its own.

| Topic | Behavior |
| --- | --- |
| Scopes | `mail:test` (sandbox) and `mail:live` (live). A token has exactly one, the mode of the key it was made with. |
| Sandbox key, app asked for `mail:live` | You get `mail:test`; the token response says `"scope": "mail:test"`. |
| Live | Granted only when the app asked for `mail:live` and Xcel has enabled live ordering for your company. Otherwise the consent page explains and offers the sandbox. If Xcel turns live ordering off later, live tokens stop refreshing. |
| Dealers | A token reaches what its key reaches, or the dealers you named on the consent page if fewer. A refresh keeps them, and consent can never widen them: a dealer the key does not reach is not accepted. |
| Lifetimes | Access token 1 hour; refresh token 30 days, replaced on every refresh. An app that has not refreshed for 30 days must connect again. |
| Revoking | Revoking the API key, or the connection's own key that a console sign-in made, revokes every token made from it within the same request. An app can revoke its own tokens at `POST /oauth/revoke`. |
| Redirect URIs | `https://`, or `http://` on `localhost`, `127.0.0.1` or `[::1]` for apps on your computer. Matched exactly, port included. |
| Approval | Unchanged. A token can do what a key can do over MCP, which never includes approving spend. |

The server issues tokens only for its own MCP URL (`$API/api/mcp`, RFC 8707 resource indicators) and accepts only those. `$API/mcp` is the same resource under a second name: a client connected there gets a 401 that points at `$API/.well-known/oauth-protected-resource/mcp`, which names `$API/mcp` as the resource, and its token works at both addresses. See [Security](security.md#oauth-for-the-mcp-endpoint) for the protections.

### For client authors: a Client ID Metadata Document

Instead of registering, a client can name itself with the https URL of a JSON document it hosts (draft-ietf-oauth-client-id-metadata-document, as the MCP authorization spec describes). The authorization server metadata says `"client_id_metadata_document_supported": true`. Send that URL as `client_id` in the authorization and token requests; Xcel fetches the document the first time it sees the URL and shows the document's host on the consent page as the publisher.

```json
{
  "client_id": "https://agent.example.com/oauth/client.json",
  "client_name": "Agent Desktop",
  "client_uri": "https://agent.example.com",
  "logo_uri": "https://agent.example.com/logo.png",
  "redirect_uris": ["http://127.0.0.1:41000/callback"],
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"],
  "token_endpoint_auth_method": "none"
}
```

| Rule | Value |
| --- | --- |
| `client_id` URL | `https://`, with a path, no fragment, credentials or dot segments, written in normal form (lower-case host, no default port). The document's `client_id` must equal it exactly. |
| Serving | HTTP 200, `application/json`, at most 5 KB, within 5 seconds, from a public address. Redirects are not followed. |
| Required fields | `client_id`, `client_name`, `redirect_uris` (1 to 10; https or loopback, matched exactly). |
| Optional fields | `grant_types` (default both; `authorization_code` required), `response_types` (`["code"]`), `scope`, `client_uri`, `logo_uri`. |
| Not allowed | `client_secret`, `client_secret_expires_at`, and any `token_endpoint_auth_method` but `none`: clients are public and use PKCE. |
| Logo | Fetched once with the document: PNG, JPEG, GIF or WebP, at most 100 KB. A logo that cannot be used is dropped, never fatal. |
| Caching | For the document's `Cache-Control` `max-age`, kept between 5 minutes and 24 hours (1 hour without one). A failed fetch is never cached. |

If the document cannot be fetched or does not validate, the consent page says why and nothing is sent to the redirect URI. Dynamic registration keeps working for clients that use it.

## Connect from Claude

**Claude (claude.ai and the Claude desktop app).** Add a custom connector with the server URL, `https://api.updash.com/api/mcp` (Settings, then Connectors, then add a custom connector). Claude opens the consent page; sign in there with your console account and approve. Claude reaches the server from the internet, so the URL must be public and `https://`; a `localhost` server does not work here.

**Claude Code, by OAuth.** Add the server with its URL only, then run `/mcp` in a session and choose to authenticate; Claude Code opens the consent page in your browser:

```bash
claude mcp add --transport http xcel-mail https://api.updash.com/api/mcp
```

**Claude Code, with the key header.** See [Connect with an API key header](#connect-with-an-api-key-header).

## Connect with an API key header

The bearer token is your partner API key, checked exactly as the REST API checks it. Keep keys out of files you commit; the examples read the key from an environment variable.

Claude Code:

```bash
export XCEL_MAIL_KEY=xm_test_REPLACE_WITH_YOUR_SANDBOX_KEY
claude mcp add --transport http xcel-mail https://api.updash.com/api/mcp \
  --header "Authorization: Bearer $XCEL_MAIL_KEY"
```

Check the connection with `claude mcp list` or `/mcp` inside a session.

To share the server with a project without sharing the key, put this in the project's `.mcp.json`; Claude Code expands `${XCEL_MAIL_KEY}` from each developer's environment:

```json
{
  "mcpServers": {
    "xcel-mail": {
      "type": "http",
      "url": "https://api.updash.com/api/mcp",
      "headers": { "Authorization": "Bearer ${XCEL_MAIL_KEY}" }
    }
  }
}
```

A stdio-only client can use the `mcp-remote` bridge, which runs locally and adds the header. For example, in Claude Desktop's `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "xcel-mail": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://api.updash.com/api/mcp", "--header", "Authorization:${XCEL_AUTH}"],
      "env": { "XCEL_AUTH": "Bearer xm_test_REPLACE_WITH_YOUR_SANDBOX_KEY" }
    }
  }
}
```

The header value goes through an environment variable because some clients split arguments on spaces. Restart Claude Desktop after editing the file.

## Connect from other MCP clients

A client that supports MCP authorization (OAuth 2.1 with PKCE and dynamic client registration) needs only the URL, as in [Connect by OAuth](#connect-by-oauth). A client that can only send headers uses the key:

```json
{ "url": "https://api.updash.com/api/mcp", "headers": { "Authorization": "Bearer xm_test_REPLACE_WITH_YOUR_SANDBOX_KEY" } }
```

## Recommended flow

The server sends this order to the client as its instructions, starting from the template, not the product list. `prepare_order` does the middle of the order in one call, so a chat app asks the person to confirm once:

```mermaid
flowchart LR
    A[list_templates<br/>the designs as pictures] --> B[prepare_order<br/>order, creative, list]
    B --> C[the upload view<br/>or source_url]
    C --> D[proof and quote]
    D --> E[show_proof<br/>the proof in the chat]
    E --> F[request_approval]
    F --> G[the approver decides<br/>on the review page<br/>or in the chat]
    G --> H[submit_campaign]
    H --> I[get_campaign_status<br/>get_campaign_results]
```

`prepare_order` runs what `create_campaign`, `generate_creative`, `upload_audience`, `render_proof` and `get_quote` do one by one. Those step tools stay for a change to one part, and for what `prepare_order` leaves out: an envelope, a mail class, vehicle history, a template version, `external_ref` and credit or lease terms.

In the sandbox, call `advance_test_campaign` after `submit_campaign` until the order is `completed`, then `get_campaign_results`.

`list_dealers` gives the `dealer_id`, `get_template` gives one template's slots in full, and `list_campaigns` finds an earlier order by dealer, status or your `external_ref`. A partner with its own design calls `save_template` once, then uses its `p_` code wherever a template code goes; `list_templates` with `owner: "partner"` finds those templates in a later conversation. The instructions also state the rules an agent must follow, which [Safety rules for agents](#safety-rules-for-agents) gives in full:

- A person at the dealer approves every live order, on the review page Xcel emails to the dealer's registered approver or in the proof view `show_proof` opens ([The proof in the chat](#the-proof-in-the-chat)). The agent cannot approve; an order is approved only when `get_campaign_status` says so.
- `max_spend_cents` is the most the user said to spend: never the agent's own estimate and never higher. If the user gave no figure, the agent asks before `request_approval`.
- No customer rows in a tool call or the chat. Give `upload_audience` a `source_url` (a link to the CSV in the user's system), or use its signed upload: the person chooses the file on `upload_page_url`, or your host PUTs it. Name the audience's record-id column `external_id`, or map the id column to it with `upload_audience`'s `column_map`. Phone and email columns are optional: kept only to match responses and sales, never printed or returned.
- Leave the store slots (phone, hours, web address, QR link, signer) out of copy unless the user gives a value: they print from the dealer's profile. Ask the person for dealer facts (slots marked `dealer_fact`) and disclosure slots; never invent them.
- USPS scans are not delivery, a matched sale is evidence and not proof the mail caused it, and prices come from your price list (the console's [Pricing](/console/pricing) page), set by your volume tier.
- Show the person `preview_url` links, not HTML or base64.
- Errors are `{"error": {code, message, fix, field}}`: follow `fix`.

Most results that change state include `next_step`; follow it.

A mailing that repeats, such as a CDP audience refreshed every week, is a standing order. `save_standing_order` saves the dealer, product, template creative and copy, the most one run may cost (`max_spend_cents`, a budget a person set) and the approver once. Each run then builds an ordinary order through `request_approval` and waits on the dealer's approver, as any order does: `start_standing_order_run` with a `source_url` starts one now, a `cadence` with a `source_url` starts one on schedule, and an emailed report starts one when its subject holds the standing order's `inbound_subject` (`update_dealer_inbound_email` turns the dealer's address on). Follow the runs with `get_standing_order`, and each run's order with `get_campaign_status`. An approved run's order submits itself unless `submit_on_approval` is `false`. See [Standing orders](standing-orders.md).

To set up or update a dealer before (or instead of) ordering, use the dealer tools: `list_dealers`, `get_dealer_profile`, `upsert_dealer`, `update_dealer_profile`, `upload_dealer_logo`, `upload_dealer_asset`, `list_dealer_assets`, `delete_dealer_asset`, `list_dealer_offers` and `save_dealer_offer`; for a photo every dealer can print, `upload_partner_asset`, `list_partner_assets` and `delete_partner_asset` keep your asset library. Save an offer only as the dealer named it, with its real figures and dates; `generate_creative` prints it with `offer_id`. `upsert_dealer` with `approver` names the dealer's approver, who confirms by email before live approval works. A sandbox key (or a `mail:test` token) creates test dealers, which exist in test mode only; its writes to dealers shared with the live key only validate: the result says `"validated_only": true` and nothing is saved. After a profile change, call `generate_creative` again for any campaign that should print it. `submit_campaign` has no `next_step`: after the submit, follow the order with `get_campaign_status`, whose `next_step` is always present (for a sandbox order it names `advance_test_campaign`).

To choose and try a template before you order, call `list_templates` (filter with `product_code`, `use_case`, `query`, `owner` or `prescreened`), read the one you pick with `get_template`, then call `preview_template` with its `template_code` and the copy you plan to send. It runs the same checks as `generate_creative` and returns the preflight issues with their fixes and a `preview_url` to send the person; leave out `dealer_id` to print the sample dealer Demo Motors. It saves nothing, but it counts against the [render limits](api-reference.md#rate-limits) it shares with `render_proof`: per dealer, with a ceiling for your partner. Opening the link counts nothing.

## Views in the chat

In a chat app that shows MCP Apps views (ChatGPT and Claude on the web and desktop, among others), three tools open a view in the conversation. Each view shows the person what they need, and the model gets words and counts, never a page or a row:

| View | Opened by | What the person does |
| --- | --- | --- |
| The template picker (`ui://xcel-mail/template-picker.html`) | `list_templates` | Sees each design as its picture, front and back (inside and envelope for a card), six at a time with **Show more**, and **See the sample** opens its `preview_url`. **Use this design** sends "Use the *name* design (*code*)." into the chat as their own message. |
| The upload view (`ui://xcel-mail/upload-view.html`) | `upload_audience` and `prepare_order` when they start an upload | Drops the CSV or Excel file (4 MB at most). It goes from their browser to the upload page's address, never through the chat; the view completes the upload with `upload_audience` and shows the counts. Opened by `prepare_order`, it goes on to the proof and the quote, and **Show me the proof** asks for the proof view. |
| The proof view (`ui://xcel-mail/proof-view.html`) | `show_proof` | Sees the proof and, as the dealer's approver, decides ([The proof in the chat](#the-proof-in-the-chat)). |

A view posts into the chat only when the person clicks. In an app without views, each tool answers as before: `list_templates` lists the templates with their `preview_url`, and the upload starts with an `upload_page_url` to give the person.

## Ready-made prompts

The server lists six prompts (MCP `prompts/list`), which Claude shows in its menu and other apps that support prompts show too: **Try a sandbox order**, **Order postcards for a dealer** (dealer, goal), **Show me the proof** (order), **Are we ready to go live?**, **How did my mailing do?** (order) and **Mail a list every month** (dealer). Every argument is optional: the model asks for what is missing. A prompt is only the person's request in plain words, so the instructions and every tool's rules still apply.

## The proof in the chat

In a chat app that shows MCP Apps views (ChatGPT and Claude on the web and desktop, among others), `show_proof` opens the order's proof inside the conversation: every page as it prints, for the same proof records the review page shows (three samples and the worst case), front and back, with a button for the review PDF. Once `request_approval` has asked, the dealer's approver can approve or reject right there:

- **Live:** only the approver decides. **Email me a code** sends a 6-digit code to their registered address; they enter it in the view, tick that they reviewed the proof, the quantity and the total, and approve, or reject with a note. A code works for 10 to 20 minutes and only for that approval; 5 codes and 10 tries an approval an hour. Every check of the review page applies, and `approval.decided` carries `decided_via: "chat_proof_view"`.
- **Sandbox:** the developer decides in the view with no code, as with `review_url`.

The agent gets the order's status from `show_proof` and never a page, a customer row or a code: the view loads the pictures straight from the API into the person's browser, through links that work for 15 minutes, and asks for them with three tools only a view may call (`get_proof_view`, `send_approval_code`, `decide_approval`, marked `visibility: ["app"]`, which a host leaves out of the model's tool list). Those tools also refuse a call without the view's own key, which travels in a result's `_meta`, where a host hands it to the view and not to the model, so an agent that reaches them anyway still cannot decide (`proof_view_only`). After a decision the view tells the agent only the outcome, so it can `submit_campaign`. In an app without views, `show_proof` still answers the status, and the approver decides from Xcel's email (sandbox: `review_url`).

## Tools

[`/mcp-tools.json`](../mcp-tools.json) is the tool list `tools/list` returns, and it needs no key: `{ "tools": [{name, title, description, inputSchema, annotations}] }`. Read it to see every tool and its input schema before you connect.

Every tool wraps the same service function as a REST endpoint, uses the same input schema with the same limits, and returns the same JSON, except that `list_mail_products` and `list_templates` answer a compact list unless you ask for `detail: "full"`, and `prepare_order` and the views' tools have no REST route. Every tool has a title and states `readOnlyHint`, `destructiveHint` and `openWorldHint`: `destructiveHint` is true for a write that can overwrite or delete, or that sends or commits what cannot be called back (an approval request, an approver's decision, an order), and `openWorldHint` is true where a tool fetches a link you give, emails a person or mails the order. A tool argument that fails its schema is refused with the standard error body: `invalid_request`, `field` set to the argument, and a `fix` ([Results and errors](#results-and-errors)). An argument a tool does not define is refused the same way, at any depth: `field` names it and `fix` names the argument meant (for example `send_date` to `requested_mail_date`, `audience_id` on `upload_audience` to `uploaded_audience_id`, a copy slot sent at the top level to inside `copy`). A retried `create_campaign` with the same `idempotency_key` and an extra argument is refused, not replayed.

| Tool | REST equivalent | Read-only | Inputs |
| --- | --- | --- | --- |
| `list_mail_products` | `GET /v1/products?detail=compact` | yes | `detail`? |
| `list_templates` | `GET /v1/templates` | yes | `product_code`?, `use_case`?, `query`?, `owner`?, `prescreened`?, `source_audience`?, `detail`? |
| `get_template` | `GET /v1/templates/{code}` (without the regions, the response boxes or the HTML) | yes | `template_code`, `template_version`? |
| `save_template` | `POST /v1/templates` | no | `code`, `product_code`, `name`, `description`, `html`, `slots`, `use_cases`?, `idempotency_key`? |
| `retire_template` | `POST /v1/templates/{code}/retire` | no (destructive, idempotent) | `template_code` |
| `preview_template` | `POST /v1/templates/{code}/preview` with `format: "json"` | yes (it saves nothing; it counts against the render limits) | `template_code`, `template_version`?, `copy`?, `dealer_id`?, `recipient`? (accepted, not listed), `document`?, `envelope`? |
| `preview_artwork` | `POST /v1/artwork/preview` with `format: "json"` (URL forms, Demo Motors) | no (it keeps the art 7 days as `artwork_id`; it counts against the render limits) | `product_code`, `artwork` (`url`, or `front.url` and `back.url`) |
| `get_dealer_brand` | `GET /v1/dealers/{id}/brand` | yes | `dealer_id` |
| `get_account` | `GET /v1/account` | yes | none |
| `list_dealers` | `GET /v1/dealers` | yes | `limit`?, `after`? |
| `get_dealer_profile` | `GET /v1/dealers/{id}/profile` | yes | `dealer_id`, `version`? |
| `upsert_dealer` | `POST /v1/dealers` (create), else `PATCH /v1/dealers/{id}/profile`; with `approver`, `POST /v1/dealers/{id}/approvers` | no | `external_id`, `profile` (a new dealer only; leave it out to only name an approver), `expected_version`?, `approver`? |
| `update_dealer_profile` | `PATCH /v1/dealers/{id}/profile` with `If-Match` | no | `dealer_id`, `expected_version`, `changes` |
| `upload_dealer_logo` | `POST /v1/dealers/{id}/logo` | no | `dealer_id`, `variant`?, `content_base64`? or `url`?, `expected_version`? |
| `upload_dealer_asset` | `POST /v1/dealers/{id}/assets` | no | `dealer_id`, `kind`, `label`?, `name`?, `title`?, `department`?, `content_base64`? or `url`?, `expected_version`? |
| `list_dealer_assets` | `GET /v1/dealers/{id}/assets` | yes | `dealer_id`, `kind`? |
| `delete_dealer_asset` | `DELETE /v1/dealers/{id}/assets/{asset_id}` | no (destructive) | `dealer_id`, `asset_id`, `expected_version`? |
| `upload_partner_asset` | `POST /v1/assets` | no | `name`, `label`?, `description`?, `content_base64`? or `url`? |
| `list_partner_assets` | `GET /v1/assets` | yes | none |
| `list_make_logos` | `GET /v1/makes` (compact), and with `make` that make's entry | yes | `dealer_id`?, `make`? |
| `delete_partner_asset` | `DELETE /v1/assets/{asset_id}` | no (destructive) | `asset_id` |
| `list_dealer_offers` | `GET /v1/dealers/{id}/offers` | yes | `dealer_id` |
| `save_dealer_offer` | `POST /v1/dealers/{id}/offers` (create), `PATCH .../offers/{offer_id}` (with `offer_id`), `DELETE .../offers/{offer_id}` (with `delete`) | no (with `delete`, destructive) | `dealer_id`, `offer_id`?, `delete`?, `name`?, `department`?, `offer`?, `detail`?, `disclosure`?, `starts_on`?, `ends_on`?, `expected_version`? |
| `prepare_order` | none: `create_campaign`, `generate_creative`, `upload_audience`, `render_proof` and `get_quote` in one call | no | `campaign_id`? or `dealer_id` and `template_code`, `name`?, `requested_mail_date`?, `copy`?, `brief`?, `offer_id`?, `source_url`?, `column_map`?, `idempotency_key`? |
| `create_campaign` | `POST /v1/campaigns` | no | `dealer_id`, `product_code`, `name`, `requested_mail_date`?, `envelope`?, `external_ref`?, `metadata`?, `idempotency_key`? |
| `list_campaigns` | `GET /v1/campaigns` | yes | `dealer_id`?, `status`?, `external_ref`?, `created_after`?, `created_before`?, `limit`?, `starting_after`? |
| `upload_audience` | `POST /v1/campaigns/{id}/audience/import` with `source_url`; or `POST /v1/campaigns/{id}/audience`, then `.../audience/complete` | no | `campaign_id`, `source_url`?, `uploaded_audience_id`?, `include_suppression_list`?, `column_map`?, `vehicle_source`? |
| `generate_creative` | `POST /v1/campaigns/{id}/creative` | no | `campaign_id`, `template_code`?, `template_version`?, `html`?, `artwork`?, `copy`?, `offer_id`?, `brief`? |
| `render_proof` | `POST /v1/campaigns/{id}/proof` | no | `campaign_id` |
| `validate_campaign` | `GET /v1/campaigns/{id}/validate` | yes | `campaign_id` |
| `get_quote` | `POST /v1/campaigns/{id}/quote` | no | `campaign_id`, `mail_class`? |
| `request_approval` | `POST /v1/campaigns/{id}/approval` | no | `campaign_id`, `quote_id`, `max_spend_cents`, `approver_email`? |
| `show_proof` | none: it opens the [proof view](#the-proof-in-the-chat) (`ui://xcel-mail/proof-view.html`) | yes | `campaign_id` |
| `get_proof_view` | none; the proof view only | yes | `campaign_id` |
| `send_approval_code` | none; the proof view only | no | `campaign_id`, `approval_id` |
| `decide_approval` | the review page's decision; the proof view only | no | `campaign_id`, `approval_id`, `decision`, `code`?, `confirm`?, `note`?, `prescreen_confirm`?, `prescreen_list_date`? |
| `submit_campaign` | `POST /v1/campaigns/{id}/submit` | no | `campaign_id`, `approval_id`, `idempotency_key` |
| `get_campaign_status` | `GET /v1/campaigns/{id}` | yes | `campaign_id` |
| `get_campaign_results` | `GET /v1/campaigns/{id}/results` | yes | `campaign_id`, `leads_after`?, `leads_limit`?, `external_id`?, `updated_after`? |
| `save_standing_order` | `POST /v1/standing-orders`; with `standing_order_id`, `PATCH /v1/standing-orders/{id}` | no | `standing_order_id`?, `dealer_id`, `name`, `product_code`, `mail_class`?, `creative`, `max_spend_cents`, `status`?, `approver_email`?, `skip_mailed_within_days`?, `submit_on_approval`?, `source_url`?, `cadence`?, `column_map`?, `vehicle_source`?, `external_id`?, `inbound_subject`?, `idempotency_key`? |
| `list_standing_orders` | `GET /v1/standing-orders` | yes | `dealer_id`?, `status`?, `external_id`?, `limit`?, `starting_after`? |
| `get_standing_order` | `GET /v1/standing-orders/{id}`, with its runs a page of ten at a time (`GET /v1/standing-orders/{id}/runs`) | yes | `standing_order_id`, `runs_after`? |
| `end_standing_order` | `DELETE /v1/standing-orders/{id}` | no (destructive, idempotent) | `standing_order_id` |
| `start_standing_order_run` | `POST /v1/standing-orders/{id}/runs` with JSON | no | `standing_order_id`, `source_url`?, `column_map`?, `vehicle_source`? |
| `get_dealer_inbound_email` | `GET /v1/dealers/{id}/inbound-email` | yes | `dealer_id` |
| `update_dealer_inbound_email` | `PUT /v1/dealers/{id}/inbound-email` | no (destructive: `rotate` stops the old address) | `dealer_id`, `enabled`?, `senders`?, `rotate`?, `idempotency_key`? |
| `advance_test_campaign` | `POST /v1/test/campaigns/{id}/advance` | no (sandbox keys only) | `campaign_id`, `to`? |

`?` marks an optional input.

`tools/list` shows each tool's input schema trimmed for an agent: descriptions written for the model, and no keywords that repeat another (a `pattern` beside a `format`, `minLength: 1`, `$schema`). For the 44 tools a model sees it is under 53,300 characters, and the instructions under 3,300: about 14,000 tokens before the first call. Three arguments the tools accept are not listed, since an agent should never send them: `brand` and `dealer` on `generate_creative` and `preview_template` (refused with `locked_field`), and `recipient` on `preview_template`. Every call is still checked against the full schema REST uses, so a listed and an unlisted argument get the same answers as over REST.

The dealer's lasting do-not-mail list and deleting an audience early have no tool: use the [REST routes](audiences.md#when-a-person-asks). A do-not-mail list holds people's names and addresses on their way in, and rows never go in a tool argument. What the list removes shows in `upload_audience`'s report as `dealer_suppression_removed`.

### list_mail_products

| Input | Type | Notes |
| --- | --- | --- |
| `detail` | `compact` or `full`, optional | Default `compact`. |

Compact (the default) returns `products`, each with its `code`, `name`, `kind`, `finished_size`, `sides`, `fold`, `envelope` code, `envelope_options` (the envelope types it can mail in, with `default`: the letter's `closed_face`, the default, and `double_window`, and the fold card's `closed_face`; `detail: "full"` adds their geometry), `mail_classes`, `min_presort_pieces`, `confirmed_by_printer` and its templates' `code` and `name` only, plus `placeholder_pricing`, `pricing_note`, `specs_note`, `detail: "compact"` and a `next_step` that points to `list_templates`. `detail: "full"` returns what `GET /v1/products` returns: the print specs (address block, barcode clear zone, notes and sources) and every template with every slot, which is large. To choose a template, call `list_templates` instead. See [Products](products.md).

### list_templates

| Input | Type | Notes |
| --- | --- | --- |
| `product_code` | string, optional | Only this product's templates. A product Xcel does not offer is `unknown_product`. |
| `use_case` | string, 1 to 40, optional | Only templates with this use case tag, for example `birthday`. Case and punctuation do not matter. |
| `query` | string, 1 to 200, optional | Words matched against names, descriptions and use cases, for example `birthday card`; best match first, and templates that match nothing are left out. |
| `owner` | `xcel` or `partner`, optional | Only Xcel's templates, or only your own saved templates. Omit for both. |
| `prescreened` | boolean, optional | `false` leaves out the prescreened credit offers (`requires_prescreened_list: true`), as for any CDP, CRM or DMS customer list; `true` keeps only them. |
| `source_audience` | string, 1 to 200, optional | Your audience's ID or name on your platform. With the audience map Xcel loads for your account, its templates come first and the answer's `source_audience` says how it matched; without one, a name searches like `query` ([Find a template](creative.md#find-a-template)). |
| `detail` | `compact` or `full`, optional | Default `compact`. |

In an app that shows views, the answer opens the [template picker](#views-in-the-chat): each design as its picture, and a click puts the pick in the chat.

Without `prescreened`, the prescreened offers come after every other template, in every listing, unless `query` or `use_case` asks for credit (credit, prescreened, pre-approved, pre-qualified, financing, APR, lower payment, refinance, equity; or the use cases `prescreened_credit`, `finance_offer`, `payment_reduction`, `equity`). The compact `summary` of every prescreened template starts with "Prescreened offer: credit bureau lists only, never a CDP, CRM or DMS list."

`query` also understands common phrasings as use cases, which outrank plain words: "haven't been in", lapsed, inactive, overdue and due for service are `service_retention`; pull-ahead, lease ending, lessees and months left are `lease_pull_ahead`; buy back, "we want your car", "buy your vehicle" and used inventory are `buyback` and `vehicle_acquisition`; trade-in, high mileage and upgrade are `trade_in`; declined or recommended service is `declined_service`; warranty and extended coverage are `warranty`; shoppers, website visitors and test drives are `in_market`; unsold, be-back and showroom traffic are `unsold_leads`; conquest, competitors and new customers are `conquest`; loyal, existing or past customers are `customer_loyalty`; recent purchases and first service are `new_owner`; paid off, payoff, finance maturity and payments left on a loan are `loan_pull_ahead`; recalls and open or safety recalls are `recall`; service to sales and bought elsewhere are `service_to_sales`; thank you for your service or visit, recently serviced and reviews are `service_thank_you`; never serviced, sold but not serviced and recent sales without service are `sold_not_serviced`; holiday and sales events, tax season, announcements, birthdays, ownership anniversaries and model launches have their own. Words such as months, been and back are ignored, since every description can contain them. "birthday card" leads with `card_8_5x11_birthday`; "model launch" finds nothing, since no current template is for it, and the answer's `note` lists the use cases in use.

Compact (the default) returns one short entry per template: `code`, `product_code`, `name`, `summary` (one line), `use_cases`, `required_slots`, `audience_columns`, `requires_prescreened_list` and `preview_url`, plus `use_cases` (every tag in use), `detail`, when a filter matched nothing a `note` that says why, and `source_audience` when you sent it. Your own saved templates come first within each product and carry `owner: "partner"`, the `version` listed and `saved_at`, when that version was saved; Xcel's entries have none of the three. `detail: "full"` adds `owner` on every entry, `version`, `created_at` (your own templates), `description`, `formats`, `compliance` and every slot (kind, `max_length`, `required`, `sample`, `default`, `dealer_fact`). See [Find a template](creative.md#find-a-template).

- `audience_columns` are the recipient columns the piece prints beyond the name and address: name your CSV columns so, or map yours to them with `column_map`.
- `requires_prescreened_list: true` marks a prescreened credit offer: only for a list from a consumer reporting agency (an FCRA prescreen), never a CDP, CRM or DMS customer list.
- `preview_url` opens the template with its sample copy, Demo Motors and the fictional recipient in a browser for one hour, with no API key ([Preview links](creative.md#preview-links)). Send it to the person.

### get_template

| Input | Type | Notes |
| --- | --- | --- |
| `template_code` | string, 1 to 64 | A code from `list_templates`. |
| `template_version` | integer, optional | Your own saved templates only: this version instead of the current one. Xcel's templates serve only their current version (`template_version_unavailable`). |

Returns `template` in the full shape: every copy slot (kind, `max_length`, `required`, `sample`, `default`, `description`, and `dealer_fact: true` on a claim only the dealer can make), the `compliance` rules, `use_cases`, `audience_columns`, `requires_prescreened_list`, `formats`, `sample_copy` and a `preview_url`, plus a `next_step`, which also says to ask the person for the slots marked `dealer_fact` and for the disclosures. Your own saved template adds `owner: "partner"` and `created_at`. The layout regions and a saved template's stored HTML are REST only (`GET /v1/templates/{code}`). An unknown or retired code, or another partner's, is 404 `unknown_template`.

### save_template

| Input | Type | Notes |
| --- | --- | --- |
| `code` | string | Your code: lower-case letters, digits and underscores, starting with a letter, at most 40 characters. Stored and returned as `p_<code>`; send either form to save a new version. |
| `product_code` | string, 1 to 64 | An offered product. Every version of a code keeps its product. |
| `name` | string, 1 to 80 | |
| `description` | string, 1 to 2,000 | What the piece is for and who should get it. |
| `html` | string, 1 to 200,000 | The template HTML, under the rules of `generate_creative`'s `html`; start from the product's starter file. |
| `slots` | array, at most 60 | Each with `name`, `kind`, `max_length`, and optionally `label`, `required`, `sample` (required slots need one), `default`, `dealer_fact` and `description`. |
| `use_cases` | array of strings, at most 12, optional | Tags for `list_templates`' `use_case` filter. |
| `idempotency_key` | string, optional | As on `create_campaign`. REST sends it as the `Idempotency-Key` header. |

Saves your own HTML with typed slots under your own code (`p_<code>`). Each save of a code is its next immutable version, and the same content again saves nothing (`result: "unchanged"`). The HTML is cleaned like `generate_creative`'s `html` and must pass preflight with every slot's sample for Demo Motors, or nothing is saved (`template_invalid` lists each error with its fix); a template that prints `{{recipient.external_id}}`, an id column or a contact column such as `email` or `phone` is refused (`audience_identifier_printed`). You may keep 100 active templates and 50 active versions of each; past that a save is refused with `template_limit_reached` or `template_version_limit_reached` (retire old ones with `retire_template`). Your sandbox and live keys share your templates; no other partner sees them. They never print Xcel's licensed vehicle photos. Returns `template` with a `preview_url` to show the person, `result` (`created`, `new_version` or `unchanged`), `preflight`, `next_step` and `idempotent_replay`. See [Your own templates](creative.md#your-own-templates).

### retire_template

| Input | Type | Notes |
| --- | --- | --- |
| `template_code` | string, 1 to 64 | One of your saved templates (`p_...`). |

Retires every version of one of your saved templates: it is no longer listed, previewed or used by new creatives. Creatives already made from it are unchanged. Saving the code again starts its next version. Returns `template` (`code`, `owner`, `product_code`, `latest_version`, `retired: true`, `versions_retired`) and `next_step`. Xcel's templates are `template_read_only` (403); another partner's code is `unknown_template`.

### preview_template

| Input | Type | Notes |
| --- | --- | --- |
| `template_code` | string, 1 to 64 | A code from `list_templates`. |
| `template_version` | integer, optional | Your own saved templates only: this version instead of the current one, and its `preview_url` opens this version. Xcel's templates serve only their current version (`template_version_unavailable`). |
| `copy` | object of strings, optional | Slot values. Slots you leave out print their samples (with `dealer_id`, store details come from the dealer's profile, dealer facts print no sample, and once you send any copy, optional slots print their default or nothing); send `""` to leave an optional slot empty. |
| `dealer_id` | string, optional | One of your dealers. Default: the sample dealer Demo Motors. |
| `envelope` | string, optional | Letter templates only: `closed_face` (the default) adds the envelope face as the last page, and its `preview_url` shows it too; `double_window` shows the letter alone. Refused for a postcard. A fold card always shows its closed face. |
| `recipient` | object, optional | REST only in practice: the tool accepts it but does not list it, because an agent should never put a customer's row in a call. A made-up row (`first_name`, `last_name`, `address1`, `city`, `state` and `zip` required, plus optional and custom columns) replaces the fictional sample recipient. Not stored. |
| `document` | `none`, `html` or `pdf`, optional | What else comes back. Default `none`. |

It renders a template without a campaign, through the same composition, locked brand values, preflight and address fitting as `generate_creative` and `render_proof`. It returns `preview_url` and `preview_url_expires_at` first: a link the person can open in a browser for one hour with no API key, showing this template with your copy, the dealer and the fictional sample recipient, never a recipient you sent (add `?format=pdf` for the PDF; [Preview links](creative.md#preview-links)). Send the person the link; it is `null` only when the copy is too long for one. Opening it counts against no limit, however often a chat app unfurls it. Then the same JSON as REST `format: "json"`: template, dealer, `copy` (what printed), `sample_slots`, `profile_slots`, `blank_store_slots`, `dealer_fact_slots`, `omitted_slots`, `preflight`, `renderer` and `next_step`. With `dealer_id`, the preview prints what `generate_creative` prints: store details you leave out (phone, hours, web address, QR link, signer) come from that dealer's profile or stay empty, and dealer facts (slots marked `dealer_fact`, and disclosures) print their default or nothing. With `dealer_id` and any `copy`, an optional slot you leave out prints its default or nothing, exactly as `generate_creative` prints it (`omitted_slots`); with no `copy` the samples show, for browsing. A required slot you leave out still shows its sample, and `next_step` says `generate_creative`'s preflight fails without it. Demo Motors' samples never print for a real dealer. `document: "html"` adds `html` (the proof page with guides) and `document: "pdf"` adds `pdf_base64` (the review proof PDF; 503 `pdf_unavailable` where PDF rendering is off). There is no `format` input: the tool always answers JSON. As in `generate_creative`, `brand` and `dealer` inputs and locked copy keys are refused with `locked_field`. Errors: `unknown_template` (404), `template_version_unavailable` (400), `not_found` for another partner's `dealer_id`, `locked_field`, `proof_render_rate_limited` (429; the hourly limits, per dealer and per partner, are shared with `render_proof`, and the message says which was reached and when it resets). See [Preview a template](creative.md#preview-a-template).

### preview_artwork

| Input | Type | Notes |
| --- | --- | --- |
| `product_code` | string, 1 to 64 | An offered product, e.g. `postcard_6x9` (400 `unknown_product` otherwise). |
| `artwork` | object | `{"url": "https://..."}` for one PDF with a page per printed side, or `{"front": {"url": "..."}, "back": {"url": "..."}}` for one PNG or JPEG per side (a letter's front is page 1). URLs only: an `artwork_id` is refused here, since an agent cannot upload a file. |

It checks art before a campaign exists, through the same reading and preflight as `generate_creative` with `artwork`, for the sample dealer Demo Motors (the creative checks it again for the campaign's dealer). It returns `preview_url` (the review proof PDF, the art with the guides and the address block for the fictional sample recipient, for one hour with no API key; [Preview artwork](creative.md#preview-artwork)): send the person the link. It is `null` where PDF rendering is off. Then the same JSON as REST `format: "json"`, without `pdf_base64`: `artwork_id` and `artwork_id_expires_at`, `artwork` (format, sha256, pages and, for images, each side's pixels, ppi and color), `dealer`, `preflight` (every `artwork_*` issue with its fix, and `locked_disclosure_unverified`) and `next_step`. A preflight error does not fail the preview. The art is kept 7 days as `artwork_id`: send `{"artwork": {"artwork_id": "..."}}` to `generate_creative` instead of the URLs, and nothing is fetched again. Errors are those of `generate_creative`'s artwork (for example `artwork_url_unreachable`, `artwork_not_pdf`, `artwork_not_image`, `artwork_too_large`), `unknown_product`, and `proof_render_rate_limited` (429; the hourly limits are shared with `render_proof` and `preview_template`, and without a dealer the preview counts against your partner's ceiling only).

### get_dealer_brand

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string, 1 to 100 characters | Xcel's dealer id or your external id. |

Returns what a new creative prints for the dealer: `dealer_name`, `address`, `logo_url` (a logo URL Xcel set) or `logo` (an uploaded logo's details), `colors` and `phone` from the current profile, `profile_version`, and the Xcel-managed `disclaimers`, `locked` and masked `registered_approvers`. A creative request cannot override these; change the profile instead.

### get_account

No inputs. Returns your account as `GET /v1/account` does: the company, the key's mode and dealers, whether live ordering is on, pricing, limits, and `live_readiness`: what is left before a live order (`gaps`) and who has to do it. The prompt **Are we ready to go live?** starts here, then `list_dealers` for each dealer's approver and logo.

### list_dealers

| Input | Type | Notes |
| --- | --- | --- |
| `limit` | integer, 1 to 200 | Default 50. |
| `after` | UUID | The `next_after` of the previous page. |

Returns `dealers` (id, `test_only`, `external_id`, name, address, `profile_version`, `live_ready`, `updash_linked`, masked approvers), `next_after` and `limit`.

### get_dealer_profile

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string, 1 to 100 characters | Xcel's dealer id or your external id. |
| `version` | integer | A past version; omit for the current one. |

Returns the `version` (pass it as `expected_version`), the `profile` you own, the `logos`, `approver_invitations` (the approvers you named and their status), the read-only `xcel_managed` fields and `live_ready`. See [Dealers](dealers.md#read-dealers).

### upsert_dealer

| Input | Type | Notes |
| --- | --- | --- |
| `external_id` | string, 1 to 100 characters | Your id for the dealer. |
| `profile` | object | A new dealer needs one, with `name` and `address`. For an existing one, only the fields to change (merge patch), or leave it out, for example to only name an approver. |
| `expected_version` | integer | Updates only: refuse with `version_conflict` unless the profile is at this version. |
| `approver` | object | Optional: `email` (at most 254 characters) and `name` (1 to 100). The person the user names to approve the dealer's live orders; never guess one. |

Creates the dealer (`created: true`) or merges into the one you have with that `external_id` (`created: false`). A new dealer is not `live_ready` until an approver is registered. Disclosures, the license number and the spend cap are refused with `xcel_managed_field`.

With `approver`, Xcel emails the person a confirm link, as `POST /v1/dealers/{id}/approvers` does: `approver_invitation` has the `invitation` and its `status`. A refused invitation (for example `approver_already_registered`) does not undo the dealer change; it comes back as `approver_invitation_error`. See [Approvers](dealers.md#approvers).

With a sandbox key a new `external_id` creates a [test dealer](dealers.md#test-dealers) (`test_only: true`). An update of a dealer shared with the live key is not saved: `"validated_only": true` and a `note`. An approver is never emailed from the sandbox. See [Test keys only validate](dealers.md#test-keys-only-validate).

### update_dealer_profile

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string | Xcel's dealer id or your external id. |
| `expected_version` | integer | Required: the version you read. A newer one refuses the update with `version_conflict`; read again and reapply. |
| `changes` | object | Only the fields to change. Objects merge, `null` clears, lists replace. |

Returns the new profile with `changed`, `changed_fields` and `validated_only: false`. Existing creatives keep their profile version; call `generate_creative` again to print the change.

With a sandbox key the update is checked and not saved: `validated_only: true`, `version` stays the current one, and `would_be_version` is what a live key would write.

### upload_dealer_logo

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string | Xcel's dealer id or your external id. |
| `variant` | `primary` or `reversed` | Default `primary`. |
| `content_base64` | string | The file, base64: PNG, JPEG or SVG, at most 3 MB. Send this or `url`. |
| `url` | string | An `https` URL Xcel fetches (public host, no redirects). |
| `expected_version` | integer | Optional `version_conflict` check. |

Raster logos need at least 600 px on the long side; animated files are refused; SVG is cleaned and drawn to a PNG. See [Dealers](dealers.md#logos). With a sandbox key the file is checked and drawn, but nothing is stored (`validated_only: true`).

### upload_dealer_asset

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string | Xcel's dealer id or your external id. |
| `kind` | `signature`, `store_photo`, `staff_photo` or `photo` | What it is. |
| `label` | string | Names it in `{{asset.<kind>.<label>}}`. Required for a photo. The same kind and label again replaces the file. |
| `name`, `title` | string | The person, for a signature or staff photo. A staff photo needs a name; a signature takes the dealer's contact name when you leave it out. |
| `content_base64` | string | The file, base64: PNG or JPEG (SVG for a signature). About 3 MB at most this way, since the hosted API refuses a request body over 4.5 MB; send a larger file, up to 10 MB, by `url`. |
| `url` | string | An `https` URL Xcel fetches (public host, no redirects). |
| `expected_version` | integer | Optional `version_conflict` check. |

The answer's `asset.merge_field` prints it in your HTML, and `warnings` says in plain words when it is too small to print sharply. Upload only what the dealer owns the rights to. See [Creative assets](dealers.md#creative-assets). With a sandbox key on a shared dealer the file is checked and drawn, but nothing is stored (`validated_only: true`).

### upload_partner_asset

| Input | Type | Notes |
| --- | --- | --- |
| `name` | string, 1 to 120 | What the photo shows. |
| `label` | string, optional | Names it in `{{asset.photo.<label>}}`; made from `name` when you leave it out. The same label again replaces the file. |
| `description` | string, optional | When to use it. |
| `content_base64` | string | The file, base64: PNG or JPEG, about 3 MB at most this way. Send a larger file, up to 10 MB, by `url`. |
| `url` | string | An `https` URL Xcel fetches (public host, no redirects). |

The photo goes in your [asset library](dealers.md#asset-library), for every dealer: `{{asset.photo.<label>}}` prints it where the dealer has no photo of its own with that label, and a built-in template's slot with that label (`service_drive`) prints it too. Sandbox and live keys share the library, so a sandbox key's upload is saved. `list_partner_assets` lists the library and `delete_partner_asset` removes a photo; creatives already made keep what they printed. To rename one, use `PATCH /v1/assets/{asset_id}`.

### list_make_logos

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string, optional | Only this dealer's makes, from its current profile. |
| `make` | string, optional | A make or alias (`Ford`, `Chevy`, `land-rover`): the answer adds `make`, that make in full. |

Returns `makes` (each with `make`, `name`, `on_light`, `on_dark`, `svg` and any `rule`), `dealer` (with `dealer_id`) and `placing`, how to print make logos in your HTML; with `make`, also `make`: its variants with each file's `url`, `content_type`, `width` and `height` (`GET /v1/makes/{make}/logo`), and with `dealer_id` `dealer_sells_make`. No file comes back inline. In HTML, print `{{dealer.make_logos}}`: it prints the dealer's own makes in the variant for their background ([Make logos](creative.md#make-logos)).

### prepare_order

One call for the middle of an order. A new order takes `dealer_id`, `template_code` (the template names the product) and `copy`, a `brief`, or an `offer_id`:

1. It creates the campaign (`name` defaults to the template's name) and makes the creative. A creative with preflight errors is kept and the call stops there, with `stopped` and the fixes.
2. With `source_url` it imports the list, renders the proof and quotes it, all in this call.
3. Without it, the answer starts the upload (`audience_id`, `upload_page_url`, `upload_url`, `then: "prepare_order"`) and an app with views shows the upload view, which completes the upload and calls `prepare_order` with `campaign_id` to render the proof and quote. Elsewhere, give the person `upload_page_url`; once they say the list is in, call `upload_audience` with `uploaded_audience_id`, then `prepare_order` with `campaign_id`.

| Input | Type | Notes |
| --- | --- | --- |
| `campaign_id` | string, optional | An order `prepare_order` started: it does what is left. Not with `dealer_id`, `name`, `requested_mail_date` or `idempotency_key` (`invalid_request`). With `template_code`, `copy`, `brief` or `offer_id` it makes a new creative first. |
| `dealer_id` | string, 1 to 100 | A new order: Xcel's dealer id or your external id. |
| `template_code` | string, 1 to 64 | A new order: from `list_templates`. |
| `name` | string, 1 to 120, optional | Default: the template's name. |
| `requested_mail_date` | string `YYYY-MM-DD`, optional | As `create_campaign` takes it. |
| `copy` | object, optional | Slot values by slot name, as `generate_creative` takes them. |
| `brief` | object, optional | `goal`, `offer`, `tone`?, `audience`?: Claude writes the slots you leave out. For credit or lease terms, use `generate_creative`'s `brief.offer_terms`. |
| `offer_id` | string, optional | From `list_dealer_offers`. |
| `source_url` | string, optional | An https link to the CSV, as `upload_audience` takes it. |
| `column_map` | object, optional | With `source_url`, as `upload_audience` takes it. |
| `idempotency_key` | string, optional | As `create_campaign` takes it: a retry returns the first campaign. |

Returns `campaign_id`, `campaign_name`, `done` (the steps this call finished, in order: `campaign`, `creative`, `audience`, `proof`, `quote`), the result of each step that ran (`creative`, `audience`, `proof` without its pages, `quote`), and `next_step`. A step that stops answers `stopped` (`step`, `code`, `message`, `fix`) and keeps the order: follow `fix`, then call again with `campaign_id`, so no second order is made. It never approves or submits: after it, `show_proof`, then `request_approval` with the budget the person set.

### create_campaign

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string, 1 to 100 | Xcel's dealer id or your external id. |
| `product_code` | string, 1 to 64 | A code from `list_mail_products`. |
| `name` | string, 1 to 120 | A name for the campaign. |
| `requested_mail_date` | string `YYYY-MM-DD`, optional | Not in the past, at most 180 days out. A request, not a promise ([Mail dates](quotes-and-approvals.md#mail-dates)). |
| `envelope` | string, optional | Letters only: `closed_face` (the default), a #10 with no window that the printer addresses and matches to its letter, or `double_window`, where page 1's addresses show through the windows. Refused for a postcard; a fold card always mails in its closed-face 6 x 9. See [A letter's envelope](concepts.md#a-letters-envelope). |
| `external_ref` | string, 1 to 100, optional | Your own id for the order, for example your campaign id. Returned on the campaign, its results and every campaign webhook; `list_campaigns` finds it. |
| `metadata` | object, optional | Up to 20 keys (1 to 40 characters) with string values (up to 500). |
| `idempotency_key` | string, optional | A key you generate for this order (a UUID) and send again only when you retry. The same key with the same arguments within 24 hours returns the first campaign with `idempotent_replay: true`; with different arguments it is refused with `idempotency_key_reused`. |

Never put customer data in `external_ref` or `metadata`: no names, addresses, emails, phone numbers or VINs. Returns `campaign`, `next_step`, `live_gaps` and the placeholder dates in `timing`, and with `idempotency_key` also `idempotent_replay` (`false` on a first call). The key shares one namespace with `submit_campaign`, so do not reuse a create key for a submit. See [Your reference on a campaign](concepts.md#your-reference-on-a-campaign).

### list_campaigns

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string, optional | One dealer's campaigns (Xcel's id or your external id). An unknown dealer is `not_found`. |
| `status` | string, optional | One status, for example `awaiting_approval`. |
| `external_ref` | string, optional | Campaigns created with this `external_ref` (exact match). |
| `created_after`, `created_before` | string, optional | An ISO 8601 date-time with a time zone, or a date (midnight UTC). Exclusive. |
| `limit` | integer 1 to 100, optional | Default 25. |
| `starting_after` | string, optional | The `next_cursor` of the previous page, unchanged, with the same filters. |

Returns `campaigns` (newest first: each with its id, name, `dealer_id` and `dealer_external_id`, `product_code`, `template_code` and `template_version`, `envelope`, status, versions, `external_ref`, `metadata`, dates, and once submitted `quantity`, `total_cents`, `placeholder_pricing` and `submitted_at`, null until then), `has_more` and `next_cursor` (`null` on the last page). It lists only your key's mode. An agent in a new conversation finds an order this way without its campaign id, then passes the id to `get_campaign_status` or `get_campaign_results`. See [List campaigns](api-reference.md#list-campaigns).

### upload_audience

In an app that shows views, calling it without a link opens the [upload view](#views-in-the-chat): the person drops the file and the view finishes the upload. With a link, call it once: `campaign_id` and `source_url`, an https link to the CSV that anyone can open for a few minutes, such as a presigned link from the CDP, CRM or storage service that holds the export. Xcel fetches it once (a public address, no redirects, at most 50 MB) and processes it in the same call, so you never handle a signed URL. Add `column_map` when your columns have other names. It returns what the second call below returns. The link is never stored or logged. A link that cannot be fetched is `audience_url_unreachable`, and one that serves a page or a spreadsheet instead of a CSV is `audience_not_csv`; neither makes an audience version. See [Import in one call](audiences.md#import-in-one-call).

Without a link, call it twice:

1. With `campaign_id` (and `include_suppression_list: true` if you have a do-not-mail list). Returns `audience_id`, `upload_url` (valid 2 hours), `upload_page_url` (valid 2 hours) and `suppression_upload_url`.
2. Give the person `upload_page_url`: they open it in a browser and choose the CSV or Excel file (at most 4 MB). The page stores it without date-of-birth columns and shows only the count of rows and the column names. Or PUT the CSV to `upload_url` with `Content-Type: text/csv`, outside the MCP connection, for example with `curl` or your own code. One PUT per URL: to send a corrected file, call `upload_audience` again for a new URL.
3. Call again with `campaign_id` and `uploaded_audience_id` set to the `audience_id`, plus `column_map` when your columns have other names (`{"customer_id": "external_id"}`) and `vehicle_source` to choose which history columns set the vehicle ([A CDP export as it comes](audiences.md#a-cdp-export-as-it-comes)). Returns `audience` (counts and the reconciliation report), `campaign_status` and `next_step`. When the report has a `suggested_column_map`, `next_step` says to complete the same `audience_id` again with it (the exact map is in the sentence): the file is processed again with no new PUT ([Column mapping](audiences.md#column-mapping-column_map)). Then it names `generate_creative`, or, when the campaign already has a creative, `validate_campaign` and then `render_proof`. With no mailable rows it says to correct the file and start a new upload.

| Input | Type | Notes |
| --- | --- | --- |
| `campaign_id` | string | |
| `source_url` | string, 1 to 4,000, optional | An https link to the CSV. Imports and processes the file in this call; not with `uploaded_audience_id` or `include_suppression_list` (`invalid_request`). |
| `uploaded_audience_id` | string, 1 to 64, optional | Present on the second call only. Omit it (do not send an empty string) on the first call. |
| `include_suppression_list` | boolean, optional | First call of the signed upload only. |
| `column_map` | object, optional | With `source_url`, or on the second call (on the first it is refused with `invalid_request`, `field` `column_map`): your header to our column, at most 100 entries. |

Name the record-id column `external_id`, or map it: per-lead results come back keyed by it, and without it every result has `external_id: null` (the report warns `external_id_column_missing`). Phone and email columns are optional: UpDash uses them to match responses and sales to the piece, and they are never printed or returned (the report notes them as `contact_columns_present`). A file may leave out `city` and `state`: they are filled from the ZIP, and the report lists the rows (`city_state_filled_from_zip`). `list_templates` gives each template's `audience_columns`; the report warns `template_columns_missing` when the campaign's creative reads a column the file lacks. When the creative comes after the audience, preflight warns the same at `generate_creative`, `validate_campaign` and `render_proof`, with the `column_map` to send and the `audience_id` to complete again.

Never pass customer rows to this tool or any other. Prefer a `source_url` when the user's system can give one. If you cannot make the PUT yourself, give the user `upload_page_url` and wait for them to say the list is uploaded; do not ask them to paste the file into the chat, and do not hand a non-technical user a `curl` command. The URL expires after 2 hours. See [Audiences](audiences.md).

### generate_creative

| Input | Type | Notes |
| --- | --- | --- |
| `campaign_id` | string | |
| `template_code` | string, optional | A template for the campaign's product: one of Xcel's, or your own saved template (`p_...`). Send exactly one of this, `html` and `artwork`. |
| `template_version` | integer, optional | With `template_code`, your own saved templates only: use this version instead of the current one. The creative records the version it used either way. |
| `html` | string up to 200,000, optional | Your own HTML. Must keep `{{brand.disclaimers}}` and, except on a fold card, an element with class `xm-address`. |
| `artwork` | object, optional | Print-ready art instead: one PDF as `{"url": "https://..."}` or `{"artwork_id": "..."}`, or one PNG or JPEG per side as `{"front": {...}, "back": {...}}`, each `{"url"}` or `{"artwork_id"}` (a letter's front is page 1). An `artwork_id` comes from `preview_artwork` or a REST upload. Not with `copy` or `brief`. See [Print-ready artwork](creative.md#print-ready-artwork). |
| `copy` | object of strings (each up to 5,000), optional | Slot values, for example `{"headline": "Service Days"}`. With a `brief`, your copy wins slot by slot. |
| `brief` | object, optional | Template creatives only. Claude writes the slots your `copy` leaves out: `goal` (required, up to 300), `offer` (required, up to 400, with the real figures and end date), `tone` (up to 100), `audience` (up to 300, general terms only) and `offer_terms` (structured finance or lease terms). See [AI-written copy](creative.md#ai-written-copy). |

With a `brief`, the result adds `ai_copy`: `status` (`ready` or `needs_edit`), the `model`, `rounds`, `generated_slots`, `offer_terms_slots`, the drafted `copy` and `issues` (each slot the checks removed). Claude never writes phones, disclosures, vehicle slots, hours, signer names, web addresses, QR links, dealer facts (slots marked `dealer_fact`, such as inventory claims) or slots with a default; send those in `copy`, after asking the person for the dealer facts. Never put customer data in a brief, and read the draft before you request approval: the checks on it are pattern checks. A brief can fail with 503 `ai_copy_unavailable` (AI copy not configured), 429 `ai_copy_rate_limited` (200 model calls a day per dealer by default, 2,000 per partner; the message says which limit and when it resets) or 502 `ai_copy_failed`.

`brand` and `dealer` are not in the tool's schema: brand values come only from the brand kit, and sending either is still refused with `locked_field`. A copy key that names a brand field or starts with `brand`, `dealer`, `recipient` or `fcra` is refused with `locked_field`. If the copy quotes a payment, rate, term or down payment, fill `offer_disclosure` with the full terms; the compliance checks are pattern checks, not legal review ([Compliance checks](creative.md#compliance-checks)). Copy and `html` may print text only for some recipients with `{{#if}}`, `{{else}}` and `{{#unless}}` blocks ([Conditional blocks](creative.md#conditional-blocks)). Templates and `html` (not copy) print make logos, vehicle photos and QR codes through image fields; vehicle photos print on live orders only from Xcel's templates ([Image fields](creative.md#image-fields)). Returns the creative with its preflight issues (each issue has a `fix`), `profile_slots` and `next_step`. Store details you leave out (phone, hours, web address, QR link, signer) print from the dealer's profile, as `preview_template` with `dealer_id` shows them, and `profile_slots` names them: tell the person which details come from the dealer profile. Send `""` for a slot to leave it empty. Send a store detail only with a value the user gave: copy that prints Demo Motors' sample details for another dealer gets `sample_store_value` (a warning in the sandbox, an error on a live order). `next_step` is one you can follow now: with preflight errors it names the first error's field and fix (`render_proof` would refuse); otherwise it names the next call in the flow. See [Creative](creative.md).

**Artwork.** URLs work from MCP: `artwork.url` for one PDF with a page per printed side at the product's file size, fonts embedded, at most 50 MB; or `artwork.front.url` and `artwork.back.url` for one PNG or JPEG per side, each at most 25 MB, in the page's proportions within 1% and 300 ppi or more at the file size (placed on the page without resampling). Each is fetched once over https with no redirects. Check the art first with `preview_artwork`, and send its `artwork_id` here. The signed upload starts (`POST /v1/artwork`, `POST /v1/campaigns/{id}/creative/artwork`) are REST only, because an agent cannot PUT a file: a backend or the person uploads the file and gives you the `artwork_id`; uploads are kept 7 days. The art is static (no copy, brief or merge fields), Xcel prints the address block over it, and the result adds `artwork` (the format, the print file's sha256, size and pages, and each image for image art). Every artwork creative carries the info issue `artwork_not_checked`: the copy and offer checks cannot read art, so the wording is the partner's responsibility. Never send a prescreened credit offer as artwork; use a template with `requires_prescreened_list: true`. Its proof needs PDF rendering (503 `pdf_unavailable` otherwise).

### render_proof

Input: `campaign_id`. Renders three sample rows and the worst case, checks the logo and the address block, prints the review and print-ready PDFs where PDF rendering is on (`renderer.format: "pdf"`, `pdf_available: true`), and moves a `draft` campaign to `proof_ready`. The proof is not returned in any form, because it shows customer records: the approver opens it from the review page. To see a template printed before a campaign exists, use `preview_template`: it can return its PDF or HTML, because it prints only your copy, your dealer and the recipient you send (or fictional ones). A PDF that cannot be printed fails the call with 502 `proof_render_failed`; retry in a minute. Where PDFs are rendered, `request_approval` binds the approval to the print file. `render_proof` counts against the campaign's dealer and your partner per hour (429 `proof_render_rate_limited`; [Rate limits](api-reference.md#rate-limits)), so render once the creative and audience are final.

### validate_campaign

Input: `campaign_id`. Returns `ready_for_proof`, `ready_for_quote`, `ready_for_approval`, `ready_for_submit`, `live_gaps`, a checklist, every preflight issue, `dealer_spend_cap_cents`, `dealer_spend_remaining_cents` and `next_step`. Changes nothing. On a live order, `ready_for_approval` is `false` when the dealer has no registered approver or your account has live ordering off, and `live_gaps` says which and who acts next; missing disclosures are listed too, as a warning. `ready_for_approval` is also `false` when Xcel changed the disclosures after the proof rendered (`proof_disclosures`): call `render_proof` again. The `dealer_facts` check names the slots only the dealer can state, to confirm with the person. `next_step` is one you can follow now: before approval, an audience with no mailable rows says to upload a corrected file, and preflight errors name the first error's field and fix; then, once the order is proofed, a spend cap that refuses it; otherwise it names the next call in the flow.

When the dealer has a monthly spend cap, `dealer_spend_cap_cents` is the cap and `dealer_spend_remaining_cents` what is left of it this month (UTC); both are `null` without a cap. Before submission the checklist then has a `spend_cap` check: it fails when the quote under approval (a pending or approved approval for the current versions) is over what is left, or, with none, when nothing is left. It holds up `ready_for_approval` only, never the proof or the quote; once the order is proofed, `next_step` says what to do.

### get_quote

| Input | Type | Notes |
| --- | --- | --- |
| `campaign_id` | string | |
| `mail_class` | `first_class` or `marketing_mail`, optional | Defaults to the product's class: `first_class` for the postcard (its only class), `marketing_mail` for the letter and the fold card. |

Returns `quote`, `dealer_spend_cap_cents`, `dealer_spend_remaining_cents` and `next_step`; when the total is over what is left of the cap, `next_step` says so, with the amounts, the date the cap counts from zero again and the ways out. Prices are your own at your volume tier (the console's [Pricing](/console/pricing) page), with a line for each add-on the design uses.

### request_approval

| Input | Type | Notes |
| --- | --- | --- |
| `campaign_id` | string | |
| `quote_id` | string | `quote.id` from `get_quote`. |
| `max_spend_cents` | positive integer, at most 10,000,000,000 | The most the user told you to spend: never your own estimate and never higher. If they gave no figure, ask first. At least the quote total. |
| `approver_email` | email, at most 254 characters, optional | Live: one of the dealer's registered approvers; omit when only one is registered. Sandbox: any address. |

Live: returns `approval_id`, `status`, the masked `approver_email`, `total_cents`, `expires_at`, `prescreen_attestation` and `next_step`; the review link goes only to the approver by email. On a prescreened credit offer, `prescreen_attestation` names the consumer reporting agency and `next_step` says the approver must confirm on the review page that the list is a prescreened list from it, with the list's date, before Approve works ([Prescreened offers](quotes-and-approvals.md#prescreened-offers)); tell the person, since their own customer list cannot be approved for it. It is null for any other piece. Sandbox: also returns `review_url` and `sandbox_only: true`. An order over the dealer's monthly spend cap is refused with `dealer_spend_cap_exceeded` before anyone is asked. The cap is checked here, again when the approver decides, and at submit. Nothing is pushed to you: poll `get_campaign_status` for the decision.

### submit_campaign

| Input | Type | Notes |
| --- | --- | --- |
| `campaign_id` | string | |
| `approval_id` | string | From `request_approval`, after a human approved it. |
| `idempotency_key` | string, 1 to 255 printable ASCII characters, no spaces | Generate one per order, for example a UUID. Reuse it only to retry the same submission. A key that breaks the rule is refused with `invalid_request` (REST says `invalid_idempotency_key`). |

Returns the submission (the same body as REST) plus `idempotent_replay`: `true` when the result is a stored replay.

### get_campaign_status

Input: `campaign_id`. Returns the campaign, `status_description`, the audience and its counts, any pending upload, the creative's preflight state, `latest_quote` (its id, total, `placeholder_pricing`, expiry, and `usable` while it still fits the current versions), `latest_approval`, the submission, `in_ops_queue`, `waiting_on` (who holds the order now) and `next_step`. A usable quote is named in `next_step`, so a new conversation need not quote again. `next_step` reads the creative's preflight: with errors it says to fix the creative (`validate_campaign` lists each issue) instead of rendering the proof.

### get_campaign_results

| Input | Type | Notes |
| --- | --- | --- |
| `campaign_id` | string | |
| `leads_after` | string, optional | The `leads.next_after` of the previous page (a row key). Omit for the first page. |
| `leads_limit` | integer 1 to 500, optional | Leads per page; default 100. |
| `external_id` | string, optional | Only this person's leads: your record id, exact. Never an email or phone: one is refused. |
| `updated_after` | string, optional | Only leads whose results changed after this time: a date-time with a time zone, or a date. |

Returns the dealer's ids, the status, `results_status` (where results stand), quantities, the timeline of status changes with their evidence, `per_lead_responses_expected`, `data_warnings`, and the results once Xcel's tracking reports them:

- `results`: aggregates (UpDash job, drops, `delivery_percent`, responses by channel, matched sales and repair orders, `leads_with_results`), with `source` and `simulated`; `null` until the first results arrive.
- `results_note`: one sentence saying where the results come from, or why there are none yet.
- `leads`: `items` (each with `external_id`, `row_key`, `responses`, `matches` and `updated_at`), `next_after` (pass it as `leads_after`; `null` on the last page) and `limit`. A match has `kind` (`sale` or `service`), `date`, `vehicle_type`, and `gross_cents` and `revenue_cents` (integer cents, `null` when the DMS has none).

Leads never carry a name or an address: join them to your records by `external_id`. A live order has results only after Xcel links it to its UpDash campaign; a sandbox order gets simulated results once `advance_test_campaign` reaches `in_postal_network` (the totals; responders per lead from `delivery_estimated`, matches at `completed`). Per-lead results are deleted 365 days (by default) after the order completes or is cancelled; `results` stays. See [Results and attribution](concepts.md#results-and-attribution).

### save_standing_order

One tool creates a standing order and changes one, as `upsert_dealer` does a dealer. Without `standing_order_id` it creates one, as `POST /v1/standing-orders` does: `dealer_id`, `name`, `product_code`, `creative` and `max_spend_cents` are required, and an answer that lacks some names them all. With `standing_order_id` it changes what the next run does, as `PATCH /v1/standing-orders/{id}` does: send only the fields to change, `null` to clear `approver_email`, `source_url` with `cadence`, `column_map`, `vehicle_source` or `inbound_subject`.

| Input | Type | Notes |
| --- | --- | --- |
| `standing_order_id` | string, optional | The standing order to change. Omit it to create one. |
| `dealer_id` | string | Create only. Xcel's dealer id or your external id. |
| `name` | string, 1 to 120 | Each run's campaign is named after it and the run's date. |
| `product_code` | string | Create only. An offered product. |
| `mail_class` | `first_class` or `marketing_mail`, optional | Create only. Defaults to the product's class: `first_class` for the postcard, `marketing_mail` for the letter and the fold card. |
| `creative` | object | `template_code` (Xcel's or your own `p_` code), `template_version`? (your own templates) and `copy`, as `generate_creative` takes them. Store details left out print from the dealer's profile. Checked by preflight for this dealer on save. |
| `max_spend_cents` | integer | The most one run may cost, in cents: a budget a person set in advance, never an estimate. A run whose quote is over it fails with `max_spend_too_low`. |
| `status` | `active` or `paused`, optional | Change only. `paused` stops new runs; `active` starts them again. |
| `approver_email` | email, optional | Live: one of the dealer's registered approvers; omit it when the dealer has exactly one. |
| `skip_mailed_within_days` | integer 0 to 730, optional | Default 90; `0` turns the skip off. |
| `submit_on_approval` | boolean, optional | Default `true`: an approved run's order submits itself. `false`: you call `submit_campaign`. |
| `source_url` | https URL, optional | Serves the current list as CSV whenever it is fetched. Answered without its query string. |
| `cadence` | object, optional | `{"every": "month", "day": 1-28}` or `{"every": "week", "weekday": 1-7}`. Send with `source_url`, or neither. |
| `column_map`, `vehicle_source` | optional | As `upload_audience` takes them. |
| `external_id` | string, optional | Create only. Your id for it, unique among your standing orders that are not ended. |
| `inbound_subject` | string, 1 to 200, optional | Take lists by email: the audience's title as the report's subject shows it ([Emailed lists](standing-orders.md#emailed-lists)). |
| `idempotency_key` | string, optional | Create only. A retry with the same key within 24 hours returns the first standing order. |

A change that sends `dealer_id`, `product_code`, `mail_class`, `external_id` or `idempotency_key` is refused with `invalid_request` naming it: they are set once. A create that sends `status` is refused the same way. Returns the standing order and `next_step`, plus `idempotent_replay` on a create.

### list_standing_orders

Inputs `dealer_id`?, `status`? (`active`, `paused` or `ended`), `external_id`?, `limit`? (1 to 100, default 25) and `starting_after`? (the previous page's `next_cursor`). Returns `standing_orders`, newest first, `has_more` and `next_cursor`, in your key's mode only.

### get_standing_order

Inputs `standing_order_id` and `runs_after`? (the previous call's `runs_next_cursor`). Returns the standing order, a page of its runs (the ten newest, or the ten after `runs_after`), `runs_next_cursor` (`null` on the last page) and `next_step`. Each run has its `status`, `trigger`, `counts`, `campaign_id`, `approval_id` and `error`; follow its order with `get_campaign_status`.

### end_standing_order

Input `standing_order_id`. Ends it: no run starts again, and its runs, their orders and its history stay. A run already waiting on its approver goes on, and its order submits only when you submit it. A second call answers the same. To stop for a while, save the standing order with `status: "paused"` instead.

### start_standing_order_run

| Input | Type | Notes |
| --- | --- | --- |
| `standing_order_id` | string | |
| `source_url` | https URL, optional | This run's list, fetched once (a public address, no redirects, at most 50 MB). Omit it to fetch the standing order's own `source_url`. |
| `column_map`, `vehicle_source` | optional | This run's own, in place of the standing order's. |

Runs as `POST /v1/standing-orders/{id}/runs` does with JSON ([Start a run](standing-orders.md#start-a-run)): it skips anyone the standing order mailed within its window, then builds the campaign, audience, creative, proof and quote and requests approval. Returns the run with its counts and the approval request: in the sandbox with `review_url` for the developer; live, the review link goes by email to the dealer's approver and is never returned. A run with nobody left to mail is `nothing_to_mail` and makes no order. A tool never takes the list's rows: send the CSV itself over REST (`Content-Type: text/csv`).

### get_dealer_inbound_email

Input `dealer_id`. Returns the dealer's address for emailed lists in your key's mode: `enabled`, `address`, `senders`, the standing orders that take email and their `inbound_subject`, and `pending_forwarding_confirmation` (a Gmail forwarding code) when one is waiting. The address is a secret: anyone who has it can email the dealer a list, so give it only to the person who sets up the report.

### update_dealer_inbound_email

| Input | Type | Notes |
| --- | --- | --- |
| `dealer_id` | string | |
| `enabled` | boolean, optional | `true` takes emailed lists (the first `true` gives the dealer its address); `false` refuses them and keeps the address. |
| `senders` | array, optional | Who may email lists: addresses or `@domain` entries, up to 50. Replaces the list. Empty allows any sender. |
| `rotate` | `true`, optional | A new address. The old one stops at once. |
| `idempotency_key` | string, optional | A retried rotation with the same key rotates once. |

Answers as `get_dealer_inbound_email` does, plus `idempotent_replay`. Where this server takes no email, turning the address on is `inbound_email_unavailable` (503).

### advance_test_campaign

| Input | Type | Notes |
| --- | --- | --- |
| `campaign_id` | string | A submitted sandbox order. |
| `to` | status, optional | The status to move to: a later one among `in_production`, `at_usps`, `in_postal_network`, `delivery_estimated` and `completed`. Omit it for the next one. The order only moves forward. |

Sandbox keys only. Moves a submitted sandbox order to its next production status (`in_production`, `at_usps`, `in_postal_network`, `delivery_estimated`, `completed`), or straight to `to`. From `in_postal_network` on, `get_campaign_results` returns simulated results (`simulated: true`), and responders per lead from `delivery_estimated`. Sandbox time runs as fast as you advance, so simulated dates follow the timeline, not the quote's `timing`. Nothing prints. A live key is refused with 403 `test_mode_only`; a campaign that is not in production with 409 `not_in_production`. Returns `campaign_id`, `from`, `status`, `status_label`, `status_evidence`, `simulated` and `results_simulated`, as REST `POST /v1/test/campaigns/{id}/advance` does. A submitted sandbox order's `next_step` names this tool.

## Results and errors

A successful call returns the JSON twice: as `structuredContent` and as JSON text without indentation in `content[0].text` (the same data in fewer tokens).

A failed call returns `isError: true` with the standard error body as text:

```json
{
  "isError": true,
  "content": [
    { "type": "text", "text": "{\"error\":{\"code\":\"approval_pending\",\"message\":\"The approval has not been decided yet.\",\"fix\":\"Wait for the approver. ...\",\"field\":\"approval_id\"}}" }
  ]
}
```

An argument that fails the tool's input schema gets the same body, not the MCP library's own validation text:

```json
{"error":{"code":"invalid_request","message":"name is required.","fix":"Send `name` and call create_campaign again. The tool's input schema (tools/list) gives each argument's type and limits.","field":"name"}}
```

An argument the tool does not take is refused the same way, never dropped:

```json
{"error":{"code":"invalid_request","message":"Unknown argument `send_date`: unknown arguments are refused, not ignored.","fix":"Send `requested_mail_date` instead of `send_date` (YYYY-MM-DD). Accepted: dealer_id, product_code, name, requested_mail_date, envelope, external_ref, metadata, idempotency_key. Then call create_campaign again.","field":"send_date"}}
```

More than one bad argument is listed at once in `issues`, and `field` stays the first. `message` and `fix` name every required argument left out, so one retry can send them all. An unknown argument is still reported on its own, before these:

```json
{"error":{"code":"invalid_request","message":"product_code and name are required.","fix":"Send `product_code` and `name` and call create_campaign again. The tool's input schema (tools/list) gives each argument's type and limits.","field":"product_code","issues":[{"field":"product_code","message":"Invalid input: expected string, received undefined"},{"field":"name","message":"Invalid input: expected string, received undefined"}]}}
```

A call past a [limit](api-reference.md#rate-limits) carries `retry_after_seconds`, the whole seconds until the limit resets, because an MCP client sees no HTTP headers. Wait that long before you call again, or tell the person when to try:

```json
{"error":{"code":"proof_render_rate_limited","message":"This dealer used its limit of 30 renders this UTC hour (...). The dealer limit resets at 2026-11-02T16:00:00.000Z.","fix":"Retry after 2026-11-02T16:00:00.000Z. ...","field":null,"retry_after_seconds":3600}}
```

Read `error.fix` and do what it says. See [Errors](errors.md) for every code.

Webhooks for events caused by an MCP tool that writes are tried right after the call, and a job every 5 minutes picks up the rest. A profile change reaches UpDash on the next push run (every 15 minutes); a REST request also tries it right away. See [Webhooks](webhooks.md#delivery-and-retries).

## Not available over MCP

Use REST with your API key for these (OAuth access tokens are valid only at `/api/mcp`, never on REST):

| Need | REST endpoint |
| --- | --- |
| Register or list webhooks | `POST /v1/webhooks`, `GET /v1/webhooks` |
| Read a template's layout regions and response boxes, or a saved template's stored HTML | `GET /v1/templates/{code}` (`get_template` gives the rest) |
| List a saved template's versions | `GET /v1/templates/{code}/versions` |
| Start an artwork upload (a signed PUT URL for a PDF, or one side's PNG or JPEG) | `POST /v1/artwork` (before a campaign) or `POST /v1/campaigns/{id}/creative/artwork`; then send its `artwork_id` to `preview_artwork`'s REST form or to `generate_creative` |
| Preview art by `artwork_id`, for a real dealer, or as a PDF body | `POST /v1/artwork/preview` |
| Read a dealer's profile versions | `GET /v1/dealers/{id}/profile/versions` |
| Replace a whole profile | `PUT /v1/dealers/{id}/profile` |
| Import dealers from a CSV | `POST /v1/dealers/import` |
| Read the account and its live readiness | `GET /v1/account` (`list_dealers` answers `ordering_enabled`) |
| Make, list or revoke keys limited to some dealers | `POST`, `GET /v1/keys`, `DELETE /v1/keys/{id}` |
| Find every campaign one shopper is on | `GET /v1/leads?external_id=` |
| Page a campaign's mailable rows | `GET /v1/campaigns/{id}/leads` |
| Read your events by time | `GET /v1/events` |
| Add to, read or clear a dealer's do-not-mail list | `POST`, `GET`, `DELETE /v1/dealers/{id}/suppressions` |
| Delete an audience version's files now | `DELETE /v1/campaigns/{id}/audience/{audience_id}` |
| Decide a sandbox approval from a script | `POST /v1/test/campaigns/{id}/approval` |
| Start a standing order run with the list itself as the body | `POST /v1/standing-orders/{id}/runs` with `Content-Type: text/csv` |

## Safety rules for agents

1. **No customer rows through chat or tools.** Upload the CSV to the signed URL. Never paste names, addresses or VINs into a prompt, a tool argument, `external_ref`, `metadata` or a reply. Results carry ids, counts, reason codes and row numbers only; do not try to reconstruct records from them. Name the record-id column `external_id` (or map it with `column_map`). Phone and email columns are optional, and useful: UpDash uses them to match responses and sales to the piece, and they are never printed or returned. Leave them out only if the user wants that.
2. **An agent cannot approve.** No tool approves an order, and nothing an agent says counts as approval. In live mode the review link goes only to the dealer's registered approver by email. In the sandbox, give `review_url` to the human developer; do not open it or submit its form yourself.
3. **Do not claim approval.** Tell the user the order is waiting for the approver until `get_campaign_status` shows `latest_approval.status: "approved"`.
4. **Brand values are locked in creatives.** Do not try to set the logo, colors, phone, dealer name or address in a creative request. Change them in the dealer profile, with the user's say-so. A sandbox key only validates changes to dealers it shares with the live key (`validated_only: true`): tell the user nothing was saved, and that the change needs a live key or the partner console in live mode. Name an approver only as the user names them. Disclosures and the FCRA notices are Xcel's; ask the user to contact Xcel.
5. **One idempotency key per order.** Generate it once, keep it, and reuse it only to retry the same `submit_campaign` call.
6. **Spend limits are the human's.** Set `max_spend_cents` to what the user told you, never higher and never your own estimate; if they gave no figure, ask. A figure a person set in advance, such as a dealer's budget in the system you work for, counts. The quote total alone does not. A quote total above it needs a new approval.
7. **USPS scan statuses are not delivery.** Do not tell a dealer that mail was delivered because the status is `at_usps`, `in_postal_network`, `delivery_estimated` or `completed`, or because of `delivery_percent`.
8. **Results are evidence, and the sales figures are the dealer's.** A match means a mailed customer bought or came in, not that the mail caused it; say so when you report results. `gross_cents` and `revenue_cents` are the dealer's confidential DMS figures: show them only to that dealer's people and the partner. Never present sandbox results (`simulated: true`) as real.
9. **Quote before you name a price.** Prices come from your price list and your volume tier; `get_quote` is the price of one order.
10. **Passing preflight is not legal approval.** The offer-disclosure and prescreen checks look for patterns. Do not tell anyone a piece is compliant, and do not invent credit terms or a firm offer; ask the user for them.
11. **Start in the sandbox.** Use an `xm_test_` key (or connect by OAuth with one) until the integration works end to end.
12. **Show links, not documents.** Give the person `preview_url` links to see a design. Do not paste HTML or base64 into the chat.
13. **Prescreened templates need a prescreened list.** Use a template with `requires_prescreened_list: true` only for a list from a consumer reporting agency, never for a CDP, CRM or DMS customer list. Never send a prescreened credit offer as artwork: preflight cannot read art.
14. **Store details come from the profile; dealer facts come from the person.** Leave the phone, hours, web address, QR link and signer out of copy unless the user gives a value: they print from the dealer's profile, and copying a sample (Demo Motors' phone, web address or signer) onto another dealer's piece is `sample_store_value`, an error on a live order. Ask the person for dealer facts (slots marked `dealer_fact`) and disclosure slots; never invent them.
15. **Keys stay out of the chat.** Never ask the person to paste an API key into the conversation. Connect by OAuth, where they paste it on Xcel's consent page, or have them set the header in the client's configuration themselves.
