UpDash Mail API ยท Quickstart
From a sandbox key to a simulated order.
Ten steps with curl and jq, in about fifteen minutes. You need a sandbox key, which you create in the console; your sandbox comes with a sample dealer. The sandbox never prints or mails, and nothing in it creates work for Xcel staff.
export API=https://api.updash.com
export KEY=xm_test_REPLACE_WITH_YOUR_SANDBOX_KEY
export DEALER=demo-motors
H="Authorization: Bearer $KEY"The whole flow, in order
Every error has the shape {error: {code, message, fix, field}}; do what fix says. Most responses that change state include next_step. The responses shown are trimmed sandbox examples with invented values.
Step 1: Look at the products, the templates and the dealer
The products include a 9 x 6 postcard, a greeting card in a 6 x 9 envelope and a tri-fold letter in a #10 envelope. Xcel's 24 templates cover the three formats, and their copy slots carry a sample; any product also takes your own HTML or print-ready art. Search the templates by product, use case or a query. The brand endpoint shows what a new creative prints for the dealer.
Shell curl -s -H "$H" $API/v1/products | jq '.products[] | {code, name, templates: [.templates[].code]}' curl -s -H "$H" "$API/v1/templates?query=birthday" | jq '.templates[] | {code, name, required_slots}' curl -s -H "$H" $API/v1/dealers curl -s -H "$H" $API/v1/dealers/$DEALER/brandStep 2: Create a campaign
One dealer, one product. The response names the next call in next_step.
Shell C=$(curl -s -H "$H" -H 'content-type: application/json' $API/v1/campaigns \ -d "{\"dealer_id\":\"$DEALER\",\"product_code\":\"postcard_6x9\",\"name\":\"November birthdays\"}" \ | jq -r .campaign.id)Show the response
Response201 {"campaign": {"id": "20b6b4d9-f321-41ef-aa5e-c1db05b559fd","mode": "test","status": "draft","status_label": "Draft"},"next_step": "Upload the audience: upload_audience (POST /v1/campaigns/{id}/audience)."}Step 3: Upload the audience
Save the sample file; its last three rows are bad on purpose. Ask for a signed URL, PUT the CSV to it, then tell the API to process it. The URL carries its own token, so your key never goes to storage. To send the file in one call instead, POST it as the body of /audience/import, or send a source_url that Xcel fetches once. Give each row an external_id: results come back keyed by it.
Shell cat > audience.csv <<'CSV' external_id,first_name,last_name,address1,address2,city,state,zip,vin,vehicle_year,vehicle_make,vehicle_model,service_advisor crm-1001,Maria,Lopez,412 Cedar Ln,,Springfield,IL,62704,1HGCV1F30LA012345,2020,Honda,Accord,Dana crm-1002,JAMES,O'BRIEN,88 Lake Shore Dr,Apt 3B,Chicago,Illinois,60611-2201,,2018,Ford,Escape, crm-1003,Priya,Shah,1200 W Main St,,Peoria,IL,61606,,2022,Toyota,RAV4,Ravi crm-1004,Tom,Nguyen,5 Elm Ct,,Normal,IL,61761,,2019,Chevrolet,Malibu,Dana crm-1005,,Baker,77 Oak St,,Decatur,IL,62521,,2021,Kia,Sorento, crm-1006,Ann,Lee,9 Pine Rd,,Champaign,ZZ,61820,,2017,Nissan,Altima, crm-1007,Maria,Lopez,412 Cedar Lane,,Springfield,IL,62704,,2020,Honda,Accord,Dana CSV UP=$(curl -s -H "$H" -X POST $API/v1/campaigns/$C/audience) AUD=$(echo "$UP" | jq -r .audience_id) URL=$(echo "$UP" | jq -r .upload_url) curl -s -X PUT -H 'content-type: text/csv' --data-binary @audience.csv "$URL" curl -s -H "$H" -H 'content-type: application/json' \ $API/v1/campaigns/$C/audience/complete -d "{\"audience_id\":\"$AUD\"}"Show the response, trimmed
Response, trimmed200 {"audience": {"status": "ready","submitted_count": 7,"mailable_count": 4,"rejected_count": 3,"reconciliation": {"rejected_by_reason": { "missing_first_name": 1, "invalid_state": 1, "duplicate": 1 },"rejected_rows": [{ "row": 6, "reason": "missing_first_name", "external_id": "crm-1005" },{ "row": 7, "reason": "invalid_state", "external_id": "crm-1006" },{ "row": 8, "reason": "duplicate", "external_id": "crm-1007" }]}},"campaign_status": "draft"}Step 4: Generate the creative
Fill the template's copy slots, or send a brief and Claude drafts them. Leave out the phone, the QR link and the signer: they print from the dealer's profile. Merge fields take a fallback after the bar. A slot that is too long is stored with a preflight error and a fix.
Shell curl -s -H "$H" -H 'content-type: application/json' $API/v1/campaigns/$C/creative -d '{ "template_code": "postcard_6x9_birthday", "copy": { "note": "Happy birthday from all of us at {{dealer.name}}! Thank you for trusting us with your {{recipient.vehicle|vehicle}}.\n\nYour gift is on the other side. Stop by any time this month and we will take care of it for you.", "gift_offer": "$50 toward any service", "expires": "12/31/2026" } }'Step 5: Render the proof and check readiness
The proof shows customer records, so the API never returns it; the approver sees it on the review page. Validate changes nothing.
Shell curl -s -H "$H" -X POST $API/v1/campaigns/$C/proof curl -s -H "$H" $API/v1/campaigns/$C/validateStep 6: Get a quote
The quote uses your price per piece for your volume tier, the one the console shows, and a note names the tier. A postcard mails First-Class only.
Shell QUOTE=$(curl -s -H "$H" -X POST $API/v1/campaigns/$C/quote) Q=$(echo "$QUOTE" | jq -r .quote.id)Show the response, trimmed
Response, trimmed201 {"quote": {"quantity": 4,"mail_class": "first_class","notes": ["Standard pricing (up to 4,999 live pieces a month): your live orders mailed 0 pieces last month and 0 pieces this month so far (UTC), across all your dealers."],"placeholder_pricing": false},"next_step": "Call request_approval with this quote_id and the budget a person set as max_spend_cents, at least total_cents. Ask for the figure if you have none: this total alone is not one."}Step 7: Ask a person to approve
max_spend_cents is the ceiling the approver agrees to: the budget the person you work for set, at least the quote total, never the total alone. In the sandbox the review link comes back as review_url, so you play the approver: open it, tick the box, choose Approve order. In CI, POST /v1/test/campaigns/{id}/approval decides it instead. With a live key it goes only to the dealer's registered approver, by email.
Shell BUDGET=50000 # the most the person you work for said to spend, in cents APPROVAL=$(curl -s -H "$H" -H 'content-type: application/json' $API/v1/campaigns/$C/approval \ -d "{\"quote_id\":\"$Q\",\"max_spend_cents\":$BUDGET}") A=$(echo "$APPROVAL" | jq -r .approval_id) echo "$APPROVAL" | jq -r .review_urlStep 8: Submit with an Idempotency-Key
One key per order. Send the same request again with that key and you get the same body with idempotent-replayed: true. Nothing is submitted twice.
Shell IDEM=$(uuidgen) curl -s -i -H "$H" -H 'content-type: application/json' -H "Idempotency-Key: $IDEM" \ $API/v1/campaigns/$C/submit -d "{\"approval_id\":\"$A\"}"Step 9: Advance it through production
Sandbox only. Each call moves the order one status. Five calls reach completed, and from in_postal_network on each call also simulates results.
Shell for i in 1 2 3 4 5; do curl -s -H "$H" -X POST $API/v1/test/campaigns/$C/advance | jq -c '{from, status, results_simulated}' doneShow the output
OutputJSON {"from":"submitted","status":"in_production","results_simulated":false}{"from":"in_production","status":"at_usps","results_simulated":false}{"from":"at_usps","status":"in_postal_network","results_simulated":true}{"from":"in_postal_network","status":"delivery_estimated","results_simulated":true}{"from":"delivery_estimated","status":"completed","results_simulated":true}Step 10: Read the results
Totals plus a page of per-lead results keyed by your external_id, never a name or an address. Sandbox values are invented and marked simulated: true.
Shell curl -s -H "$H" $API/v1/campaigns/$C/results | jq '.leads.items[0]'Show the one lead
One leadsimulated {"external_id": "crm-1001","row_key": "xmdr6kslk45b2rkegz","responses": [{ "type": 2, "type_label": "web" },{ "type": 4, "type_label": "appointment" }],"matches": [{ "kind": "sale", "vehicle_type": "Used", "gross_cents": 285000, "revenue_cents": 4125000 }]}
The same flow, as code
Three runnable examples run the whole sandbox flow end to end and check a webhook signature on the way. Xcel's end-to-end test runs all three, so they stay in step with the API.
- Node
- Node 22 or later, fetch only, no dependencies
- Python
- Python 3.9 or later, the standard library only
- MCP
- Node 22 or later, the official MCP TypeScript client
Each reads XM_API and XM_KEY, refuses any key that is not xm_test_, and registers one webhook endpoint that it deactivates at the end. They ship with the docs at api.updash.com/docs.
The docs also carry a Postman collection and the guide to a pre-release TypeScript SDK, @updash/mail-api. It is not on npm yet, so ask Xcel for the package.
export XM_API=https://api.updash.com
export XM_KEY=xm_test_REPLACE_WITH_YOUR_SANDBOX_KEY
# The Node and Python scripts then approve the sandbox order themselves, with no browser step:
export XM_SANDBOX_APPROVE=1
curl -sO $XM_API/docs/examples/node/sandbox.mjs
node sandbox.mjs
curl -sO $XM_API/docs/examples/python/sandbox.py
python3 sandbox.py
mkdir mcp-example && cd mcp-example
curl -sO $XM_API/docs/examples/mcp/sandbox.mjs
curl -sO $XM_API/docs/examples/mcp/package.json
npm install && node sandbox.mjsconst idempotencyKey = randomUUID();
const submitted = expect(
await api("POST", `/v1/campaigns/${campaign.id}/submit`, {
body: { approval_id: approval.approval_id },
headers: { "idempotency-key": idempotencyKey },
}),
201,
"submit",
);
// A retry with the same key must replay the first response.def verify_signature(secret, header, raw_body, tolerance_seconds=300):
try:
parts = dict(p.split("=", 1) for p in (header or "").split(","))
t = int(parts["t"])
except (ValueError, KeyError):
return False
if abs(time.time() - t) > tolerance_seconds:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body,
hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
const client = new Client({ name: "xcel-mail-example", version: "1.0.0" });
await client.connect(new StreamableHTTPClientTransport(
new URL(`${API}/api/mcp`),
{ authProvider: { token: async () => KEY } },
));
const { campaign } = await tool("create_campaign", {
dealer_id: dealer, product_code: "postcard_6x9", name: "MCP example",
});Short excerpts, apart from Run. The full scripts read top to bottom, one request per step.
Questions
- Does the sandbox print or mail anything?
- No. A sandbox key never prints, mails or creates work for Xcel staff. Address processing and production are simulated, and results are invented values marked simulated: true.
- How long does the quickstart take?
- About fifteen minutes with curl and jq, once you have a sandbox key from the console.
- Can I run the examples against live?
- No. Each script refuses to start unless XM_KEY is a sandbox key (xm_test_), so an example can never place a real order.
- How do I receive webhooks from a hosted sandbox?
- The receiver in each example listens on your own machine. Point a tunnel at it and set XM_WEBHOOK_PUBLIC_URL to its public https URL; without one, the example skips the signature check.
- Where is the full quickstart?
- At api.updash.com/docs, with every response shown in full.
Get a sandbox key
Sign up, and create the key in the console. The full docs are at api.updash.com/docs. Ready to go live? Ask for live access.
Or text 305.877.3881 and a person writes back.