Skip to main content

Cookbook

What's here

Three worked recipes covering the most common integrations:

RecipeUse when
Sync orders to your ERPYou have a separate ERP / accounting system that needs Sumeru order data
Build custom attributionYou want a custom attribution pipeline (e.g. company-specific touchpoint weights)
Embed storefront widgetsYou're not on Liquid; need to embed widgets in Hydrogen / Next.js / custom

Each recipe is:

  • Self-contained — code runs as-is
  • Production-grade — auth, error handling, idempotency
  • Documented — each line explained

Common patterns across recipes

Auth setup

All recipes assume a v1 admin token. Get one: Authentication & scopes.

const ATLANTIS_TOKEN = process.env.ATLANTIS_API_KEY; // copt_live_...

SDK vs. raw HTTP

Recipes show both. Pick whichever fits:

  • SDK for typed methods + auto-retry + idempotency
  • Raw HTTP for full control / non-supported language

Webhook-driven vs. poll-driven

For real-time integrations (ERP sync, custom attribution), use webhooks. Polling is rate-limit-hungry + slower.

Webhook setup pattern shown in each recipe.

Pattern: idempotent webhook handler

Re-used across recipes:

server/webhooks/sumeru.js
const seen = new Map(); // production: use Redis or DB

app.post('/webhook', async (req, res) => {
const eventId = req.body.id;
if (seen.has(eventId)) {
// Already processed; ack and skip
return res.status(200).end();
}

// Verify signature first — bail on mismatch before doing any work.
if (!verifySumeruWebhook(req.rawBody, req.headers['x-sumeru-signature'], SECRET)) {
return res.status(401).end();
}

try {
await handleEvent(req.body);
seen.set(eventId, Date.now());
return res.status(200).end();
} catch (err) {
console.error('Webhook processing failed:', err);
return res.status(500).end(); // We'll retry
}
});

Pattern: rate-limit-aware client

# Bash with retry-on-429 (use this in shell scripts + CI)
for i in 1 2 3 4 5; do
response=$(curl -s -w "%{http_code}" \
-H "Authorization: Bearer $ATLANTIS_TOKEN" \
-H "Content-Type: application/json" \
"https://api.sumeru.systems/v1/customers")
status="${response: -3}"
if [ "$status" != "429" ]; then
echo "${response%???}"
break
fi
sleep "$((2 ** i))"
done

The language tab you pick is remembered across every code sample on the site — pick once and the rest follow.

See also