Skip to content

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.

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.

  1. Get access. MarsX gives your developer access to the sandbox console. If you have no access yet, contact MarsX.

  2. 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.

  3. 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.

Open the sandbox console

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.

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.

  1. 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"
  2. Sign and send one lead. The script builds a lead.new, signs webhook-id, webhook-timestamp and the raw body, and posts it. It refuses any URL that is not https and does not follow redirects.

  3. Read the answer. A 202 with "result": "accepted" means MarsX has stored the event and queued it.

quickstart.sh
#!/usr/bin/env bash
set -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.

What the script sent
POST /v1/sources/conn_exampleexample22/events
content-type: application/json
webhook-id: msg_quickstart_1791100800
webhook-timestamp: 1791100800
webhook-signature: v1,<base64 signature>
What MarsX answered, 202
{
"result": "accepted",
"webhook_id": "msg_quickstart_1791100800",
"request_id": "req_example_0001"
}

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

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.