Quick start
Send one signed lead.new to the sandbox, read the 202, then break it on purpose so you know what an error looks like. It takes about 20 minutes and uses made-up data only.
Prefer clicking to code? Use the Postman collection.
Get sandbox access
Section titled “Get sandbox access”You make the test key in the sandbox console, not in Concour. A live connection in Concour has no Make a test key, because it holds live keys only. Concour is where you get your live key, at go-live.
-
Get access. MarsX gives your developer access to the sandbox console. If you have no access yet, contact MarsX.
-
Sign in. Open the sandbox console and enter the email address MarsX gave developer access. The console emails you a code. Enter it. If the code does not arrive, check your Junk and quarantine folders, then contact support.
-
Make the test key. Open Developers, then API keys (the Open API keys button), type a name under Make a test key and choose Make a test key. The dialog Your test key shows the Signing secret, the Status client ID and the Status secret once. Copy them, then choose I have saved it. Keep the signing secret on your server.
The sandbox console is where test keys are made. It opens the sign-in page. Sign in with the email address MarsX gave developer access: the console emails you a code.
No account? MarsX sets up partner access.
Before you start
Section titled “Before you start”The sandbox console shows the connection reference. You need:
- the connection reference, such as
conn_exampleexample22 - the signing secret, which starts with
whsec_
You also need a server-side runtime: a shell with curl and openssl, Node.js 18 or newer, or Python 3 with requests. Not got your sandbox details yet? Check your signing code offline with the test vector first.
The three steps
Section titled “The three steps”-
Set three variables. Put the connection reference and signing secret in your environment. Never write them into code.
Terminal window export MARSX_CONNECTION="conn_exampleexample22"export MARSX_SIGNING_SECRET="whsec_..."export MARSX_BASE_URL="https://api-sandbox.marsx.media" -
Sign and send one lead. The script builds a
lead.new, signswebhook-id,webhook-timestampand the raw body, and posts it. It refuses any URL that is nothttpsand does not follow redirects. -
Read the answer. A
202with"result": "accepted"means MarsX has stored the event and queued it.
Sign and send
Section titled “Sign and send”#!/usr/bin/env bashset -euo pipefail
: "${MARSX_CONNECTION:?Set MARSX_CONNECTION}": "${MARSX_SIGNING_SECRET:?Set MARSX_SIGNING_SECRET}"BASE_URL="${MARSX_BASE_URL:-https://api-sandbox.marsx.media}"case "$BASE_URL" in https://*) ;; *) echo "Refusing a URL that is not https" >&2; exit 1 ;;esac
TIMESTAMP="$(date +%s)"WEBHOOK_ID="msg_quickstart_${TIMESTAMP}"NOW="$(date -u +%Y-%m-%dT%H:%M:%SZ)"BODY="$(cat <<EOF{ "type": "lead.new", "timestamp": "$NOW", "data": { "partner_lead_id": "SRC-TEST-$TIMESTAMP", "record_action": "new", "created_at": "$NOW", "customer_name": "Contoh Pelanggan", "phone": "+6280000000003", "email": "contoh.pelanggan3@contoh.example", "source_channel": "website_form", "contact_consent": "yes", "consent_time": "$NOW", "model_interest": "Model A", "customer_province": "Jawa Barat", "customer_city": "Kota Bandung", "preferred_dealer_code": "D0001", "test_drive_requested": "N", "enquiry_notes": "Ingin meminta penawaran.", "campaign": "campaign-test" }}EOF)"
KEY_HEX="$(printf '%s' "${MARSX_SIGNING_SECRET#whsec_}" | openssl base64 -d -A | xxd -p -c 256)"SIGNATURE="v1,$(printf '%s.%s.%s' "$WEBHOOK_ID" "$TIMESTAMP" "$BODY" \ | openssl dgst -sha256 -mac HMAC -macopt "hexkey:${KEY_HEX}" -binary \ | openssl base64 -A)"
curl --proto '=https' --max-redirs 0 --silent --show-error --include \ --request POST "$BASE_URL/v1/sources/$MARSX_CONNECTION/events" \ --header "content-type: application/json" \ --header "webhook-id: $WEBHOOK_ID" \ --header "webhook-timestamp: $TIMESTAMP" \ --header "webhook-signature: $SIGNATURE" \ --data-binary "$BODY"Run it with bash quickstart.sh.
import { createHmac } from "node:crypto";
const baseUrl = process.env.MARSX_BASE_URL ?? "https://api-sandbox.marsx.media";const connection = process.env.MARSX_CONNECTION;const secret = process.env.MARSX_SIGNING_SECRET;if (!connection || !secret) throw new Error("Set MARSX_CONNECTION and MARSX_SIGNING_SECRET");if (!baseUrl.startsWith("https://")) throw new Error("Refusing a URL that is not https");
const now = new Date();const stamp = Math.floor(now.getTime() / 1000);const iso = now.toISOString().replace(/\.\d{3}Z$/, "Z");const body = JSON.stringify({ type: "lead.new", timestamp: iso, data: { partner_lead_id: `SRC-TEST-${stamp}`, record_action: "new", created_at: iso, customer_name: "Contoh Pelanggan", phone: "+6280000000003", email: "contoh.pelanggan3@contoh.example", source_channel: "website_form", contact_consent: "yes", consent_time: iso, model_interest: "Model A", customer_province: "Jawa Barat", customer_city: "Kota Bandung", preferred_dealer_code: "D0001", test_drive_requested: "N", enquiry_notes: "Ingin meminta penawaran.", campaign: "campaign-test", },});
const webhookId = `msg_quickstart_${stamp}`;const timestamp = String(stamp);const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");const signature = "v1," + createHmac("sha256", key).update(`${webhookId}.${timestamp}.${body}`).digest("base64");
const response = await fetch(`${baseUrl}/v1/sources/${connection}/events`, { method: "POST", redirect: "manual", // a 3xx is a failure, never a retry target headers: { "content-type": "application/json", "webhook-id": webhookId, "webhook-timestamp": timestamp, "webhook-signature": signature, }, body, signal: AbortSignal.timeout(20_000),});console.log(response.status, await response.text());Run it with node quickstart.mjs.
import base64import hashlibimport hmacimport jsonimport osimport timefrom datetime import datetime, timezone
import requests
base_url = os.environ.get("MARSX_BASE_URL", "https://api-sandbox.marsx.media")connection = os.environ["MARSX_CONNECTION"]secret = os.environ["MARSX_SIGNING_SECRET"]if not base_url.startswith("https://"): raise SystemExit("Refusing a URL that is not https")
stamp = int(time.time())iso = datetime.fromtimestamp(stamp, timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")body = json.dumps( { "type": "lead.new", "timestamp": iso, "data": { "partner_lead_id": f"SRC-TEST-{stamp}", "record_action": "new", "created_at": iso, "customer_name": "Contoh Pelanggan", "phone": "+6280000000003", "email": "contoh.pelanggan3@contoh.example", "source_channel": "website_form", "contact_consent": "yes", "consent_time": iso, "model_interest": "Model A", "customer_province": "Jawa Barat", "customer_city": "Kota Bandung", "preferred_dealer_code": "D0001", "test_drive_requested": "N", "enquiry_notes": "Ingin meminta penawaran.", "campaign": "campaign-test", }, }, separators=(",", ":"),).encode()
webhook_id = f"msg_quickstart_{stamp}"timestamp = str(stamp)key = base64.b64decode(secret.removeprefix("whsec_"))digest = hmac.new(key, f"{webhook_id}.{timestamp}.".encode() + body, hashlib.sha256).digest()signature = "v1," + base64.b64encode(digest).decode()
response = requests.post( f"{base_url}/v1/sources/{connection}/events", data=body, headers={ "content-type": "application/json", "webhook-id": webhook_id, "webhook-timestamp": timestamp, "webhook-signature": signature, }, allow_redirects=False, # a 3xx is a failure, never a retry target timeout=20,)print(response.status_code, response.text)Run it with python3 quickstart.py.
Read the answer
Section titled “Read the answer”POST /v1/sources/conn_exampleexample22/eventscontent-type: application/jsonwebhook-id: msg_quickstart_1791100800webhook-timestamp: 1791100800webhook-signature: v1,<base64 signature>{ "result": "accepted", "webhook_id": "msg_quickstart_1791100800", "request_id": "req_example_0001"}Break it on purpose
Section titled “Break it on purpose”Each of these takes one change to the script. Expect the answer on the right.
| Change | Expect |
|---|---|
Send the same webhook-id again, with the same body and a fresh webhook-timestamp and signature |
202 with "result": "duplicate". MarsX processes the event once |
| Change one character of the secret | 401. A bad signature, a stale timestamp and a wrong connection reference all give the same 401 |
| Use a timestamp more than 300 seconds old | 401 |
Delete contact_consent |
400 with a pointer to the field. Nothing is stored |
Next steps
Section titled “Next steps”The quick start sends one event. A working integration also needs updates, privacy events, retries and, if you want a safety net, four optional endpoints that MarsX reads.

