# Running many dealers

For a platform that orders mail for many dealers: a CDP, an agency or an agent operator. This page gathers the rules from [Dealers](dealers.md), [Going live](going-live.md), [Concepts](concepts.md), [Audiences](audiences.md) and [Webhooks](webhooks.md), and says what is still done by hand.

## One partner, many dealers

Your company is one **partner**. You hold one set of API keys, and a key works for all your dealers unless you limit it to some of them ([Keys for one dealer](#keys-for-one-dealer)).

- The key decides the partner and the mode. Nothing in a request can change either. Another partner's dealer answers 404.
- A campaign is one mailing for one dealer and one product. A promotion across 100 stores is 100 campaigns, each with its own audience, proof, quote and approval. No call makes them in one request.
- Your staff use the [partner console](console.md) on the same dealers. An admin can limit a member or viewer to some dealers ([Roles](console.md#roles)).

## Keys for one dealer

A key can be limited to some of your dealers, so one dealer's marketer, or an agent working for that dealer, holds a credential that reaches only that dealer. A key without a limit reaches every dealer, as it always has. Nothing about it changes.

Make one in the [partner console](console.md#developers): **Developers**, **API keys**, then tick the dealers. Or make one over REST, with a key for every dealer in the same mode, so each of hundreds of stores can hold its own:

```bash
curl -s -X POST "$API/v1/keys" -H "Authorization: Bearer $KEY" -H "Idempotency-Key: store-key-40117" \
  -H "Content-Type: application/json" -d '{"label": "Store 40117", "dealer_ids": ["40117"]}'
```

The answer has the secret once, in `key`, and only its hash is kept. `dealer_ids` is required, so `POST /v1/keys` cannot make a key for every dealer: those stay in the console. `Idempotency-Key` is required too, since a retry must not make a second key. No stored answer holds a secret, so a retry with the same key and body answers the same key's `id` with `key: null` and `Idempotent-Replayed: true`. If the first answer was lost, revoke that key and make another with a new `Idempotency-Key`.

`GET /v1/keys` lists this mode's keys, revoked ones too, with each limited key's `dealer_ids`, and never a secret. `DELETE /v1/keys/{id}` revokes a limited key at once, with every MCP connection made from it. A key for every dealer is revoked in the console only, so one leaked key cannot lock out the others. A limited key gets 403 `dealer_scope_forbidden` on all three. MCP has no tool for them. Each make and revoke goes in your audit log with the acting key's id, never the secret.

**At most 1,000 active limited keys per partner and mode, and 10 active keys for every dealer.** Neither counts against the other. Past either, 409 `key_limit_reached`.

A key's dealers are set when it is made and never change: to change them, make a new key and revoke the old one. A key lists 1 to 100 dealers, all yours, and a live key cannot list a test dealer. `GET /v1/account` says which dealers a key reaches in `dealer_ids`, or `null` for every dealer.

A dealer outside the list answers exactly as another partner's dealer does: 404 `not_found`, never a 403 that would confirm it exists. A partner-wide action answers 403 `dealer_scope_forbidden`.

| Area | What a limited key does |
| --- | --- |
| Campaigns | Creates, reads and acts only for its dealers. `GET /v1/campaigns` lists only those. Results, leads, proof, quote, approval, submit, audience, creative and the sandbox routes follow the same check. |
| Dealers | Lists and reads only its dealers, and updates only those, with their profile, assets, logo and approvers. It cannot change a dealer's website: see below. |
| Events | `GET /v1/events` returns only its dealers' events. An event that names no dealer is left out. |
| Account | `GET /v1/account` counts only its dealers, so it says nothing about your others. `live_webhook_endpoints` is 0, and the partner's ceilings in `limits` are `null`. |
| Templates | Reads and previews Xcel's templates. **A saved template needs a key for every dealer:** it holds free HTML that may have been written for any of your dealers, so to a limited key it answers `unknown_template`, as a code nobody saved does, in the list, on read, versions, preview and `generate_creative`. A preview naming a dealer outside the list answers 404. A preview with no dealer prints the sample dealer. |
| Approvers | Names them for its dealers, but every one goes to Xcel's review after they confirm, whatever the address. The answer says so, and `domain_match` reads only that dealer's own website. |
| Artwork | Art on a campaign follows the campaign. Art uploaded without a campaign stays open, because it names no dealer, but it belongs to that key and its list of dealers: see below. |
| Rate limits | The same limits. **A limited key shares your partner's hourly ceiling:** there is no budget per key. At the default limits, a key with ten dealers can spend all 300 renders an hour, 30 for each dealer by naming it in a preview, and your other dealers then wait for the next hour. A preview with no dealer counts against the first of its dealers. At your partner's ceiling its 429 says only that renders are paused, with `Retry-After` and no figures, and how soon that 429 comes depends on what your other dealers rendered. |

A limited key **cannot**:

- Create a dealer, by `POST /v1/dealers`, `upsert_dealer` or the CSV import.
- Change a dealer's website. Approver domain matching reads it, so `links.website` answers 403 `dealer_scope_forbidden`, naming the field, by `PUT` or `PATCH` of the profile, `update_dealer_profile` or `upsert_dealer`. A `PUT` replaces the whole profile, so send the website on file: leaving it out clears it, and that is refused too. Everything else on the dealer's profile stays open.
- Use webhooks. Every webhook route answers 403, because an endpoint receives your whole partner's events and holds a signing secret. Keep your endpoints on a key for every dealer: events from a limited key's orders reach them as usual.
- Read, preview, print, save or retire a saved template.
- Read an artwork upload made by any other credential, or let any other credential read its own. Two OAuth connections narrowed to different dealers do not share uploads either. Another's `artwork_id` answers 409 `artwork_not_uploaded`, the same as an id nobody uploaded. To share art, send it as a URL.
- Reach the sample dealer as a dealer, unless it is on the list.

Three more things differ from a key for every dealer:

- **Retries.** An `Idempotency-Key` belongs to the dealers of the key that sent it. A limited key never replays or collides with an answer another key stored about other dealers, so retry from the key that sent the request, or one with the same dealers. No key may start with `scoped:`, the prefix of that namespace.
- **External ids.** An external id you reuse for a test dealer names the shared dealer first. If that shared dealer is outside the list, use the test dealer's Xcel id.
- **Lists.** `dealer_id=` naming a dealer outside the list answers 404, as an unknown dealer does, and returns no rows. A cursor from another key's walk returns only this key's rows, and `after` naming a dealer outside the list answers 400, as another partner's dealer does.

A review link and a preview link carry their own token and need no key. A limited key's preview link prints only a dealer it reaches, and stops when the key is revoked.

An agent connecting by OAuth gets what the key reaches, and can be narrowed further on the consent page ([MCP server](mcp.md#a-key-limited-to-some-dealers)). Limiting a key does not change who approves: a person at the dealership still approves every live order, and an approver a limited key names is registered only after Xcel's review.

## Use your own ids

Join everything to your records with your own ids.

| Field | Names | Rules | Comes back on |
| --- | --- | --- | --- |
| `external_id` on a dealer | The store | 1 to 100 printable characters, unique among your dealers (test dealers apart). It works anywhere a request takes a dealer id. A duplicate answers 409 `external_id_taken`. | Every campaign object, results and campaign webhook as `dealer_external_id`; `dealer.updated` as `external_id`. |
| `external_ref` on a campaign | The order | 1 to 100 characters, not unique, set once on create. | Every campaign object, results and campaign webhook. `GET /v1/campaigns?external_ref=` finds the order. |
| `metadata` on a campaign | Your labels | Up to 20 keys, each value a string of up to 500 characters, set once on create. | Every campaign object, results and campaign webhook. |
| `external_id` in an audience row | The person | At most 128 characters, opaque. Name your column `external_id`, or map it with [`column_map`](audiences.md#column-mapping-column_map). | Per-lead results and `campaign.lead_results_updated`, beside the row key. |

Never put customer data in any of these: no names, addresses, emails, phone numbers or VINs. `external_ref` and `metadata` are stored with the order, outside the audience file's retention. An audience `external_id` that looks like an email address or a formatted phone number is blanked at intake.

## Load dealers from a CSV

`POST /v1/dealers/import` with `Content-Type: text/csv` upserts dealers by `external_id`. [Import a CSV](dealers.md#import-a-csv) lists every column.

```csv
external_id,name,address_line1,city,state,zip,phone_main,website,makes,time_zone
store-1042,Lakeside Ford,1 Lake Rd,Boston,MA,02134,6175550100,https://lakeside.example.com,Ford;Lincoln,America/New_York
store-1043,Hillcrest Toyota,200 Hill St,Albany,NY,12207,5185550100,https://hillcrest.example.com,Toyota,America/New_York
```

```bash
curl -s -X POST "$API/v1/dealers/import" \
  -H "Authorization: Bearer $KEY" -H "Content-Type: text/csv" \
  -H "Idempotency-Key: $(uuidgen)" --data-binary @dealers.csv
```

- A row for a new `external_id` creates the dealer. It needs `name`, `address_line1`, `city`, `state` and `zip`.
- A row for an existing dealer merges its non-empty cells. An empty cell leaves that field as it is.
- A file holds at most 500 rows (413 `import_too_large`) and 1 MB (413 `payload_too_large`). Split a longer roster.
- Hours, hours exceptions and logos are not in the CSV. Set them per dealer: `PATCH /v1/dealers/{id}/profile` and `POST /v1/dealers/{id}/logo`.
- A column Xcel manages, or an unknown or repeated column, refuses the whole file.
- The answer has totals and one result per row. Read `results` for rows with `"status": "failed"`.
- With a live key, new rows create real dealers. With a test key, they create [test dealers](#test-dealers), and rows for dealers your live key made only validate (`"validated_only": true`).

## Who approves

A person at the dealership approves every live order, on a review page Xcel emails them. No API key, MCP tool or console role can approve. You name each dealer's approver with `POST /v1/dealers/{id}/approvers`, and they confirm by email ([Approvers](dealers.md#approvers)). The confirm link works once, for 7 days.

| The address they confirm | Result |
| --- | --- |
| At the dealer's website domain (`links.website` in its profile) | `registered` at once, unless that website moved from another domain in the last 30 days. Then `pending_xcel_review`. |
| At a dealer-group domain Xcel listed for you | `registered` at once. |
| Anything else, or a common free mail service | `pending_xcel_review`: Xcel checks it with the dealership, then registers or declines it. No timing is promised. |

- For stores under a group, ask Xcel to list the group's domains before you name people.
- Tell each person first. The email comes from UpDash and names your company and the dealer.
- A dealer can have three invitations waiting (409 `approver_invitations_pending_limit`) and five approver emails in one UTC day (429 `approver_invite_rate_limited`).
- Every change of status sends `dealer.updated` with `changed_fields: ["approvers"]` and `approver_invitation`.
- A new dealer is not `live_ready` until an approver is registered. Until then, a live `request_approval` or submit answers 409 `no_registered_approver`.
- To remove an approver, ask Xcel.

## What you keep and what Xcel sets

| You keep | How |
| --- | --- |
| The profile: name, address, phones, hours, links, makes, colors, contact and the rest ([The profile](dealers.md#the-profile)) | REST, MCP, the CSV import or the console. Every change writes a new numbered version. |
| Logos | `POST /v1/dealers/{id}/logo` |
| Signatures and photos | `POST /v1/dealers/{id}/assets` |
| Which people you name as approvers | `POST /v1/dealers/{id}/approvers` |

| Xcel sets by hand | Scope | Where you read it |
| --- | --- | --- |
| Disclosures | Each dealer | `xcel_managed` on the profile. `dealer.updated` names `xcel_managed.disclosures`, never the wording. |
| License number | Each dealer | `xcel_managed` on the profile. |
| Monthly spend cap (`spend_cap_cents`) | Each dealer | The dealer list and `xcel_managed`. `null` means no cap. |
| Live ordering (`ordering_enabled`) | Your whole company: one switch | `GET /v1/account` |

A request that sends one of these is refused with `xcel_managed_field`. To ask for them, reply to your sandbox welcome email or write to support@xcelmg.com. The console has no button for this, and the docs promise no timing.

Get a dealer's disclosures before you build its orders. A piece prints the dealer's current disclosures when its proof renders. If they change later, `request_approval` refuses with 409 `proof_disclosures_changed` until you render the proof again ([Get disclosures before you build](going-live.md#get-disclosures-before-you-build)).

## Limits

| What | Limit | Past it |
| --- | --- | --- |
| Renders: `render_proof`, template previews and artwork previews | 30 per dealer and 300 per partner, per UTC hour | 429 `proof_render_rate_limited` |
| AI copy: model calls for a `brief` | 200 per dealer and 2,000 per partner, per UTC day | 429 `ai_copy_rate_limited` |
| Spend per dealer, per calendar month in UTC | The cap Xcel sets, if any | 409 `dealer_spend_cap_exceeded` |
| Approver invitations waiting, per dealer | 3 | 409 `approver_invitations_pending_limit` |
| Approver emails, per dealer per UTC day | 5 | 429 `approver_invite_rate_limited` |
| Creative assets, per dealer | 40 | 409 `asset_limit_reached` |
| Test dealers, per partner | 25 | 409 `test_dealer_limit_reached` |
| Active webhook endpoints, per partner and mode | 5 | 409 `webhook_limit_reached` |
| Active API keys for every dealer, per partner and mode | 10 | 409 `key_limit_reached` |
| Active API keys limited to some dealers, per partner and mode | 1,000 | 409 `key_limit_reached` |
| Active saved templates, per partner | 100 | 409 `template_limit_reached` |
| Dealer CSV, per file | 500 rows, 1 MB | 413 `import_too_large` over 500 rows, 413 `payload_too_large` over 1 MB |
| Audience file | 250,000 rows, 50 custom columns and 500 columns in all, 50 MB; 4.5 MB as a request body on the hosted API | `audience_too_large`, `audience_file_invalid`, `payload_too_large` |
| A dealer's do-not-mail list | 1,000,000 entries; 100,000 on a test key | 422 `suppression_list_full` |

- REST and MCP calls are not rate-limited in Phase 1. Poll a campaign no more than about once a minute, or use a webhook.
- Sandbox and live count together against the render and AI copy limits.
- Past a dealer limit, your other dealers carry on. Past a partner limit, they wait: the 429 says when it resets.
- One proof for each of 1,000 stores takes more than three hours at 300 renders an hour. Xcel can raise one partner's numbers, so ask before a campaign goes to many stores at once. `GET /v1/account` shows the numbers that apply to you.

## Test dealers

A dealer your test key creates is a [test dealer](dealers.md#test-dealers), so you can try your own stores before you go live.

- Its writes save, and every answer shows `"test_only": true`. Your live key never sees it.
- It never gets an approver or an UpDash link, and live orders cannot name it.
- Your test keys may create 25. There is no reset; ask Xcel to delete ones you no longer need.
- Its `external_id` is apart from your live dealers'. When you create the real dealer with your live key and the same `external_id`, that id names the real dealer in both modes, and the test dealer stays reachable by its Xcel id.

## When a person asks

Someone asks not to get a dealer's mail, or asks that their record go. [When a person asks](audiences.md#when-a-person-asks) gives the two calls and what each leaves alone:

- `POST /v1/dealers/{id}/suppressions` adds to the dealer's lasting do-not-mail list, which every upload for that dealer applies, so nobody is sent again by hand on the next file. It stores keyed hashes only. A key limited to some dealers reaches those dealers' lists, and a test key's list stays apart from your live key's.
- `DELETE /v1/campaigns/{id}/audience/{audience_id}` deletes a version's files now, unless it is the file of an order still in production.

The dealer is the business the person has the relationship with, so settle the request with the dealer. An audience already processed is not touched by the list, and a submitted order is not recalled.

## Results and webhooks by your id

| You read | Keyed by |
| --- | --- |
| A campaign webhook | `data.dealer_external_id`, `data.external_ref`, `data.metadata` |
| `dealer.updated` | `data.external_id`, with the changed field names, never the values |
| `campaign.lead_results_updated` | `data.leads`: up to 500 pairs of `external_id` and `row_key` in each event |
| `campaign.usps_tracking_updated` | `data.pieces`: up to 500 pieces in each event, each with `external_id`, `row_key`, `stage` and `stage_at` |
| `GET /v1/campaigns/{id}/results` | `dealer_external_id`, `external_ref`, and each lead's `external_id`. Never a name or an address. |
| `GET /v1/campaigns?dealer_id=<your id>` | One dealer's orders, a page at a time ([List campaigns](api-reference.md#list-campaigns)) |

- One endpoint can receive every event type for every dealer, so one receiver is enough. Route on `dealer_external_id`.
- An endpoint belongs to the key's mode. `dealer.updated` for a dealer shared by both modes goes to both modes' endpoints, each signed with its own secret ([The delivery](webhooks.md#the-delivery)).
- Delivery is at least once. De-duplicate on `X-Xcel-Event-Id`, and compare `sequence` to find the newer event: it grows across all your campaigns and dealers.
- A live order reports results only after Xcel links it to its tracking, when it goes into production. `campaign.results_linked` says when. A job then reads results every 6 hours ([Results and attribution](concepts.md#results-and-attribution)).
- Matched sales and service need the dealer's sales and service data in UpDash, which Xcel sets up with the dealer outside the API. Without it, an order reports responses, drops and delivery, and no matches ([Results and attribution](concepts.md#results-and-attribution)).
- Matched sales and service carry the dealer's own figures. Xcel shares them with you under the partner agreement, only on your own campaigns. Treat them as the dealer's confidential data.
- Per-lead results are deleted 365 days (by default) after the order closes. Copy what you need before then ([Retention](audiences.md#retention)).

## From the sandbox to the first live dealer

[Going live](going-live.md) has the whole table. In short:

1. Run a sandbox order end to end with your webhook receiver on ([Quickstart](quickstart.md)), on `demo-motors` or a test dealer.
2. Create a live key in the console (**Developers**, then **API keys**, in live mode). It works before live ordering is on, for everything but submit.
3. Create the real dealer with the live key, with the same `external_id` as its test dealer.
4. Name its approver. They confirm by email.
5. Ask Xcel to set its disclosures, license number and monthly spend cap.
6. Ask Xcel to turn on live ordering. Your console users, keys, webhooks and saved templates carry over. `GET /v1/account` then answers `ordering_enabled: true`.
7. Register a live webhook endpoint (https only) and send it a test event: `POST /v1/webhooks/{id}/test`.
8. Build a live order until `validate_campaign` says `ready_for_approval: true`. Set `max_spend_cents` from a figure a person gave, and call `request_approval`.
9. The approver approves on the review page. Submit with one `Idempotency-Key`.

**A script can run the whole sandbox flow.** `POST /v1/test/campaigns/{id}/approval` decides a sandbox order's pending approval, and `POST /v1/test/campaigns/{id}/advance` moves it through production. A sandbox `request_approval` also returns `review_url` with `sandbox_only: true`, for a person to play the approver. A live key is refused on both test routes, and no route or tool approves a live order. The [example scripts](quickstart.md#before-you-start) do this: each prints `review_url` and waits for a person, for as long as `XM_APPROVAL_WAIT_SECONDS` says.

## From the first dealer to the hundredth

`ordering_enabled` stays on, so nothing changes for your company. Each new dealer takes the same steps:

1. Add its row to your CSV and import it with the live key.
2. Upload its logo and set its hours.
3. Name its approver.
4. Ask Xcel for its disclosures, license number and spend cap.
5. Order for it once `live_ready` is `true`.

Three reads show where the roster stands:

| Read | Tells you |
| --- | --- |
| `GET /v1/dealers?limit=200` | Each dealer's `live_ready`, `spend_cap_cents` and masked `registered_approvers`. Pass `next_after` as `after` for the next page. |
| `GET /v1/account` | `live_readiness`: `live_dealers`, `dealers_with_registered_approver`, `approvers_waiting_on_xcel`, `approvers_waiting_to_confirm` and `gaps`. |
| `validate_campaign` (`GET /v1/campaigns/{id}/validate`) | What one order lacks, in `live_gaps`. |

## Still by hand

These take a person today, whatever your volume.

| Step | Who | Today |
| --- | --- | --- |
| Turning on live ordering | Xcel | On request. |
| Each dealer's disclosures, license number and spend cap | Xcel | On request, one dealer at a time. |
| Listing your dealer-group domains | Xcel | On request. |
| Reviewing approver addresses off the dealer's domain | Xcel | No timing is promised. |
| Removing an approver; deleting a test dealer | Xcel | On request. |
| Approving each live order | The dealer's approver | On the review page. This stays with a person. |
| CASS and NCOA | Xcel | After submit, by hand. No date of its own. |
| The signed NCOA PAF | Xcel, with each dealer | Outside the API. |
| Production | Xcel | By hand: Xcel staff send the files to the printer and move the order through its statuses. |
| Linking each order to its tracking | Xcel | One order at a time, when it goes into production. |
| Linking dealers to UpDash | Xcel | Not part of this pilot: `updash_linked` stays `false`. |
| Cancelling after submit | Xcel | Reply to your Xcel thread. Xcel cancels before production on request. |
| Invoices | Xcel | Not in the API or the console. |

Prices are per piece, and your volume tier counts every dealer's live pieces together (the console's [Pricing](/console/pricing) page). Dates are placeholders; [Still undecided](going-live.md#still-undecided) has the list.
