Skip to content

Receive deliveries and verify signatures

Your application receives work from the platform as HTTP POSTs: deliveries of dispatch jobs (events matched by your subscriptions, and direct jobs) and scheduled-job firings. This page builds a receiver that checks every request really came from the platform, processes it once, and answers so the platform does the right thing next. Delivery is the full description of the request and the answers.

A POST to the target URL with:

  • a body: the JSON envelope (id, type, attemptNumber, time, source, subject, messageGroup, correlationId, clientId, clientCode, data), or the raw payload when the subscription or job is data-only;
  • X-Dispatch-Job-Id and X-Event-Type (the job id and code);
  • X-FlowCatalyst-Client: {clientId}:{clientCode} when the job belongs to a client;
  • X-FlowCatalyst-Timestamp and X-FlowCatalyst-Signature, and Authorization: Bearer <token>, when the signing service account has those credentials.

Deliveries are signed with a service account’s signing secret: the account of the subscription’s connection, or for application-owned connections and scheduled-job firings, your application’s own service account (see who signs a delivery). The secret is never shown after it is created. To get a value you can configure, open the service account in the console (Service accounts) and choose Regenerate Secret under Signing Secret (HMAC-SHA256), or call POST /api/service-accounts/{id}/regenerate-signing-secret. Store it in your secret manager and expose it to the receiver, conventionally as FLOWCATALYST_SIGNING_SECRET.

The signature is hex(HMAC-SHA256(secret, timestamp + rawBody)). Verify over the exact bytes you received, before any JSON parsing: re-serialised JSON has different bytes. The SDK verifiers also refuse a timestamp older than 5 minutes (a replay guard) or too far in the future, compare in constant time, and fail closed when the secret is empty.

verifier := webhook.NewVerifier(os.Getenv("FLOWCATALYST_SIGNING_SECRET"))
func handle(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil {
http.Error(w, "read body", http.StatusBadRequest)
return
}
if err := verifier.Verify(body, r.Header.Get(webhook.SignatureHeader), r.Header.Get(webhook.TimestampHeader)); err != nil {
http.Error(w, "invalid signature", http.StatusUnauthorized)
return
}
var env struct {
ID string `json:"id"`
Type string `json:"type"`
Data json.RawMessage `json:"data"`
}
_ = json.Unmarshal(body, &env)
// ... process, keyed on env.ID ...
w.WriteHeader(http.StatusOK)
}

webhook.Validator (ValidatorFromEnv, Validate(sig, ts, body)) is the same check with sentinel errors for each failure; prefer Verifier in new code.

The bearer token is optional extra. The Authorization: Bearer header carries the service account’s auth token, a static credential. Some verifiers can require it as a second gate (expectedBearerToken in TypeScript, with_bearer_token in Rust, FLOWCATALYST_WEBHOOK_AUTH_TOKEN in Laravel). It is never a substitute for the signature, which binds the secret to this body at this time.

Delivery is at least once: a timeout, a lost answer or an operator’s requeue can bring the same job again. Make the handler idempotent with the job id (X-Dispatch-Job-Id, or id in the envelope), for example a unique key on a “processed deliveries” table written in the same transaction as the work. Within a message group the platform delivers in order, so you can rely on seeing an aggregate’s events in sequence (see ordering).

Answer Effect on the job
2xx Done: COMPLETED.
2xx with {"ack": false, "notBefore": "<RFC 3339>", "delaySeconds": n} Deferred: back to waiting, delivered again at notBefore (else after delaySeconds, else 30 seconds). No attempt is used. Send both fields.
429, with Retry-After Deferred for that long (30 seconds without the header). No attempt is used.
401 or 403 Failed at once: retrying with the same credentials cannot help.
422 with the header FlowCatalyst-Outcome: reject Failed at once: “this will never work”.
5xx, another 4xx, a timeout, a connection error A failed attempt; retried with backoff until its attempts run out, then FAILED.

Use ack: false when you are healthy but cannot take this one yet: a record it depends on has not arrived, a downstream system is in maintenance, you are throttling yourself. It is not counted as a failure. Deferrals are not capped, so in a BLOCK_ON_ERROR subscription an endless deferral holds the group.

w.Header().Set("Content-Type", "application/json")
later := time.Now().Add(2 * time.Minute).UTC()
_ = json.NewEncoder(w).Encode(map[string]any{
"ack": false, "notBefore": later.Format(time.RFC3339), "delaySeconds": 120,
})

Keep the handler fast. A delivery waits at most the job’s timeout (30 seconds by default, never more than 2 minutes); answer once the work is safely recorded, and do long work in the background.

A job that belongs to a client carries X-FlowCatalyst-Client: {clientId}:{clientCode} (and clientId / clientCode in the envelope). Route the work to that tenant with it, after the signature check. The Rust SDK parses it with parse_client_header. clientCode is left out when the client cannot be resolved.

A subscription or job with dataOnly: true sends the payload byte for byte with its own Content-Type (XML stays XML), and the identifying fields travel only in the headers. Verification is identical: the signature covers whatever bytes were sent. Use data-only when the receiver expects a fixed format that is not FlowCatalyst’s envelope.

Sign a body yourself with the same secret and post it:

Terminal window
ts=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
body='{"id":"test1","type":"orders:sales:order:placed","data":{"orderId":"ord_1"}}'
sig=$(printf '%s%s' "$ts" "$body" | openssl dgst -sha256 -hmac "$FLOWCATALYST_SIGNING_SECRET" -hex | awk '{print $NF}')
curl -i -X POST http://localhost:3000/webhooks/orders \
-H "Content-Type: application/json" \
-H "X-FlowCatalyst-Timestamp: $ts" -H "X-FlowCatalyst-Signature: $sig" \
-d "$body"

Laravel has a command that checks a captured delivery against the configured secret: php artisan flowcatalyst:verify-signature --timestamp=... --signature=... --body-file=body.json. With fcdev, a subscription may target localhost; a deployed platform refuses loopback and private targets by default.

Regenerating a signing secret replaces it immediately: deliveries from that moment are signed with the new secret, and a receiver still holding the old one answers 401, which fails those jobs at once. Rotate in a quiet moment, update the receiver straight away, then requeue anything that failed in between from the console’s Dispatch jobs page.

Symptom Cause
Every delivery fails 401 with a signature error The receiver has another account’s secret, an old one, or verifies a re-serialised body.
timestamp expired The receiver’s clock is wrong, or you are replaying an old captured request.
Deliveries arrive without signature headers The signing account has no credentials, or none could be resolved; the attempt in the console records why. Fix the account rather than accepting unsigned requests.
The same job arrives twice Expected under at-least-once delivery; deduplicate on the job id.