Skip to content

Sign requests

A signature proves that a request came from you and arrived unchanged. MarsX follows Standard Webhooks 1.0.0 and accepts one scheme: HMAC v1. Sign on your server, never in a browser or an app. Libraries for many languages are listed at standardwebhooks.com.

  1. Build the string to sign. Join the webhook-id, a full stop, the webhook-timestamp, a full stop and the raw request body: webhook-id + . + webhook-timestamp + . + body. The body is the exact bytes you send. Sign those bytes and send that same body: a trailing newline, an extra space or a re-formatted body changes the signature, and MarsX answers 401.
  2. Decode the secret. Remove the whsec_ prefix, then base64-decode the rest. The result is the decoded secret.
  3. Compute HMAC-SHA256 of the string with the decoded secret. The result is 32 bytes.
  4. Send v1, followed by the base64 of those 32 bytes in the webhook-signature header.
Header Value
webhook-id A new id for each event: 1 to 128 characters from A-Z a-z 0-9 _ -. The same value on every retry of the same event, and never on a different event (that gets 409). No full stop, colon, plus, slash or space. Any other id gets the same 401 as a bad signature
webhook-timestamp The time of this attempt in whole seconds since the Unix epoch. It changes on every retry. It must be within 300 seconds of the MarsX clock, in either direction. Keep your servers on network time (NTP)
webhook-signature v1,<base64>. During a change of signing secret, two signatures separated by a space. At most 4 signatures: a header with more gets the generic 401

Each sample takes the secret, the id, the timestamp and the raw body, and returns the header value.

sign.sh
# Needs OpenSSL 1.1 or newer, or the LibreSSL that ships with macOS, and xxd.
sign_v1() { # sign_v1 <secret> <webhook-id> <timestamp> <body>
local key_hex
key_hex="$(printf '%s' "${1#whsec_}" | openssl base64 -d -A | xxd -p -c 256)"
printf 'v1,%s' "$(printf '%s.%s.%s' "$2" "$3" "$4" \
| openssl dgst -sha256 -mac HMAC -macopt "hexkey:${key_hex}" -binary \
| openssl base64 -A)"
}

Run these made-up inputs through your code before you send anything. The secret is used nowhere. Every input and the expected result are given.

Input Value
Secret whsec_ZmljdGlvbmFsLXRlc3Qtc2VjcmV0LWRvLW5vdC11c2U=
Decoded secret The 32 ASCII characters fictional-test-secret-do-not-use
webhook-id msg_test_0001
webhook-timestamp 1791100800 (4 October 2026, 15:00:00 at +07:00)
Body The single line below, 350 bytes, no line break at the end
body
{"type":"lead.withdraw","timestamp":"2026-10-04T15:00:00+07:00","data":{"partner_lead_id":"SRC-TEST-0001","source_revision":3,"record_action":"withdraw","created_at":"2026-10-01T09:15:00+07:00","updated_at":"2026-10-04T15:00:00+07:00","request_type":"withdraw_consent","request_time":"2026-10-04T14:59:30+07:00","request_reference":"PRIV-TEST-0001"}}

The string that is signed: the id, a full stop, the timestamp, a full stop, then the body.

signed string
msg_test_0001.1791100800.{"type":"lead.withdraw","timestamp":"2026-10-04T15:00:00+07:00","data":{"partner_lead_id":"SRC-TEST-0001","source_revision":3,"record_action":"withdraw","created_at":"2026-10-01T09:15:00+07:00","updated_at":"2026-10-04T15:00:00+07:00","request_type":"withdraw_consent","request_time":"2026-10-04T14:59:30+07:00","request_reference":"PRIV-TEST-0001"}}

This webhook-timestamp is fixed so that you can check your signature. It is far older than 300 seconds, so you cannot send this request as it is: MarsX would answer 401. When you send for real, use the current time.

Expected result:

expected header
webhook-signature: v1,fzi3+AruxTHPp63y+tTDa97ZUOcbMHHhKNLnXyz/CSM=
  • The signature proves the request came from you. If one character changes on the way, it no longer fits.
  • The timestamp stops someone from copying a real request and sending it later. A copy goes stale in five minutes.
  • The webhook-id lets MarsX recognise a request that arrives twice, for example after a lost answer. It stores nothing new. The source_revision decides which version of a lead wins, not the id.
  • One secret for each connection and environment keeps the damage small if a secret leaks. The sandbox secret never works in production.
  • Signing a re-serialised body instead of the bytes that go on the wire.
  • Reusing an old webhook-timestamp on a retry.
  • Putting a full stop inside webhook-id.
  • Using the sandbox secret in production, or the secret of another connection.
  • Leaving off the v1, prefix, or sending the hex of the digest instead of base64.

Change it from time to time, and at once if you think someone else has seen it. You can change it without dropping events.

  1. Rotate the key in Concour. Your developer opens Developers, then API keys, and chooses Rotate next to the key, then Rotate key. A new key is made at once and its secret works now.

  2. Save the new secret. The dialog Your new key shows the new Signing secret once. Copy it, then choose I have saved it. It never travels by email or WhatsApp. The old key shows as Replaced, works until a date.

  3. Sign with both secrets during the overlap. Send both signatures in one header, separated by a space. MarsX accepts either:

    webhook-signature: v1,<signature with the old secret> v1,<signature with the new secret>
  4. Test it in the sandbox first. Check that events are accepted with the old secret alone, the new secret alone and both.

  5. Switch to the new secret alone within the overlap. Concour says: The old key keeps working for 7 days, then stops. Change your system to the new key within that time.

The old secret stops working 7 days after you rotate. To end the overlap sooner, choose Revoke next to the old key and type its name to confirm. Revoke it at once if it may have leaked: it stops working immediately, and this cannot be undone. On a retry during the overlap, keep the same webhook-id and body, and make a fresh webhook-timestamp and fresh signatures with both secrets.