At a glance: what you can do with the REST API v1
One interface to connect your websites, cash registers, workflows, and AI assistants to your merchants while keeping human oversight.
Show live Apple/Google Wallet card previews on your website and provision active merchant accounts with ready-to-use QR codes.
Identify customers by QR code, phone, or email, enroll new cardholders, and earn, debit, or redeem points, stamps, gift cards, and prepaid balances.
Read merchant activity (active cards, visits, credit balances) and filter cardholders by inactivity, balance, birthday month, or GDPR opt-ins.
Let an automation or AI assistant draft SMS, email, or Wallet campaigns with exact audience and cost estimates — nothing is ever sent until a human approves it.
Subscribe your systems to card installs, loyalty transactions, unlocked rewards, campaign approvals, and GDPR updates.
https://www.mellio-agences.fr/api/v1
Overview & Dual-Key Architecture
Two complementary tracks: browser merchant onboarding on your website (pk_) and server-to-server integration for POS, CRM, AI campaigns, and webhooks (sk_).
Fidelity API v1 lets you embed a live loyalty card configurator on your website and connect your POS software, CRM, or AI assistant (store metrics, loyalty points/stamps, human-approved campaigns, and real-time webhooks). It relies on two complementary key types across Sandbox (test) and Production (live).
pk_live_... / pk_test_...
Publishable Key
Designed to be called directly from browser JavaScript on a static or marketing site (Astro, Next.js, Webflow, WordPress) without exposing any secrets.
- Strictly locked via CORS to your allowlisted Origin domains (browser Origin header required).
- Restricted exclusively to public onboarding scopes (theme catalog, interactive Wallet preview drafts, and initial signup).
- Protected automatically by per-IP rate limits and adaptive bot verification (Cloudflare Turnstile / hCaptcha).
sk_live_... / sk_test_...
Secret Key
Reserved strictly for server-to-server requests initiated from your private backend, background workers, or internal automations.
- Must never be embedded in frontend code, mobile apps, or public repositories (automatically rejected if a browser Origin header is present).
- Unlocks full POS Cash Register integration: QR/phone customer lookup, loyalty points/stamps earning, reward redemption, and receipt refunds.
- Can be locked down to static IP / CIDR allowlists and enforced with canonical HMAC-SHA256 request signing.
Authentication, Scopes & Canonical HMAC
Required HTTP headers, least-privilege scopes, and replay-proof request signing.
Every request to /api/v1/* must be sent over HTTPS with Content-Type: application/json using one of the two authentication modes below:
X-Fidelity-Publishable-Key: pk_live_xxx Origin: https://your-static-site.com Content-Type: application/json
The Origin header is automatically sent by the browser and must exactly match one of the allowed origins configured on your API client.
Authorization: Bearer sk_live_xxx X-Fidelity-Timestamp: 1763200000 X-Fidelity-Signature: v1=8f4c2e9a... Content-Type: application/json
X-Fidelity-Timestamp and X-Fidelity-Signature are required whenever 'Require HMAC' is enabled on your API client.
Permission Scopes Matrix
| Scope | Allowed keys | Description |
|---|---|---|
| catalog:read | pk_ & sk_ | List business sectors, Apple/Google Wallet visual presets, and default color palettes. |
| onboarding:write | pk_ & sk_ | Create, poll, and update interactive Wallet pass preview drafts prior to signup. |
| merchants:onboard | pk_ & sk_ | Convert a preview draft into a live merchant account (with POS PIN and accepted terms). |
| merchants:read | sk_ only | Read merchant accounts attached to your partner organization. |
| merchants:write | sk_ only | Manage attached merchants and mint fresh POS scanner handoff tokens. |
| customers:read | sk_ only | Identify customers at checkout (Wallet QR, PVC card, phone, email) and read pass balances. |
| customers:write | sk_ only | Enroll customers at the register, bind physical PVC cards, and sync CRM profiles. |
| transactions:write | sk_ only | Credit points or stamps, redeem rewards, process gift/prepaid cards, and refund receipts. |
| campaigns:read | sk_ only | Read marketing campaigns and time-limited Wallet offers for a merchant. |
| campaigns:draft | sk_ only | Prepare campaign drafts (pending_approval status only; direct sending forbidden). |
| campaigns:approve | sk_ only | Approve or reject pending campaigns from a separate party (never enabled by default). |
| webhooks:manage | sk_ only | Configure outbound webhook endpoints, trigger test pings, and inspect delivery logs. |
Canonical HMAC-SHA256 Signature (Server-to-Server)
To guarantee JSON payload integrity and block replay attacks, sign the canonical string below using your whsec_... signing secret:
import crypto from "node:crypto";
const timestamp = Math.floor(Date.now() / 1000).toString();
const method = "POST";
const fullpath = "/api/v1/merchants/9c12a8f4.../transactions"; // includes query string if present
const rawBody = JSON.stringify(payload);
const canonical = `${timestamp}.${method}.${fullpath}.${rawBody}`;
const signature = crypto
.createHmac("sha256", process.env.FIDELITY_SIGNING_SECRET) // whsec_...
.update(canonical, "utf8")
.digest("hex");
// Headers:
// "X-Fidelity-Timestamp": timestamp
// "X-Fidelity-Signature": `v1=${signature}`
Maximum clock skew: ±300 seconds (5 minutes). Every (signature, timestamp) pair is single-use; replaying a signed request returns HTTP 401 replay_detected.
Zero-Trust Security, Idempotency & Sandbox Isolation
Public documentation never weakens security: cryptographic authentication, strict tenant isolation, and pessimistic SQL locks.
Zero-Trust Architecture & Strict Isolation
Security relies 100% on hashed secrets and server-side boundaries—never on URL obscurity.
- Instant browser block: any secret key (sk_) sent with Origin or Sec-Fetch-* headers is rejected (HTTP 403 secret_key_in_browser).
- Test vs Live isolation: an sk_test_ key can never read or mutate a live production merchant (HTTP 403 environment_mismatch).
- Anti-replay & Anti-fraud: every HMAC signature is single-use (replay_detected), and no transaction or spent top-up can ever be refunded twice.
Mandatory Idempotency-Key on all mutations
Send a unique UUID v4 in Idempotency-Key whenever provisioning a merchant, enrolling a customer, or recording/refunding a POS transaction.
- If your client retries the exact same request after a network timeout, the API safely replays the original response without creating duplicates.
- If the same Idempotency-Key is reused with a different JSON body, the API rejects the call with HTTP 409 idempotency_key_conflict.
- Idempotency keys are scoped per API client and retained for 24 hours.
Per-Minute Rate Limits & Adaptive Captcha
Every API client enforces per-minute request quotas per key and per caller IP address.
- When exceeded, the API returns HTTP 429 rate_limited with a standard Retry-After header (in seconds).
- On publishable keys (pk_), exceeding the hourly signup threshold per IP or enabling strict bot protection requires a valid X-Captcha-Token header.
- In Sandbox mode (pk_test_ / sk_test_), provisioned merchants are isolated as test accounts with zero live billing.
Web Onboarding & Merchant Management (/api/v1)
Theme catalog, interactive Wallet drafts, store provisioning, and POS configuration retrieval.
/api/v1/ping
Validates your publishable or secret key, checks CORS origin or IP allowlists, and returns the active environment and granted scopes.
{
"ok": true,
"environment": "live",
"key_type": "secret",
"client_name": "POS Connector Server",
"distributor": { "uuid": "8b4e2f10-...", "brand_name": "Your Agency" },
"scopes": ["merchants:read", "customers:read", "customers:write", "transactions:write"],
"timestamp": "2026-11-16T10:30:00Z"
}
/api/v1/catalog/themes?locale=fr
Returns all supported business categories and ready-to-use Wallet visual themes to populate your frontend configurator.
locale (optional) : Language for returned labels (fr, en, es, de, it, pt, nl, ca, pl, el, ar). Defaults to fr.
curl -X GET "https://www.mellio-agences.fr/api/v1/catalog/themes?locale=fr" \ -H "X-Fidelity-Publishable-Key: pk_live_xxx" \ -H "Origin: https://your-static-site.com"
{
"locale": "fr",
"sectors": [
{
"key": "brasserie",
"presets": [
{
"id": "brasserie_houblon_ambre",
"bg_color": "#DB972F",
"image_url": "https://www.mellio-agences.fr/passes/presets/brasserie/houblon_ambre.png",
"focal_x": 87,
"focal_y": 56,
"poster_fx": 87,
"poster_fy": 56,
"poster_zoom": 100,
"google_fx": 87,
"google_fy": 56,
"google_zoom": 100,
"visual_layout_mode": "full_bleed",
"uniform_edges": true,
"subject_coverage": 0.1631,
"aspect_ratio": 3.0
}
]
}
]
}
/api/v1/onboarding/drafts
Creates a 72-hour preview session backed by a real demo pass installable on iPhone (Apple Wallet) and Android (Google Wallet).
| JSON Field | Type | Description |
|---|---|---|
| draft.name | string | Shop name displayed on the Wallet pass (e.g., 'Golden Crust Bakery'). |
| draft.business_type | string | Business type identifier from the catalog (e.g., boulangerie, coiffure, restaurant, fleuriste, kebab). |
| draft.wallet_theme_preset | string | Selected Wallet theme preset identifier. |
| draft.bg_color | string | Primary pass background color in hex format (#RRGGBB). |
| draft.mode_fidelite | string | Loyalty program mechanic: tampons (stamps) or points. |
| draft.threshold | integer | Number of stamps or points threshold needed to unlock the reward. |
| draft.reward_text | string | Reward label shown on the pass (e.g., '1 free espresso'). |
| draft.visual_data_url / logo_data_url | string (optional) | Custom artwork or logo encoded as a base64 data URL (PNG, JPEG, or WebP). |
| draft.poster_fx / poster_fy | integer (0..100) | Apple Wallet (358×448) and /enrollment card focal point in percent (0 to 100, aliases focal_x / focal_y). |
| draft.poster_zoom | integer (50..180) | Apple Wallet artwork zoom in percent (50 to 180, default 100; < 100 zooms out over bg_color). |
| draft.google_fx / google_fy | integer (0..100) | Independent Google Wallet heroImage focal point (1032×336, 0 to 100). Inherits from Apple on creation and stays preserved on partial PATCH. |
| draft.google_zoom | integer (50..180) | Independent Google Wallet zoom in percent (50 to 180, default 100; never inherits from poster_zoom). |
| draft.visual_layout_mode | string (optional) | Visual layout mode: full_bleed (recommended) or auto. |
| draft.locale | string | Locale for pass labels and preview flow (default: fr). |
curl -X POST "https://www.mellio-agences.fr/api/v1/onboarding/drafts" \
-H "X-Fidelity-Publishable-Key: pk_live_xxx" \
-H "Origin: https://your-static-site.com" \
-H "Content-Type: application/json" \
-d '{
"draft": {
"name": "Boulangerie L'\''Épi d'\''Or",
"business_type": "boulangerie",
"wallet_theme_preset": "boulangerie_epi_fournil",
"bg_color": "#5A3825",
"mode_fidelite": "tampons",
"threshold": 8,
"reward_text": "1 tradition offerte",
"poster_fx": 82,
"poster_fy": 44,
"poster_zoom": 65,
"google_fx": 18,
"google_fy": 72,
"google_zoom": 135,
"visual_layout_mode": "full_bleed",
"locale": "fr"
}
}'
{
"draft_token": "eyJfcmFpbHMiOnsibWVzc2FnZSI6...",
"draft": {
"name": "Boulangerie L'Épi d'Or",
"business_type": "boulangerie",
"mode_fidelite": "tampons",
"threshold": 8,
"reward_text": "1 tradition offerte",
"focal_x": 82,
"focal_y": 44,
"poster_fx": 82,
"poster_fy": 44,
"poster_zoom": 65,
"google_fx": 18,
"google_fy": 72,
"google_zoom": 135,
"visual_layout_mode": "full_bleed",
"uniform_edges": true,
"subject_coverage": 0.2246,
"aspect_ratio": 3.0
},
"wallet_preview": {
"install_url": "https://www.mellio-agences.fr/api_gateway/preview/eyJfcmFp...",
"qr_svg_data_uri": "data:image/svg+xml;base64,...",
"pass_installed": false,
"wallet_type": null,
"converted": false
},
"expires_at": "2026-11-18T10:30:00Z"
}
/api/v1/onboarding/drafts/:token
Lets your frontend check whether the prospect has installed the preview pass on their phone (wallet_preview.pass_installed = true).
/api/v1/onboarding/drafts/:token
Updates the name, colors, preset, or reward on the draft. If the prospect already added the pass to their phone, it updates over the air.
/api/v1/onboarding/email_verifications
Sends a 6-digit verification code to validate the merchant owner's email before final provisioning.
{ "email": "artisan@epidor.fr", "draft_token": "..." }
/api/v1/onboarding/email_verifications/verify
Validates the code entered by the user before calling POST /api/v1/merchants.
{ "email": "artisan@epidor.fr", "code": "482910", "draft_token": "..." }
/api/v1/merchants
Creates a live merchant under your partner account (or converts an existing draft_token while preserving its full Wallet appearance).
| JSON Field | Type | Description |
|---|---|---|
| draft_token | string (optional) | Draft token from the previous step to carry over the configured Wallet design. |
| merchant.name | string (required) | Official business name. |
| merchant.pin | string (required) | Exact 4-digit secret PIN (0000–9999) used by staff to unlock the POS scanner. |
| merchant.poster_* / google_* | integer (optional) | Optional Apple (poster_fx/fy/zoom) and Google (google_fx/fy/zoom) framing overrides; inherited from the draft when omitted. |
| owner.email | string | Owner email address for portal login and important account notifications. |
| owner.phone | string | Owner mobile number in E.164 format (e.g., +33612345678). |
| owner.accept_terms | boolean | Must be explicitly set to true after the user accepts the terms and conditions. |
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants" \
-H "X-Fidelity-Publishable-Key: pk_live_xxx" \
-H "Origin: https://your-static-site.com" \
-H "Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000" \
-H "Content-Type: application/json" \
-d '{
"draft_token": "eyJfcmFpbHMiOnsibWVzc2FnZSI6...",
"merchant": {
"name": "Boulangerie L'\''Épi d'\''Or",
"pin": "2580",
"locale": "fr"
},
"owner": {
"email": "artisan@epidor.fr",
"phone": "+33612345678",
"accept_terms": true
}
}'
{
"success": true,
"merchant": {
"uuid": "9c12a8f4-3b7d-4e91-8a10-77e2c1109f3a",
"name": "Boulangerie L'Épi d'Or",
"mode_fidelite": "tampons",
"sandbox": false,
"visual_framing": {
"focal_x": 82,
"focal_y": 44,
"visual_layout_mode": "full_bleed",
"poster_fx": 82,
"poster_fy": 44,
"poster_zoom": 65,
"google_fx": 18,
"google_fy": 72,
"google_zoom": 135
},
"distributor": { "uuid": "8b4e2f10-...", "brand_name": "Your Agency" },
"scanner_billing": {
"enabled": true,
"mode": "open",
"free_trial_months": 2,
"trial_ends_at": "2027-01-26T10:30:00Z",
"days_remaining": 60,
"monthly_price_cents": 2900,
"currency": "EUR"
}
},
"onboarding_assets": {
"scanner_handoff_url": "https://www.mellio-agences.fr/merchant/s/9c12a8f4-.../install",
"scanner_install_url": "https://www.mellio-agences.fr/merchant/s/9c12a8f4-.../install",
"scanner_handoff_qr_svg": "data:image/svg+xml;base64,...",
"customer_enrollment_url": "https://www.mellio-agences.fr/enrollment?merchant_uuid=9c12a8f4-...",
"customer_enrollment_qr_svg": "data:image/svg+xml;base64,...",
"counter_flyer_url": "https://www.mellio-agences.fr/api_gateway/flyer/eyJfcmFp...",
"portal_login_url": "https://www.mellio-agences.fr/fr/portal/login"
}
}
/api/v1/merchants
Returns a paginated list of merchants under your partner account (automatically restricted to sandbox stores when using sk_test_).
curl -X GET "https://www.mellio-agences.fr/api/v1/merchants?active=true&per_page=50" \ -H "Authorization: Bearer sk_live_xxx"
/api/v1/merchants/:uuid
Lets your POS sync the store's active loyalty mode (points or stamps), earning ratio, reward thresholds, and gift/prepaid card settings.
{
"merchant": {
"uuid": "9c12a8f4-...",
"name": "Brasserie Le Comptoir",
"currency": "EUR",
"stats": {
"customers_count": 342,
"active_cards_count": 318,
"wallet_installed_count": 265,
"transactions_total_count": 1490,
"visits_last_30_days_count": 184
},
"credits": {
"sms_balance_micros": 12500000,
"sms_balance_eur": 12.5,
"sms_unlimited": false,
"email_credits": 850,
"email_unlimited": false,
"currency": "EUR"
},
"loyalty_rules": {
"mode": "points",
"points_per_unit": 2,
"unit_amount_cents": 100,
"reward_tiers": [
{ "threshold": 50, "unit": "points", "label": "1 Dessert offert" }
]
}
}
}
/api/v1/merchants/:uuid/handoff_tokens
Generates on demand (server-to-server only) a short-lived signed token (30 minutes) allowing the merchant to open and install their PWA POS scanner.
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-3b7d-4e91-8a10-77e2c1109f3a/handoff_tokens" \ -H "Authorization: Bearer sk_live_xxx"
POS Cash Register Integration — Customers & Transactions
Server-to-server endpoints (sk_ only) to identify customers at checkout, credit receipts, and redeem rewards.
/api/v1/merchants/:merchant_uuid/customers/lookup
Looks up a customer strictly within the merchant's scope via scanned barcode (Apple/Google Wallet or PVC card), phone, or email, returning live balances and unlocked rewards. Returns found: false with unassigned_physical_card when scanning a blank store PVC card.
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../customers/lookup" \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"code": "a8f190c42e77b10394dd1102"
}'
# Or by phone / email:
# { "phone": "0612345678", "phone_country": "FR" }
{
"found": true,
"customer": {
"uuid": "51d9e0a1-...",
"name": "Claire Martin",
"phone": "+33612345678",
"pass": {
"serial_number": "a8f190c42e77b10394dd1102",
"reward_ready": true,
"loyalty_mode": "points",
"points_balance": 60,
"stamps_balance": 0,
"gift_card_balance_cents": 0,
"prepaid_balance_cents": 4300,
"currency": "EUR",
"unlocked_rewards": [
{ "threshold": 50, "unit": "points", "label": "1 Dessert offert" }
]
}
}
}
/merchants/:uuid/customers
Creates or updates a customer profile, provisions their pass, optionally links an unassigned PVC card (card_serial), and returns the Apple / Google Wallet install URL and SVG QR code.
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../customers" \
-H "Authorization: Bearer sk_live_xxx" \
-H "Idempotency-Key: 91b2e3c4-1111-4222-8333-444455556666" \
-H "Content-Type: application/json" \
-d '{
"phone": "+33612345678",
"first_name": "Claire",
"last_name": "Martin",
"card_serial": "CARD-4821-9034",
"rgpd_marketing_opt_in": true
}'
/merchants/:uuid/customers/:customer_uuid
Retrieves the full Wallet pass state of a customer by UUID along with their recent checkout history.
curl -X GET "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../customers/51d9e0a1-..." \ -H "Authorization: Bearer sk_live_xxx"
/api/v1/merchants/:merchant_uuid/transactions
Atomically executes (pessimistic SQL lock + Idempotency-Key) a receipt credit (earn with integer amount_cents or stamps), a reward redemption (redeem_reward), or a gift/prepaid card operation, pushing live updates to Apple / Google Wallet.
| operation | JSON Field | Description |
|---|---|---|
| earn | code | customer_uuid | phone, amount_cents | stamps | Awards points automatically computed from integer amount_cents (e.g. 2450 for €24.50) or adds stamps (default: 1). |
| debit_loyalty | code | customer_uuid, points | stamps | Debits loyalty points or stamps without redeeming a reward (accepts points or stamps). |
| redeem_reward | code | customer_uuid, reward_threshold | Deducts the configured reward_threshold (e.g. 50 points or 10 stamps) after verifying sufficient balance. |
| gift_card_* / prepaid_* | gift_card_credit | gift_card_debit | prepaid_credit | prepaid_debit, amount_cents | Credits or debits integer amount_cents on the customer's gift card or prepaid wallet. |
# 1) Credit a €30.00 receipt (3000 cents):
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../transactions" \
-H "Authorization: Bearer sk_live_xxx" \
-H "Idempotency-Key: pos-ticket-2026-00482" \
-H "Content-Type: application/json" \
-d '{
"operation": "earn",
"code": "a8f190c42e77b10394dd1102",
"amount_cents": 3000,
"external_reference": "TICKET-2026-00482",
"operator_name": "Caisse 1 - Lucas"
}'
# 2) Redeem a 50-point reward:
# { "operation": "redeem_reward", "customer_uuid": "51d9e0a1-...", "reward_threshold": 50 }
{
"success": true,
"transaction": {
"id": 1842,
"transaction_type": "gain",
"amount_cents": 3000,
"currency": "EUR",
"points_changed": 60,
"stamps_changed": 0,
"operator_name": "Caisse 1 - Lucas",
"source": "pos_api",
"refunded": false
},
"customer": {
"uuid": "51d9e0a1-...",
"pass": {
"points_balance": 60,
"reward_ready": true
}
}
}
/merchants/:uuid/transactions/:id/refund
Reverses the exact points, stamps, or cents recorded on an original transaction. Enforces PostgreSQL-level protection against double-refunds and spent-gift-card refund fraud.
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../transactions/1842/refund" \
-H "Authorization: Bearer sk_live_xxx" \
-H "Idempotency-Key: pos-refund-ticket-00482" \
-H "Content-Type: application/json" \
-d '{ "reason": "Ticket annulé en caisse" }'
/merchants/:uuid/transactions
Returns merchant transactions in reverse chronological order (filterable by customer_uuid, transaction_type, and before_id cursor) including the refunded flag.
curl -X GET "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../transactions?limit=25" \ -H "Authorization: Bearer sk_live_xxx"
Human-Approved Campaigns & Customer Segmentation
Safe AI & partner automation workflow: draft creation, live cost estimation, and mandatory human approval.
Agency endpoints let tools segment GDPR-eligible customers and prepare pending_approval campaign drafts with real-time audience and credit cost estimates.
/merchants/:uuid/customers
Paginated customer list with segmentation filters (inactive_days, min_points, birthday_month, opt_in_sms, opt_in_email) and GDPR flags.
/merchants/:uuid/campaigns (/:uuid)
Lists campaigns and time-limited offers for a merchant (GET /campaigns and GET /campaigns/:uuid) with optional status filters.
/merchants/:uuid/campaigns
Creates a pending_approval draft only, computes opt-in audience and cost estimate, and notifies the approver.
/merchants/:uuid/campaigns/:uuid/approve
Approves a pending draft (requires campaigns:approve scope and enforces 4-eyes anti-self-approval).
/merchants/:uuid/campaigns/:uuid/reject
Rejects a pending campaign draft (requires campaigns:approve + Idempotency-Key) and records the rejection reason.
/merchants/:uuid/customers/:uuid/transactions
Earn or debit loyalty points/stamps (debit_loyalty) or redeem rewards with mandatory Idempotency-Key.
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../campaigns" \
-H "Authorization: Bearer sk_live_xxx" \
-H "Idempotency-Key: camp-draft-2026-11-26-01" \
-H "Content-Type: application/json" \
-d '{
"title": "Offre week-end -15%",
"content": "Votre café offert ce samedi !",
"channels": ["push", "sms"],
"filters": { "inactive_days": 30, "opt_in_sms": true }
}'
{
"success": true,
"campaign": {
"uuid": "7f3a9d10-...",
"status": "pending_approval",
"audience": {
"total_matched": 84,
"eligible_by_channel": { "push": 62, "sms": 58, "email": 0, "whatsapp": 0 }
},
"cost_estimate": {
"sms_estimated_micros": 4060000,
"sms_estimated_eur": 4.06,
"sms_segments_per_recipient": 1,
"email_credits_required": 0,
"sufficient_credits": true,
"currency": "EUR"
},
"approval": {
"required": true,
"review_url": "https://www.mellio-agences.fr/fr/portal/campaign_approvals/7f3a9d10-..."
}
}
}
curl -X GET "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../customers?inactive_days=30&min_points=20&birthday_month=11&opt_in_sms=true&page=1&per_page=50" \ -H "Authorization: Bearer sk_live_xxx"
# Validate (separate key with campaigns:approve scope — 4-eyes rule):
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../campaigns/7f3a9d10-.../approve" \
-H "Authorization: Bearer sk_live_approver_xxx" \
-H "Idempotency-Key: camp-approve-7f3a9d10"
# Or reject with reason:
curl -X POST "https://www.mellio-agences.fr/api/v1/merchants/9c12a8f4-.../campaigns/7f3a9d10-.../reject" \
-H "Authorization: Bearer sk_live_approver_xxx" \
-H "Idempotency-Key: camp-reject-7f3a9d10" \
-H "Content-Type: application/json" \
-d '{ "rejection_reason": "Modifier la remise à -10%" }'
Outbound Webhooks & HMAC Signature
Signed asynchronous events (X-Mellio-Signature) with 24-hour exponential backoff retries.
Subscribe your HTTPS endpoint to real-time events (card.installed, loyalty.transaction_created, reward.unlocked, campaign.pending_approval, customer.anonymized...).
Webhook Management Endpoints (webhooks:manage)
/api/v1/webhooks
Lists all configured agency endpoints along with the catalog of 14 supported event types.
/api/v1/webhooks
Registers an SSRF-safe HTTPS URL and returns the signing_secret once upon creation.
/api/v1/webhooks/:uuid
Updates the endpoint name, target URL, subscribed_events, or active flag.
/api/v1/webhooks/:uuid
Permanently deletes the webhook endpoint.
/api/v1/webhooks/:uuid/ping
Queues a synthetic webhook.ping delivery to test connectivity and signature verification (HTTP 202).
/api/v1/webhooks/:uuid/deliveries
Inspects paginated delivery attempts (status, HTTP code, attempt count, latency, error).
curl -X POST "https://www.mellio-agences.fr/api/v1/webhooks" \
-H "Authorization: Bearer sk_live_xxx" \
-H "Idempotency-Key: wh-create-2026-11-26-01" \
-H "Content-Type: application/json" \
-d '{
"name": "Make / n8n Production",
"url": "https://hooks.example.com/mellio",
"subscribed_events": [
"card.installed",
"loyalty.transaction_created",
"campaign.pending_approval",
"campaign.sent"
]
}'
{
"success": true,
"webhook": {
"uuid": "4c92e1a0-...",
"name": "Make / n8n Production",
"url": "https://hooks.example.com/mellio",
"active": true,
"signing_secret": "whsec_9a8b7c6d...",
"subscribed_events": [
"card.installed",
"loyalty.transaction_created",
"campaign.pending_approval",
"campaign.sent"
]
}
}
Catalog of 14 Outbound Webhook Events
Verifying X-Mellio-Signature (HMAC-SHA256)
Always verify the HMAC-SHA256 signature and timestamp window (±300s) using a constant-time comparison.
import crypto from "node:crypto";
const sigHeader = req.headers["x-mellio-signature"]; // t=...,v1=...
const parts = Object.fromEntries(sigHeader.split(",").map((kv) => kv.split("=")));
if (Math.abs(Math.floor(Date.now() / 1000) - Number(parts.t)) > 300) {
throw new Error("Timestamp expired");
}
const expected = crypto
.createHmac("sha256", process.env.MELLIO_WEBHOOK_SECRET)
.update(`${parts.t}.${rawBody}`, "utf8")
.digest("hex");
const valid = crypto.timingSafeEqual(Buffer.from(expected, "hex"), Buffer.from(parts.v1, "hex"));
5 automatic retry attempts over 24 hours via Solid Queue, with auto-disable and email alert after 10 consecutive permanent failures.
Ready-to-Use Browser Gateways (/api_gateway)
Signed URLs returned by the API to display QR codes or redirect merchants with zero custom UI work.
Onboarding responses return signed gateway URLs ready to be scanned on mobile or embedded as SVG QR codes:
GET /api_gateway/preview/:token
Demo Wallet Pass Installer
Detects iOS or Android automatically and prompts instant installation into Apple Wallet or Google Wallet (valid for 72 hours).
GET /api_gateway/scanner/:token
One-Scan POS Scanner Handoff
Signs the merchant directly into their mobile PWA register and starts their trial window if configured (valid for 30 minutes).
GET /api_gateway/flyer/:token
Printable Counter Enrollment Flyer
Renders a print-ready counter poster featuring the customer enrollment QR code to place by the register (valid for 7 days).
Step-by-Step Integration Recipes (Web & POS)
Choose the workflow matching your integration: website acquisition (pk_) or in-store POS checkout (sk_).
Load business themes
Call GET /api/v1/catalog/themes on page load to populate your sector selector and Wallet theme gallery.
Create & live-update the Wallet preview
Create a draft via POST /api/v1/onboarding/drafts, render qr_svg_data_uri, and call PATCH whenever the visitor tweaks colors or rewards.
Collect PIN & provision the merchant
Ask for email, a 4-digit POS PIN, and terms consent, then call POST /api/v1/merchants with a fresh Idempotency-Key.
Deliver Scanner & Counter Flyer
Display scanner_handoff_qr_svg so the merchant installs their POS scanner immediately, plus a button for counter_flyer_url.
Sync store loyalty rules
Call GET /api/v1/merchants/:uuid when configuring the register to load the loyalty mode (points/stamps) and reward_tiers.
Identify or enroll the customer
Scan the pass or submit phone via POST .../customers/lookup. If unknown, enroll via POST .../customers and display the Wallet QR.
Credit the receipt or redeem a reward
On receipt close, call POST .../transactions (operation: earn with amount_cents or redeem_reward) with a receipt-bound Idempotency-Key.
Handle voided receipts
When a receipt is voided or refunded in the POS, call POST .../transactions/:id/refund to reverse the pass balance automatically.
Error Format & HTTP Status Codes
All errors return a consistent JSON envelope with a machine-readable code and a clear message.
Never branch your application logic on error.message text—always match against the stable error.code identifier.
{
"error": {
"code": "insufficient_loyalty_balance",
"message": "Insufficient loyalty balance (required: 50, available: 30)."
}
}
| HTTP | Error code | Description |
|---|---|---|
| 400 | missing_idempotency_key | The Idempotency-Key header is missing on an endpoint that requires it. |
| 401 | missing_api_key / invalid_api_key | API key is missing, malformed, or unknown. |
| 401 | revoked_api_key / expired_api_key | The API key or parent partner account has been revoked or suspended. |
| 401 | invalid_signature / replay_detected | Missing/invalid HMAC-SHA256 signature, timestamp outside ±5 min window, or replayed signature. |
| 402 | subscription_required | The merchant's POS/scanner subscription has expired (HTTP 402). |
| 403 | secret_key_required | Server-only endpoint (sk_): publishable keys (pk_) are strictly forbidden. |
| 403 | secret_key_in_browser | Attempted to use a secret key (sk_) from a browser context (Origin header detected). |
| 403 | environment_mismatch | A test key (sk_test_) attempted to access a live production merchant. |
| 403 | invalid_origin | Browser Origin header is not allowlisted on this publishable key. |
| 403 | ip_not_allowed | Caller server IP is not included in the API client's allowed CIDR ranges. |
| 403 | insufficient_scope / self_approval_forbidden | Authenticated key lacks the required permission scope for this endpoint. |
| 403 | merchant_inactive | The merchant account is deactivated or suspended; POS mutations are blocked. |
| 403 | card_belongs_to_other_merchant | Scanned pass or card belongs to another store (zero customer PII exposed). |
| 403 | captcha_required | Bot challenge required or provided X-Captcha-Token failed verification. |
| 404 | customer_not_found | No enrolled customer matched the provided code, phone, email, or UUID. |
| 409 | idempotency_key_conflict / campaign_already_processed | The same Idempotency-Key was reused with different request parameters. |
| 409 | transaction_already_refunded | This transaction has already been refunded/reversed. |
| 410 | campaign_approval_expired | The approval window for this campaign draft has expired (7-day limit). |
| 422 | direct_send_forbidden | Direct campaign dispatch via API is forbidden; campaigns must stay in pending_approval. |
| 422 | insufficient_loyalty_balance / insufficient_funds | Insufficient points, stamps, gift card, or prepaid balance for this operation. |
| 422 | insufficient_balance_for_refund | Cannot refund a gift card or prepaid top-up whose balance has already been spent. |
| 422 | terms_not_accepted | owner.accept_terms was not explicitly set to true. |
| 422 | invalid_pin | merchant.pin is missing or is not an exact 4-digit string. |
| 429 | rate_limited | Per-minute request quota exceeded. Wait for the duration specified in Retry-After. |