Long-running endpoints can deliver their results to a webhook URL of your choosing rather than holding the HTTP connection open. This is how /v1/rfc/verify-batch works exclusively, and it is an option on /v1/rfc/validate, /v1/rfc/find-zip, and /v1/rfc/commerce-registry.
Reading a voter ID has it too: /v1/ine/card takes webhook_url as a form field, and a hosted session (/v1/ine/sessions) posts its result when the person finishes.
How it works
-
Pass
webhook_urlin the request body. http or https only. Redirects are not followed. Max length: 2048 characters. - The API immediately returns 202 Accepted with a small status envelope, then continues processing.
- Once the work is done, we POST a JSON payload to your URL. The payload's status/body envelope mirrors the synchronous response.
Payload shape
{
"status": 200,
"body": {
"rfc": "XAXX010101000",
"valid": true,
"message": "RFC válido, puede ser utilizado en comprobantes",
"...": "rest of the endpoint's normal response body"
}
}
Receiving webhooks
- Respond with any 2xx status as quickly as possible. We treat anything else as a delivery failure.
- Webhooks are best-effort. Each result is sent once, with a 30-second timeout, and is not retried, so keep your endpoint reachable.
- Always check that the body belongs to a request you sent: the rfc for the RFC endpoints, the session id or your own reference for a hosted session. Don't trust a webhook payload to identify which user it belongs to; use a tenant-scoped URL or include a token in the path.
Verify the signature
Every webhook is signed, so your server can tell it came from us and was not changed on the way. Check the signature before you act on a result: anyone who learns your webhook URL can post to it.
-
webhook-id: a unique id for the message. Keep the ones you have handled to ignore a repeat. -
webhook-timestamp: when it was sent, in Unix seconds. -
webhook-signature: v1, followed by the Base64 HMAC-SHA256 of the id, the timestamp, and the raw body, joined by dots.
The key is your webhook signing secret, found on the API keys page of your dashboard (an organization has its own): drop its whsec_ prefix and decode the rest from Base64. Hash the body exactly as it arrived, before any JSON parsing, compare in constant time, and refuse a timestamp more than 5 minutes away from your clock, so an old delivery cannot be sent again. Rotating the secret signs every later webhook with the new one.
import crypto from "node:crypto";
function verifyWebhook(secret, headers, rawBody) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const expected = "v1," + crypto.createHmac("sha256", key)
.update(`${id}.${timestamp}.${rawBody}`)
.digest("base64");
return headers["webhook-signature"].split(" ").some((signature) =>
signature.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected)));
}
import base64, hashlib, hmac, time
def verify_webhook(secret: str, headers, raw_body: bytes) -> bool:
msg_id = headers["webhook-id"]
timestamp = headers["webhook-timestamp"]
if abs(time.time() - int(timestamp)) > 300:
return False
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{msg_id}.{timestamp}.".encode() + raw_body
expected = "v1," + base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
return any(hmac.compare_digest(signature, expected)
for signature in headers["webhook-signature"].split())
The scheme is Standard Webhooks, so its libraries for most languages can check the signature for you.
Webhooks for requests made through RapidAPI are not signed: the account is RapidAPI's, so there is no secret here to share with you.
Local testing
Use a tunnel like ngrok, Cloudflare Tunnel, or Tailscale Funnel to expose your local dev server. We do not need to reach you from inside a private network. Any publicly resolvable URL will do.