Integrate with MCIDInbound webhooks

Inbound webhooks: signing and sending

Sign and send a submission with Node, Python or curl: the signature, replay protection, the origin allowlist and the rate limit.

Each request to an inbound webhook carries your API key and, unless an admin switched it off, a signature. The signature proves the body is exactly what your backend produced and was not replayed. This page shows how to compute it, with runnable examples, and what MCID answers when something is wrong.

What you send

POST /api/inbound-webhooks/{id}/submit
X-API-Key: pk_xxxxxxxx.your-secret
X-MCID-Signature: t=1791234567,v1=9f2c...e1
Content-Type: application/json

{ ...your JSON... }
PartWhat it is
{id}The webhook's ID, a UUID.
X-API-KeyYour project's API key. See API keys and server access.
X-MCID-Signaturet=<unix seconds>,v1=<hex signature>.
BodyJSON that matches the webhook's schema.

The key identifies the project, and the webhook must belong to it. The signature adds proof about this particular request. You need both. A webhook that an admin set to not require a signature needs only the key.

How the signature is computed

  1. Take the current time as whole seconds since 1970. Call it t.
  2. Build the string "<t>.<body>": the number, a dot, then the exact bytes of the JSON body you will send.
  3. Compute HMAC-SHA256 of that string, with the webhook's signing secret as the key, and write it as lowercase hex. That is v1.
  4. Send X-MCID-Signature: t=<t>,v1=<v1>.

The signing secret is the whole string the admin panel showed, whsec_ followed by 64 hex characters, prefix included. It is different from your API key.

Warning

Sign the exact string you send. MCID checks the signature against the raw request body, so spaces and key order count. If you build the signature from one serialisation and send another, for example signing compact JSON and then sending it pretty-printed, every request fails with SIGNATURE_MISMATCH. Serialise once, then use that same string for both the signature and the body.

Examples

Set these environment variables first, then run the script. The signing secret and webhook ID come from an admin.

export MCID_URL=http://localhost:3000/api
export MCID_API_KEY=pk_xxxxxxxx.your-secret-here
export WEBHOOK_ID=00000000-0000-4000-8000-000000000000
export SIGNING_SECRET=whsec_your-signing-secret

Save as send.mjs and run node send.mjs. It needs Node 18 or later and no packages.

import { createHmac } from 'node:crypto';

const { MCID_URL, MCID_API_KEY, WEBHOOK_ID, SIGNING_SECRET } = process.env;

const body = JSON.stringify({
  identity: { firstname: 'Amina', email: 'amina@usthb.dz', status: 'student' },
  background: { university: 'USTHB' },
});

const t = Math.floor(Date.now() / 1000);
const v1 = createHmac('sha256', SIGNING_SECRET).update(`${t}.${body}`).digest('hex');

const res = await fetch(`${MCID_URL}/inbound-webhooks/${WEBHOOK_ID}/submit`, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': MCID_API_KEY,
    'X-MCID-Signature': `t=${t},v1=${v1}`,
  },
  body,
});

console.log(res.status, await res.json());

All three print the same kind of result, a 201 with the submission's ID and the time MCID received it:

{ "id": "c8cf02b1-4831-4791-9d4c-7f21857c272d", "receivedAt": "2026-10-05T18:18:21.024Z" }

Keep the signing secret on your server, like the API key. Rotate it when an admin or a developer who knew it leaves, or when it may have leaked. After a rotation, requests signed with the old secret fail at once.

What MCID checks, in order

A request passes these checks one after another and stops at the first that fails:

OrderCheckFailure
1The API key is valid401 API key is required or Invalid API key
2The webhook exists and belongs to your project404 Inbound webhook not found
3The webhook is active410 This webhook is no longer active
4The origin is allowed, when the webhook limits origins403
5The signature is valid and has not been used, when required401 or 409
6The rate limit holds429
7The payload matches the schema422

Every failure of the signature has the same shape, with a reason that says which:

{ "statusCode": 401, "error": "InvalidSignature", "reason": "SIGNATURE_MISMATCH" }
reasonMeaning
MALFORMED_HEADERThe header is missing, or is not t=<digits>,v1=<hex>.
STALE_TIMESTAMPt is more than 5 minutes away from MCID's clock, in either direction.
SIGNATURE_MISMATCHThe signature does not match the body: wrong secret, or the body changed after signing.

Replay protection

A signature can be used once. The second request with the same signature gets a 409:

{ "message": "This request has already been processed", "error": "Conflict", "statusCode": 409 }

MCID remembers each accepted signature for twice the 5 minute tolerance, which covers a timestamp that is slightly in the future. So an attacker who copies a request from the wire cannot send it again.

Two things follow:

  • Two requests with the same body signed in the same second have the same signature, so the second is refused as a replay. If your system can legitimately send the same payload twice in a second, add something that differs, such as an ID or a timestamp, to the payload.
  • A request refused with a 422 does not use up its signature. Nothing was stored, so you can fix the problem and send again. A new signature is still the cleanest way.

Replay protection and the rate limit rely on Redis. If Redis is unreachable, MCID keeps accepting valid requests instead of refusing all of them, so replay checks and the rate limit pause until it is back.

The tolerance is 300 seconds by default. An operator can change it with the INBOUND_WEBHOOK_SIGNATURE_TOLERANCE_S setting of the API. Keep your server's clock in sync, because a clock that drifts by more than the tolerance makes every request fail with STALE_TIMESTAMP.

Sending a form one step at a time

A webhook whose schema has steps can also be filled over several requests, for a wizard that saves each page as it goes. A draft holds the steps sent so far. Three calls use the same API key, origin check and signature as /submit:

POST  /api/inbound-webhooks/{id}/drafts
PATCH /api/inbound-webhooks/{id}/drafts/{draftId}/{stepKey}
POST  /api/inbound-webhooks/{id}/drafts/{draftId}/submit
CallBodyAnswer
POST .../draftsNone. The signature covers "".201 with { "draftId": "...", "expiresAt": "..." }.
PATCH .../{step}The step's fields, as a JSON object.200 with { "draftId", "stepKey", "completedSteps", "expiresAt" }.
POST .../submitNone. The signature covers "".201 with { "id": "...", "receivedAt": "..." }.
  • A step is checked on its own. Only the fields of that step are validated, and every error in it comes back at once as a 422. Its conditions can read the steps already saved. A step that does not apply because of its condition is accepted and ignored.
  • Sending a step again replaces it. This is how a caller resumes or corrects: it keeps the draftId and sends the step it wants to change. completedSteps in each answer lists what is saved.
  • The submit checks everything. The saved steps are validated as one payload, with conditions resolved across steps, so a step that was never sent fails its required fields and an answer changed later is rechecked. A 422 leaves the draft open.
  • A draft is submitted once. A second submit, or a patch after the submit, answers 409.
  • A draft expires. It lasts 24 hours from the moment it was opened, and an operator can change that with INBOUND_WEBHOOK_DRAFT_TTL_H. Sending to an expired draft answers 410, and the caller opens a new one.
  • A draft belongs to one webhook and one project. An unknown draft, or one of another webhook, answers 404.
  • A webhook with only fields has no steps and no drafts: POST .../drafts answers 400, so send the payload to /submit.

Each of these calls counts toward the rate limit below, like a /submit.

Sending files

A file never travels inside the JSON of a submission. A webhook with file or files fields takes them in two steps, so the signed body stays small and a wizard can upload on one page and submit on another:

POST /api/inbound-webhooks/{id}/files      multipart/form-data, one part named "file"
POST /api/inbound-webhooks/{id}/submit     JSON, with { "fileId": "..." } where the file belongs

The upload answers 201 with { "fileId", "sha256", "size", "mime", "expiresAt" }. Put the fileId in the field, as "cv": { "fileId": "..." }, in /submit or in a draft step.

curl -X POST https://mcid.example/api/inbound-webhooks/$WEBHOOK_ID/files \
  -H "X-API-Key: $MCID_API_KEY" \
  -F "file=@cv.pdf"
  • The signature covers "". The multipart body is not signed, because checking a signature means buffering the whole body before the caller is authenticated. The signature still proves the caller holds the secret, and it is still single-use.
  • The type comes from the content. MCID reads the file's first bytes and ignores the Content-Type the sender gives, so an executable renamed to cv.pdf is refused. A type with no recognizable signature, such as plain text or CSV, is refused too. The type must be in the accept list of at least one file field of the webhook, and /submit then checks it against the field that uses the file.
  • The size is capped while it streams. The cap is the largest maxSizeBytes of the webhook's file fields. A bigger file answers 413 and nothing is stored.
  • Identical content is stored once. Two uploads of the same bytes get two fileIds and share one stored object.
  • An upload expires. It lasts one hour, and an operator can change that with INBOUND_WEBHOOK_FILE_TTL_H. A file that no submission has used by then is deleted, and /submit answers FILE_EXPIRED for it. A file saved in a draft step lives as long as the draft instead, so a wizard can upload on one page and submit a day later.
  • A file belongs to one webhook and one submission. Another webhook's fileId is answered as FILE_NOT_FOUND, and a second submission using it gets FILE_ALREADY_USED.
StatusWhen
400The body is not multipart, has no file, has more than one, or the file is empty. Also for a webhook with no file fields.
413The file is over the largest maxSizeBytes.
415The content is not a type the webhook accepts.
503File storage is not configured on the server.

The upload also answers with the errors every write call shares: 401, 403, 404, 409, 410 and 429. Each upload counts toward the rate limit below.

Origin allowlist

An admin can restrict a webhook to specific origins, for example https://forms.example.com. MCID then compares the request's Origin header with the list, exactly. A request with another origin, or none, gets a 403:

{
  "message": "Origin \"https://evil.example\" is not permitted for this webhook",
  "error": "Forbidden",
  "statusCode": 403
}

Browsers set Origin themselves, so this limits which sites can post from a browser. It is not a defence against other clients, because any program can send any Origin. Do not rely on it for security, and do not put the API key or signing secret in a page. A webhook that is called from your backend usually has no origins listed. If one does, your backend must send the Origin header explicitly.

Rate limit

Each webhook accepts up to 120 submissions a minute, and the project as a whole up to 120 a minute across all its webhooks. Beyond that MCID answers 429 until the minute ends:

{
  "statusCode": 429,
  "error": "RateLimited",
  "message": "Rate limit of 120 requests per minute exceeded"
}

An operator can change the number with INBOUND_WEBHOOK_RATE_LIMIT. Retry later, or batch your data into fewer, larger submissions.

For every error code, see Errors and limits.

Source: apps/api/src/common/utils/inbound-webhook-signature.util.ts, apps/api/src/modules/inbound-webhooks/inbound-webhooks.service.ts, apps/api/src/modules/inbound-webhooks/inbound-webhook-ingest.controller.ts, apps/api/src/modules/inbound-webhooks/files/inbound-webhook-files.service.ts, apps/api/src/common/guards/api-key.guard.ts.

On this page