# API reference

Every REST endpoint in one table, with its auth and retry behavior. The full request and response schemas are in [`/openapi.json`](../openapi.json) (OpenAPI 3.1).

## Conventions

- Base URL: `https://api.updash.com` (`$API`).
- Auth: `Authorization: Bearer xm_test_...` (sandbox) or `Bearer xm_live_...` (live) on every `/v1` request, or HTTP Basic with the key as the user name and an empty password (`curl -u "$KEY:"`, as on Lob and Stripe; a password is ignored). The key decides the partner and the mode.
- Bodies are JSON. Send `Content-Type: application/json`. An empty body counts as `{}`. Some endpoints also take a file: the asset uploads (a dealer's and the asset library's) and the logo upload (the image itself), and the dealer import, the audience import and the do-not-mail list (`text/csv`). Artwork files (a PDF, or one PNG or JPEG per side) are PUT to a signed storage URL, and an audience file can go that way too.
- Responses are JSON with `Cache-Control: no-store` and an `X-Request-Id` header. A template preview can instead answer with a PDF or an HTML document.
- Field names are snake_case. Money is integer cents (`total_cents`). Times are ISO 8601 UTC. Ids are UUIDs.
- Errors are `{"error":{"code","message","fix","field"}}`. See [Errors](errors.md). Every `/v1` path answers JSON, a path no endpoint serves included: it is 404 `not_found`, with no key needed ([Unknown paths](errors.md#unknown-paths)). A real path with a method it does not serve answers 405 `method_not_allowed` with an `Allow` header, also with no key needed; `OPTIONS` answers 204 with the same header.
- A body field or query parameter an endpoint does not declare is refused with 400 `invalid_request` naming it in `field`; nothing is ignored. The `fix` names the field meant for common names from Lob and other mail APIs (`send_date` to `requested_mail_date`, `merge_variables` to `copy`) and lists the fields the request takes. Endpoints without parameters (`GET /v1/campaigns/{id}`, `GET /v1/dealers/{id}`, `GET /v1/dealers/{id}/brand`, `GET /v1/webhooks`, `POST /v1/campaigns/{id}/proof`, `POST /v1/campaigns/{id}/creative/artwork`, `GET` or `POST /v1/campaigns/{id}/validate`, `POST /v1/templates/{code}/retire`, `DELETE /v1/webhooks/{id}`, `POST /v1/webhooks/{id}/rotate-secret`) refuse any. `GET /v1/templates/{code}` takes `?version=` for your own saved templates; Xcel's templates answer only their current version (400 `template_version_unavailable`).
- Lists of campaigns page with a cursor (`starting_after` = the previous page's `next_cursor`, while `has_more` is `true`); the dealer list pages with `after` = `next_after`. A cursor names a row of its list and has no expiry, so one saved earlier keeps working while the list holds that row. One from another list, or of a row the list no longer holds (a row key from before a new audience version), is refused with 400 `invalid_request`: read from the first page.
- A date query parameter (`since`, `until`, `created_after`, `created_before`, `updated_after`) is an ISO 8601 date-time with a time zone (`2026-11-05T14:00:00Z`) or a date (`2026-11-05`, midnight UTC). A time with no zone is refused, and the 400 names the format.
- `fix` and `next_step` name MCP tools because REST and MCP share their code. Over REST each one carries its route: `validate_campaign (POST /v1/campaigns/{id}/validate)`.
- `Idempotency-Key` is required on submit and on making a key, and optional on campaign create, template save, the dealer import, the audience import, the approval request and clearing a do-not-mail list ([Idempotency](concepts.md#idempotency)). A key starting `scoped:` is refused with 400 `invalid_request`.
- `{id}` for a dealer is Xcel's dealer id or your external id. `{id}` for a campaign is the campaign UUID.
- A key limited to some dealers answers 404 for any dealer outside its list, and for that dealer's campaigns, as another partner's do. Creating a dealer, the dealer import, saving or retiring a template, every webhook route and a change to a dealer's `links.website` answer 403 `dealer_scope_forbidden`. Your saved templates answer `unknown_template` to it: they need a key for every dealer ([Keys for one dealer](partners.md#keys-for-one-dealer)).
- Dealers your live key or Xcel created are shared by your test and live keys, so a test key's write to one only validates: it answers `"validated_only": true` and the header `X-Xcel-Validated-Only: true`, and saves nothing. See [Test keys only validate](dealers.md#test-keys-only-validate). A dealer a test key creates is a [test dealer](dealers.md#test-dealers): test mode only, and its writes save.

## Endpoints

| Method | Path | Purpose | Success | Safe to retry | Auth |
| --- | --- | --- | --- | --- | --- |
| GET | `/v1/products` | List the offered products, their specs and templates. Query: `detail=compact` for the short form MCP answers by default (no print specs; each template's code and name). | 200 | Yes | Any key |
| GET | `/v1/makes` | The make logo library: each make's `color`, `white` and `black` variants (PNG, and SVG for the one-color forms that trace true), which prints on light and on dark, and why ([Make logos](creative.md#make-logos)). Query: `dealer_id` for that dealer's makes. | 200 | Yes | Any key |
| GET | `/v1/makes/{make}/logo` | One make's logo file, `image/png` or `image/svg+xml`. Query: `variant` (`color`, `white`, `black`) or `tone` (`light`, `dark`), and `format` (`png`, `svg`). | 200 | Yes | Any key |
| GET | `/v1/templates` | List the templates of the offered products: Xcel's and your own saved templates ([Find a template](creative.md#find-a-template)). Query: `product_code`, `use_case`, `query`, `owner` (`xcel` or `partner`), `prescreened` (`true` or `false`), `source_audience` (your audience's ID or name: its templates first, with your account's audience map), `detail` (`compact`, the default, or `full` for every slot and the compliance rules). Compact entries of your own saved templates carry `version` and `saved_at`. Prescreened offers come after every other template unless `query` or `use_case` asks for credit. | 200 | Yes | Any key |
| POST | `/v1/templates` | Save your own template, or its next version ([Your own templates](creative.md#your-own-templates)). `Idempotency-Key` optional. | 201 (200 when unchanged) | Yes: the same content saves nothing; with the same `Idempotency-Key`, a replay | Any key; test and live keys share your templates |
| GET | `/v1/templates/{code}` | One template, with its use cases, audience columns, prescreen flag, formats, layout regions and response boxes (inches) and sample copy; for your own saved templates also `html` and `created_at`. Query: `version` (your own saved templates). | 200 | Yes | Any key |
| GET | `/v1/templates/{code}/versions` | A template's versions, newest first, without HTML: every version of your own (retired ones too), the current one of Xcel's. Query: `limit` (1 to 100, default 20), `before` (the previous page's `next_before`). | 200 | Yes | Any key |
| POST | `/v1/templates/{code}/retire` | Retire every version of your own saved template; creatives already made from it are unchanged. No body. Xcel's templates are 403 `template_read_only`. | 200 | Yes | Any key |
| POST | `/v1/templates/{code}/preview` | Render a template without a campaign: the review proof PDF, the proof page as HTML, or JSON with the preflight and a `preview_url` ([Preview a template](creative.md#preview-a-template)). Saves nothing. | 200 | Yes: nothing is saved, but each call counts against the render limit | Any key |
| GET | `/v1/dealers` | List or find your dealers, a page at a time, oldest first ([Read dealers](dealers.md#read-dealers)). Query: `limit` (1 to 200, default 50), `after` (the previous page's `next_after`), `query` (name or external id contains, ignoring case), `dealer_group` (the whole value, ignoring case). `total` counts every match. | 200 | Yes | Any key |
| POST | `/v1/dealers` | Create a dealer with its profile version 1 ([Dealers](dealers.md)). A test key creates a test dealer (test mode only, 25 per partner). | 201 | No: a repeat is 409 `external_id_taken` | Any key |
| POST | `/v1/dealers/import` | Upsert dealers from a CSV by `external_id`; one result per row. A test key creates test dealers and only validates rows for shared dealers. | 200 | Yes, with the same `Idempotency-Key` (optional) | Any key; `Content-Type: text/csv` |
| GET | `/v1/dealers/{id}` | One dealer, with the approvers you named. | 200 | Yes | Any key |
| GET | `/v1/dealers/{id}/approvers` | The registered approvers (masked) and the people you named, with their status ([Approvers](dealers.md#approvers)). | 200 | Yes | Any key |
| POST | `/v1/dealers/{id}/approvers` | Name an approver: `email`, optional `name`. Xcel emails them a confirm link. A test key only validates (200, nobody emailed). | 201 | No: naming the address again sends a new link and counts toward the daily limit | Live key emails; test key validates |
| GET | `/v1/dealers/{id}/brand` | What a new creative prints: name, address, logo, colors and phone from the profile; Xcel's disclosures and masked approvers. | 200 | Yes | Any key |
| GET | `/v1/dealers/{id}/profile` | The current profile, or `?version=N`. `ETag` is the version. | 200 | Yes | Any key |
| PUT | `/v1/dealers/{id}/profile` | Replace the profile. `If-Match` optional; a stale one is 412 `version_conflict`. | 200 | Yes: the same body twice changes nothing the second time | Live key writes; test key validates |
| PATCH | `/v1/dealers/{id}/profile` | Merge-patch the profile (RFC 7396). `If-Match` as for PUT. | 200 | Yes with `If-Match`; without, a repeat applies the same change again, which changes nothing | Live key writes; test key validates |
| GET | `/v1/dealers/{id}/profile/versions` | Versions newest first: `changed_fields`, `actor`, `created_at`. Query: `limit` (1 to 100), `before`. | 200 | Yes | Any key |
| POST | `/v1/dealers/{id}/logo` | Upload the `primary` or `reversed` logo: the file as the body, or JSON with `content_base64` or `url`. | 200 | Yes: the same file changes nothing | Live key writes; test key validates |
| GET | `/v1/dealers/{id}/assets` | The dealer's [creative assets](dealers.md#creative-assets). Query: `kind`. | 200 | Yes | Any key |
| POST | `/v1/dealers/{id}/assets` | Upload a signature or photo: the file as the body with `kind`, `label`, `name` and `title` in the query, or JSON with `content_base64` or `url`. | 201 new, 200 otherwise | Yes: the same file and details change nothing | Live key writes; test key validates |
| POST | `/v1/dealers/{id}/suppressions` | Add to the dealer's lasting do-not-mail list: the CSV as a `text/csv` body, or JSON with a `source_url` fetched once. Answers counts only: `rows_read`, `added`, `already_on_list`, `ignored` ([When a person asks](audiences.md#when-a-person-asks)). | 200 | Yes: a repeat adds nothing | Any key; each mode has its own list |
| GET | `/v1/dealers/{id}/suppressions` | The list's `count` and `last_changed_at`, never an entry. | 200 | Yes | Any key |
| DELETE | `/v1/dealers/{id}/suppressions` | Clear the list in this key's mode. Needs an `Idempotency-Key` or `?confirm=true`, else 400. | 200 | Yes | Any key |
| GET | `/v1/dealers/{id}/inbound-email` | The dealer's inbound address for emailed lists in this key's mode: `enabled`, `address` (a secret), `senders`, the standing orders that take email and any `pending_forwarding_confirmation` ([Emailed lists](standing-orders.md#emailed-lists)). | 200 | Yes | Any key; each mode has its own address |
| PUT | `/v1/dealers/{id}/inbound-email` | Turn the address on or off (`enabled`), set `senders`, or `rotate: true` for a new address. Send only the fields to change. | 200 | Yes; a retried rotation rotates once with the same `Idempotency-Key` (optional) | Any key; each mode has its own address |
| GET | `/v1/dealers/{id}/assets/{asset_id}` | One asset. | 200 | Yes | Any key |
| PATCH | `/v1/dealers/{id}/assets/{asset_id}` | Change its `label`, `name`, `title` or a signature's `department`. `If-Match` as for the profile. | 200 | Yes | Live key writes; test key validates |
| DELETE | `/v1/dealers/{id}/assets/{asset_id}` | Remove it: new creatives can no longer print it; creatives made with it keep what they printed. | 200 | No: a second is 404 | Live key writes; test key validates |
| GET | `/v1/dealers/{id}/offers` | The dealer's offers library, each with its status today ([Offers](dealers.md#offers)). | 200 | Yes | Any key |
| POST | `/v1/dealers/{id}/offers` | Add an offer: `name`, `department`, `offer`, and optional `detail`, `disclosure`, `starts_on`, `ends_on`. `If-Match` as for the profile. | 201 | No: a second is 409 `offer_name_taken` | Live key writes; test key validates |
| GET | `/v1/dealers/{id}/offers/{offer_id}` | One offer, by id or label. | 200 | Yes | Any key |
| PATCH | `/v1/dealers/{id}/offers/{offer_id}` | Change its fields; `null` clears an optional one. | 200 | Yes | Live key writes; test key validates |
| DELETE | `/v1/dealers/{id}/offers/{offer_id}` | Remove it: new creatives can no longer use it; creatives made with it keep what they printed. | 200 | No: a second is 404 | Live key writes; test key validates |
| GET | `/v1/assets` | Your [asset library](dealers.md#asset-library): photos any dealer prints by `{{asset.photo.<label>}}`, with `limit` and `can_change`. | 200 | Yes | Any key; shared by test and live |
| POST | `/v1/assets` | Add a photo: the file as the body with `name`, `label` and `description` in the query, or JSON with `content_base64` or `url`. The same label replaces its file. | 201 new, 200 otherwise | Yes: the same file and details change nothing | Any key for every dealer; shared by test and live |
| GET | `/v1/assets/{asset_id}` | One library photo. | 200 | Yes | Any key |
| PATCH | `/v1/assets/{asset_id}` | Change its `name`, `label` or `description`. | 200 | Yes | Any key for every dealer |
| DELETE | `/v1/assets/{asset_id}` | Remove it: new creatives can no longer print it; creatives made with it keep what they printed. | 200 | No: a second is 404 | Any key for every dealer |
| GET | `/v1/campaigns` | List campaigns for this key's partner and mode, newest first, a page at a time ([List campaigns](#list-campaigns)). Query: `dealer_id`, `status`, `external_ref`, `created_after`, `created_before`, `limit` (1 to 100, default 25), `starting_after` (the previous page's `next_cursor`). | 200 | Yes | Any key |
| POST | `/v1/campaigns` | Create a draft campaign. | 201 | Yes, with the same `Idempotency-Key` (optional); without one, each call creates a campaign | Any key |
| GET | `/v1/campaigns/{id}` | Status, counts, creative and approval state, `next_step`. Like every campaign object, the campaign carries `dealer_external_id`, `template_code` and `template_version`. | 200 | Yes | Any key |
| POST | `/v1/campaigns/{id}/audience/import` | Send the audience CSV and process it in one call: JSON with a `source_url` Xcel fetches once, or the CSV as a `text/csv` body. Answers as the completion does ([Import in one call](audiences.md#import-in-one-call)). | 201 | Yes, with the same `Idempotency-Key` (optional); without one, each call creates a version | Any key; JSON or `Content-Type: text/csv` |
| POST | `/v1/campaigns/{id}/audience` | Start an audience upload; returns the signed `upload_url`. | 201 | No: each call creates a version | Any key |
| POST | `/v1/campaigns/{id}/audience/complete` | Process the uploaded CSV, renaming columns by `column_map`; returns counts, the reconciliation report and `next_step`. | 200 | Yes: a repeat returns the stored result; a different `column_map` processes the file again ([Audiences](audiences.md#column-mapping-column_map)) | Any key |
| DELETE | `/v1/campaigns/{id}/audience/{audience_id}` | Delete one version's files now, with its proof PDFs; sets `purged_at`, and counts stay. 409 `audience_in_production` while it is the file of a submitted order not yet completed or cancelled. The current audience of an order not yet submitted leaves a `draft` with no audience ([Remove a list early](audiences.md#remove-a-list-early)). | 200 | Yes | Any key |
| POST | `/v1/campaigns/{id}/creative` | Fill a template with copy (or copy Claude writes from a `brief`), store your HTML, or store print-ready art: a PDF, or one PNG or JPEG per side (`artwork`, [Print-ready artwork](creative.md#print-ready-artwork)); returns preflight. | 201 | No: each call creates a version, and a `brief` spends AI copy calls | Any key |
| POST | `/v1/campaigns/{id}/creative/artwork` | Start an artwork upload for this campaign: a signed PUT URL valid for 2 hours for one PDF, or one side's PNG or JPEG, and the `artwork_id` that `generate_creative` takes. The file is kept 7 days. No body. REST only. | 201 | No: each call issues a new id (nothing is stored until the PUT) | Any key |
| POST | `/v1/artwork` | Start an artwork upload before a campaign exists (body `product_code`): the same answer, and an `artwork_id` that works for an artwork preview and for any of your campaigns in the key's mode, for 7 days ([Send it by signed upload](creative.md#send-it-by-signed-upload)). REST only. | 201 | No: each call issues a new id | Any key |
| POST | `/v1/artwork/preview` | Check print-ready art against a product without a campaign: the review proof PDF, or JSON with every issue, a `preview_url` and the `artwork_id` the art is kept as for 7 days ([Preview artwork](creative.md#preview-artwork)). Makes no campaign or creative. | 200 | Yes: each call counts against the render limit and keeps the file under a new `artwork_id` | Any key |
| POST | `/v1/campaigns/{id}/proof` | Render and check the proof, and print the review and print-ready PDFs where PDF rendering is on; moves `draft` to `proof_ready`. | 200 | Yes | Any key |
| GET or POST | `/v1/campaigns/{id}/validate` | Readiness checklist and every preflight issue, with `dealer_spend_cap_cents` and `dealer_spend_remaining_cents`; when the dealer has a cap and the order is not submitted, a `spend_cap` check that holds up `ready_for_approval` only ([Spend caps](concepts.md#spend-caps)). On a live order, `live_gaps` and the `approver`, `live_ordering` and `disclosures` checks say what approval or submit still lacks ([Going live](going-live.md)). Read-only. | 200 | Yes | Any key |
| POST | `/v1/campaigns/{id}/quote` | Quote the current creative and audience. The answer adds `dealer_spend_cap_cents` and `dealer_spend_remaining_cents` (null without a cap), and `next_step` says when the total is over what is left. | 201 | No: each call creates a quote | Any key |
| POST | `/v1/campaigns/{id}/approval` | Request human approval. Checks the dealer's spend cap first; the approver's approve and submit check it again. | 201 | Yes, with the same `Idempotency-Key`: no second email. Without one, no: each call expires the previous pending approval | Any key; `Idempotency-Key` optional |
| POST | `/v1/campaigns/{id}/submit` | Submit an approved campaign. | 201 | Yes, with the same `Idempotency-Key` | Any key; `Idempotency-Key` required |
| GET | `/v1/campaigns/{id}/results` | Timeline, quantities, result totals and a page of per-lead results ([Results and attribution](concepts.md#results-and-attribution)). Query: `leads_after` (the previous page's `leads.next_after`), `leads_limit` (1 to 500, default 100), `external_id` (one person's leads, exact), `updated_after` (leads whose results changed after this time). | 200 | Yes | Any key |
| GET | `/v1/campaigns/{id}/leads` | The current audience's mailable rows, ids only: `row_key`, `external_id`, `audience_version`, `result_status` and `usps`, the piece's USPS tracking ([Who was mailed](concepts.md#who-was-mailed)). Query: `external_id` (one shopper's rows, exact), `after` (the previous page's `next_after`), `limit` (1 to 500, default 100). | 200 | Yes | Any key |
| GET | `/v1/leads` | Every campaign one shopper is on, in this key's mode and dealers, newest first: `campaign_id`, `dealer_id`, `status`, `mailed`, `row_key` ([Who was mailed](concepts.md#who-was-mailed)). Query: `external_id` (required, exact), `dealer_id`, `limit` (1 to 100, default 50), `starting_after` (the previous page's `next_cursor`). | 200 | Yes | Any key |
| GET | `/v1/standing-orders` | List your [standing orders](standing-orders.md), newest first. Query: `dealer_id`, `status` (`active`, `paused`, `ended`), `external_id`, `limit` (1 to 100, default 25), `starting_after` (the previous page's `next_cursor`). | 200 | Yes | Any key |
| POST | `/v1/standing-orders` | Save a standing order: dealer, product, template creative, `max_spend_cents`, approver, skip window, optional `source_url` and `cadence`, optional `inbound_subject` for emailed lists ([Create a standing order](standing-orders.md#create-a-standing-order)). Checks the creative's preflight for the dealer. | 201 | Yes, with the same `Idempotency-Key` (optional); without one, each call saves another | Any key |
| GET | `/v1/standing-orders/{id}` | The standing order and its last ten runs. | 200 | Yes | Any key |
| PATCH | `/v1/standing-orders/{id}` | Change what the next run does, or pause and resume it. | 200 | Yes | Any key |
| DELETE | `/v1/standing-orders/{id}` | End it: no run starts again; its runs and history stay. | 200 | Yes: a second call answers the same | Any key |
| POST | `/v1/standing-orders/{id}/runs` | Start a run: the list as a `text/csv` body, or JSON `{"source_url"}` (`{}` for the order's own). Builds the campaign through to the approval request and answers the run, its counts and the approval ([Start a run](standing-orders.md#start-a-run)). | 201 | No: each call starts a run, and one builds at a time (409 `standing_order_run_in_progress`); people a run holds are skipped by the next | Any key |
| GET | `/v1/standing-orders/{id}/runs` | The runs, newest first. Query: `limit`, `starting_after`. | 200 | Yes | Any key |
| POST | `/v1/test/campaigns/{id}/approval` | Sandbox: approve or reject a pending approval from a script, with every check of the review page. Not an MCP tool. | 200 | No: a second call answers `approval_already_decided` | Test keys only |
| POST | `/v1/test/campaigns/{id}/advance` | Sandbox: move a submitted campaign to the next status, or to `to`. MCP: `advance_test_campaign`. | 200 | No: each call moves it again | Test keys only |
| GET | `/v1/events` | Your events in this key's mode, oldest first, in the webhook envelope ([Reconcile a window you missed](webhooks.md#reconcile-a-window-you-missed)). Query: `since`, `until` (a date-time or date; `until` is exclusive), `dealer_id` (Xcel id or your external id), `type`, `limit` (1 to 100, default 50), `starting_after` (the previous page's `next_cursor`). | 200 | Yes | Any key |
| GET | `/v1/webhooks` | List this mode's webhook endpoints with each one's latest delivery and the active-endpoint limit (no secrets). | 200 | Yes | Any key |
| POST | `/v1/webhooks` | Register a webhook endpoint; returns its secret once. | 201 | No: each call registers another endpoint | Any key |
| DELETE | `/v1/webhooks/{id}` | Deactivate an endpoint and cancel its pending deliveries. 404 for another partner's or mode's endpoint. | 200 | Yes | Any key |
| POST | `/v1/webhooks/{id}/rotate-secret` | Replace the signing secret; returns the new one once. | 200 | No: each call issues a new secret | Any key |
| GET | `/v1/webhooks/event-types` | Every event type you can subscribe to, with what it says, and the test event. | 200 | Yes | Any key |
| POST | `/v1/webhooks/{id}/test` | Send a signed test event now and report what the endpoint answered. Stores nothing. 429 `webhook_test_rate_limited` past 20 per hour. | 200 | Yes: each call sends another test event | Any key |
| GET | `/v1/webhooks/{id}/deliveries` | One endpoint's deliveries, newest first (`limit`, `offset`). Never the body. | 200 | Yes | Any key |
| POST | `/v1/webhooks/{id}/deliveries/{delivery_id}/replay` | Queue a past delivery to send again, with its original event id. | 202 | Yes | Any key |
| POST | `/v1/keys` | Make a key limited to the dealers in `dealer_ids`, in this key's mode ([Keys for one dealer](partners.md#keys-for-one-dealer)). The secret comes back once. | 201 | Yes, with the same `Idempotency-Key`: the same key's id with `key: null` | Key for every dealer; `Idempotency-Key` required |
| GET | `/v1/keys` | This mode's keys, with each limited key's dealers, never a secret. Query: `limit` (1 to 200, default 100), `after` (the previous page's `next_after`). | 200 | Yes | Key for every dealer |
| DELETE | `/v1/keys/{id}` | Revoke a limited key at once. A key for every dealer answers 403 `key_for_every_dealer`. | 200 | Yes | Key for every dealer |
| GET | `/v1/account` | Who this key acts for, whether live ordering is on, what a live order still lacks, and your limits ([Account](#account)). | 200 | Yes | Any key |
| Any | Any other `/v1` path | 404 `not_found` in the standard error shape, with a `fix` that names where the job lives ([Unknown paths](errors.md#unknown-paths)). | 404 | Yes | None |
| GET | `/v1/health` | Liveness for an uptime monitor: `status` and `version`, no data. With `?deep=1` and Xcel's health token it also times a database query and a storage read, and answers 503 if either fails. | 200 or 503 | Yes | None; deep checks need the health secret |

## Request bodies

| Endpoint | Body |
| --- | --- |
| `POST /v1/templates` | `code` (required), `product_code` (required), `name` (required, 1 to 80), `description` (required, 1 to 2,000), `html` (required, at most 200,000), `slots` (required, at most 60, each with `name`, `kind` and `max_length`, and optional `label`, `required`, `sample`, `default`, `dealer_fact` and `description`), `use_cases` (optional, at most 12); header `Idempotency-Key` optional. See [Your own templates](creative.md#your-own-templates). |
| `POST /v1/templates/{code}/preview` | All optional: `template_version` (your own saved templates), `copy` (object of strings; slots you leave out print their samples, or with `dealer_id` the dealer's own store details, and with `dealer_id` and any copy, optional slots you leave out print their default or nothing, listed in the answer's `omitted_slots`), `dealer_id` (one of your dealers; default the sample dealer Demo Motors), `recipient` (one audience row; default a fictional sample recipient), `envelope` (letter templates only: `closed_face` adds the envelope face as the last page; a fold card always shows its closed face), `format` (`pdf`, `html` or `json`). |
| `POST /v1/campaigns` | `dealer_id` (required), `product_code` (required, an offered product), `name` (required, 1 to 120), `requested_mail_date` (`YYYY-MM-DD`, at most 180 days out), `envelope` (a fold card takes only `closed_face`; the letter: `closed_face`, the default, or `double_window`; see [A letter's envelope](concepts.md#a-letters-envelope)), `external_ref` (1 to 100), `metadata` (up to 20 string values; see [Your reference on a campaign](concepts.md#your-reference-on-a-campaign)); header `Idempotency-Key` optional. The body is checked first, so a bad body is refused before the key is looked at. |
| `POST /v1/artwork` | `product_code` (required, an offered product). |
| `POST /v1/artwork/preview` | `product_code` (required), `artwork` (required, as for `POST .../creative`; an `artwork_id` from `POST /v1/artwork`), `dealer_id` (optional; default the sample dealer Demo Motors), `format` (`pdf` or `json`). |
| `POST .../audience/import` | JSON: `source_url` (required, https, at most 4,000 characters; never stored or logged), `column_map` and `vehicle_source` (optional, as on the completion). Or the CSV itself with `Content-Type: text/csv` (at most 4.5 MB), with `column_map` as URL-encoded JSON and `vehicle_source` in the query. Header `Idempotency-Key` optional. |
| `POST .../audience` | `include_suppression_list` (boolean), optional |
| `POST /v1/dealers/{id}/suppressions` | JSON: `source_url` (required, https, at most 4,000 characters; never stored or logged). Or the CSV as the body with `Content-Type: text/csv`: `address1` and `zip`, with optional `first_name`, `last_name` and `address2`. |
| `POST .../audience/complete` | `audience_id` (required), `column_map` (optional: your header to our column, at most 100 entries; see [Column mapping](audiences.md#column-mapping-column_map)), `vehicle_source` (optional: `owned`, `sold` or `serviced`; see [A CDP export as it comes](audiences.md#a-cdp-export-as-it-comes)) |
| `POST .../creative` | `template_code`, `html` or `artwork` (exactly one), `template_version` (optional, with `template_code`, your own saved templates), `copy` (object of strings), `brief` (optional, template only: `goal` and `offer` required, `tone`, `audience`, `offer_terms`; Claude writes the slots `copy` leaves out, see [AI-written copy](creative.md#ai-written-copy)). `artwork`: one PDF as `url` (https, at most 2,000 characters) or `artwork_id` (from `POST .../creative/artwork`, `POST /v1/artwork` or an artwork preview), exactly one; or `front` and `back`, each `{"url"}` or `{"artwork_id"}` of a PNG or JPEG (a letter's front is page 1); not with `copy` or `brief` ([Print-ready artwork](creative.md#print-ready-artwork)). |
| `POST .../quote` | `mail_class`: `first_class` or `marketing_mail`, optional; absent, the product's default (`first_class` for the postcard, its only class; `marketing_mail` for the letter and the fold card) |
| `POST .../approval` | `quote_id` (required), `max_spend_cents` (required, at least the quote total: the figure the user gave), `approver_email`. Header `Idempotency-Key` optional. |
| `POST .../submit` | `approval_id` (required); header `Idempotency-Key` (required). The body is checked first, so a bad body is refused before the key is looked at. |
| `POST /v1/test/campaigns/{id}/approval` | `approval_id` (required), `decision` (required: `approve` or `reject`), `note`; on a prescreened offer, `prescreen_confirm` and `prescreen_list_date` |
| `POST /v1/test/campaigns/{id}/advance` | `to`: a later status among `submitted`, `in_production`, `at_usps`, `in_postal_network`, `delivery_estimated`, `completed`; optional |
| `POST /v1/webhooks` | `url` (required, a public host; `https` for live keys, `https` or `http` for sandbox keys), `event_types` (array; empty or omitted means all) |
| `POST /v1/dealers` | `external_id` (required, 1 to 100), `profile` (required: `name` and `address`, and any other [profile field](dealers.md#the-profile)) |
| `PUT .../profile` | The whole profile, as `GET .../profile` returns it in `profile`. Header `If-Match` optional. |
| `PATCH .../profile` | Only the fields to change; `null` clears one. Header `If-Match` optional. |
| `POST .../logo` | The file with `Content-Type` `image/png`, `image/jpeg` or `image/svg+xml` and `?variant=primary` or `reversed`; or JSON `variant`, and exactly one of `content_base64` and `url`. At most 3 MB. Header `If-Match` optional. |
| `POST /v1/keys` | `label` (required, 1 to 120), `dealer_ids` (required, 1 to 100, by Xcel id or your external id). Header `Idempotency-Key` required. |
| `POST /v1/dealers/import` | A CSV with an `external_id` column ([columns](dealers.md#import-a-csv)), at most 500 rows and 1 MB. Header `Idempotency-Key` optional. |

## Response headers

| Header | When |
| --- | --- |
| `X-Request-Id` | Every `/v1` response. Quote it when you report a problem. |
| `Idempotent-Replayed: true` | A campaign create, template save, submit, dealer import, audience import, approval request or key create answered from the stored result of an earlier identical request. |
| `ETag: "3"` | Dealer creation, and every profile read, write and logo upload: the profile version. Send it back as `If-Match`. A test key's validate-only write answers with the version that is still current; its creation answers with no ETag. |
| `X-Xcel-Validated-Only: true` | A dealer write with a test key: checked, nothing saved. |
| `X-Xcel-Preflight-Ok` (`true` or `false`), `X-Xcel-Preflight-Errors`, `X-Xcel-Preflight-Warnings`, `X-Xcel-Template-Version`, and `X-Xcel-Handwriting-Note` when the piece has a `data-hand` note | A template preview answered as a PDF or HTML. `X-Xcel-Preflight-Ok` is `false` when preflight found an error. The errors and warnings are comma-separated issue codes, each once, empty when there are none. `format=json` gives every issue with its fix. |
| `X-Xcel-Preview-Url` | A template preview answered as a PDF or HTML: the [preview link](creative.md#preview-links) a person can open for an hour. Absent when the copy is too long for a link. |
| `WWW-Authenticate: Bearer realm="xcel-mail-api"` | Every `/v1` 401. The MCP endpoint's 401 adds `resource_metadata` and `scope` for OAuth clients; see [MCP server](mcp.md#endpoint-and-auth). |

## Other routes

These are not part of the partner REST API, but they run on the same host:

| Route | Who uses it | Auth |
| --- | --- | --- |
| `/api/mcp` and `/mcp`, the same server (POST, GET, DELETE) | MCP clients. See [MCP server](mcp.md). | The partner API key or an OAuth access token as a bearer token |
| `GET /.well-known/oauth-protected-resource` (also `.../oauth-protected-resource/api/mcp`, and `.../oauth-protected-resource/mcp`, which names `/mcp` as the resource), `GET /.well-known/oauth-authorization-server` | MCP clients discovering OAuth (RFC 9728, RFC 8414). See [MCP server](mcp.md#connect-by-oauth). | None |
| `POST /oauth/register`, `GET` and `POST /oauth/authorize`, `POST /oauth/token`, `POST /oauth/revoke` | MCP clients and the person consenting. OAuth access tokens work only at `/api/mcp` and `/mcp`, never on `/v1`. | Public clients with PKCE; the consent page takes a partner API key in a same-origin form |
| `GET /preview/{token}` (`?format=pdf` for the PDF) | A person opening a template preview link from `preview_url`. See [Preview links](creative.md#preview-links). | The signed token in the link; it lasts one hour |
| `GET /preview/artwork/{token}` | A person opening an artwork preview link from `preview_url`: the review proof PDF. See [Preview artwork](creative.md#preview-artwork). | The signed token in the link; it lasts one hour |
| `/review/{token}`, `GET /review/{token}/proof.pdf` and `POST /review/{token}/decision` | The human approver. `proof.pdf` serves the PDF review proof inline (the review page frames it; `?download=1` saves it). See [Quotes and approvals](quotes-and-approvals.md#the-review-page). | The token in the link; same-origin form posts only |
| `/console` and `/console/...` | Your own staff, in the [partner console](console.md). Pages and form posts only; it has no JSON API. | A session cookie from an email address and password; same-origin form posts only |
| `GET /status` | Anyone: a page with the health check's answer now. It keeps no history. | None |
| `/openapi.json`, `/mcp-tools.json`, `/llms.txt`, `/llms-full.txt`, `/docs/*.md` | Anyone | None |

## Account

`GET /v1/account` answers without a refused submit:

```json
{
  "partner": { "id": "...", "name": "Larkspur Data" },
  "api_version": "...",
  "mode": "live",
  "dealer_ids": null,
  "ordering_enabled": false,
  "audience_map": null,
  "live_readiness": {
    "ready": false,
    "ordering_enabled": false,
    "live_dealers": 3,
    "live_dealers_more": false,
    "dealers_with_registered_approver": 0,
    "approvers_waiting_on_xcel": 3,
    "approvers_waiting_to_confirm": 0,
    "live_webhook_endpoints": 1,
    "gaps": [{ "code": "ordering_disabled", "blocks": "submit", "owner": "xcel", "detail": "...", "fix": "..." }],
    "guide": "/docs/going-live.md"
  },
  "limits": { "renders_per_dealer_per_hour": 30, "renders_per_partner_per_hour": 300, "ai_copy_per_dealer_per_day": 200, "ai_copy_per_partner_per_day": 2000, "webhook_endpoints_per_mode": 5 },
  "next_step": "..."
}
```

`dealer_ids` is `null` for a key that reaches every dealer. For a key limited to some dealers it lists them, every count in `live_readiness` covers only those dealers, `live_webhook_endpoints` is 0, because such a key cannot use webhooks, and `limits.renders_per_partner_per_hour` and `limits.ai_copy_per_partner_per_day` are `null`, because the partner's ceilings count your other dealers ([Keys for one dealer](partners.md#keys-for-one-dealer)).

`audience_map` names the audience map Xcel loaded for your platform, or is `null`: with one, `source_audience` on `GET /v1/templates` leads with the templates for your audience ([Find a template](creative.md#find-a-template)).

MCP has no tool for it: `list_dealers` answers `ordering_enabled`, and `validate_campaign` says what one order lacks.

## List campaigns

`GET /v1/campaigns` (MCP: `list_campaigns`) returns this key's campaigns only (its partner and its mode), newest first by creation time, then id.

| Query | Meaning |
| --- | --- |
| `dealer_id` | One dealer's campaigns: the Xcel dealer id or your external dealer id. An unknown dealer, or one outside a limited key's list, is 404 `not_found` with `field: "dealer_id"`. |
| `status` | One status (`draft`, `proof_ready`, `awaiting_approval`, ...). |
| `external_ref` | Campaigns created with this `external_ref`, exact match. |
| `created_after`, `created_before` | Creation time, exclusive. An ISO 8601 date-time with a time zone (`2026-11-01T14:00:00Z`, `2026-11-01T09:00:00-05:00`) or a date (`2026-11-01`, meaning midnight UTC). |
| `limit` | 1 to 100, default 25. |
| `starting_after` | The `next_cursor` of the previous page, unchanged. |

The response is `{ "campaigns": [...], "has_more": true, "next_cursor": "..." }`. Each entry is the campaign object, so it names the dealer by both ids (`dealer_id`, `dealer_external_id`) and the template its current creative prints (`template_code`, `template_version`; `null` before the first creative and for your own HTML or print-ready art). To read the next page, send the same filters with `starting_after` set to `next_cursor`. On the last page `has_more` is `false` and `next_cursor` is `null`. The cursor is opaque: do not build or change it; anything else is 400 `invalid_request` with `field: "starting_after"`. Without parameters the endpoint answers the newest 25.

Find the order you know as `cmp_778`:

```bash
curl -s -H "Authorization: Bearer $KEY" "$API/v1/campaigns?external_ref=cmp_778"
```

## Rate limits

REST and MCP calls are not rate-limited in Phase 1. Renders and AI copy are, per dealer with a ceiling for the partner, so one busy dealer cannot stop your other dealers:

| What counts | Per dealer | Per partner, across its dealers | Past it |
| --- | --- | --- | --- |
| Renders: `render_proof`, template previews and artwork previews, every format | 30 per UTC hour | 300 per UTC hour | 429 `proof_render_rate_limited` |
| AI copy: model calls for a creative `brief` (a repair counts as a call) | 200 per UTC day | 2,000 per UTC day | 429 `ai_copy_rate_limited` |

- Sandbox and live count together, so heavy sandbox testing uses the same hour's renders as live proofs.
- A render or a brief counts against its dealer and the partner: the campaign's dealer, or the dealer a preview names with `dealer_id`. A preview without `dealer_id` (Demo Motors) counts against the partner only, or, for a key limited to some dealers, against the first of its dealers too.
- Opening a [preview link](creative.md#preview-links) counts nothing. A link renders once per format, on its first opening, and every opening serves that render, so a chat app unfurling the link costs no render.
- A request refused before rendering (400, 404) counts nothing.
- The 429 names the limit (dealer or partner), its number and when it resets: the next UTC hour for renders, midnight UTC for AI copy. Its `fix` says what to do; past a dealer limit, your other dealers carry on. A key limited to some dealers shares the partner's ceiling, with no budget of its own. When it reaches that ceiling it gets the same code with no figures: only when to retry, in `Retry-After` and `retry_after_seconds`, and no `X-RateLimit-*` headers.
- Xcel can raise one partner's numbers, which matters when one campaign goes to many stores at once. Ask your Xcel contact. `GET /v1/account` shows the numbers that apply to you.

Every 429 carries these headers, with one exception: a key limited to some dealers gets `Retry-After` alone when the partner's ceiling refuses it, so it learns nothing about the partner's other dealers. They come only on a 429: a call that succeeds has none of them.

| Header | Meaning |
| --- | --- |
| `Retry-After` | Whole seconds until the limit resets, at least 1. |
| `X-RateLimit-Limit` | The number of the limit that refused the call. |
| `X-RateLimit-Remaining` | `0`. |
| `X-RateLimit-Reset` | When the limit resets, in unix seconds. |

The error body also has `retry_after_seconds`, the same number as `Retry-After`, so an MCP client, which sees no headers, gets it too:

```json
{
  "error": {
    "code": "proof_render_rate_limited",
    "message": "This dealer used its limit of 30 renders this UTC hour (render_proof, template previews and artwork previews together, sandbox and live together). The dealer limit resets at 2026-11-02T16:00:00.000Z.",
    "fix": "Retry after 2026-11-02T16:00:00.000Z. Render a proof once the creative and audience are final. The partner's other dealers can still render. To raise it for this partner, ask Xcel.",
    "field": null,
    "retry_after_seconds": 3600
  }
}
```

Other limits: webhook test events and replays and approver emails per dealer ([Errors](errors.md)), the OAuth endpoints' client registration, consent attempts and metadata fetches ([Security](security.md#oauth-for-the-mcp-endpoint)), and the [partner console](console.md#sign-in)'s sign-in requests and approval-link resends. A 429 from any of them carries the same headers; one from `POST /oauth/register` has `retry_after_seconds` in the OAuth error body, and the consent page has the headers only. Poll `GET /v1/campaigns/{id}` no more than about once a minute, or register a [webhook](webhooks.md).
