Skip to Content
MYIDIIDocs

Webhooks

Get results pushed to your server, and check that each one really came from MYIDII.

Webhooks save you from polling. When a check finishes, we POST a signed event to your URL.

Add an endpoint

In the dashboard, open Developers, then Webhooks, and add your URL. Pick the events you want, and use Send test to try it. You'll get a signing secret that starts with whsec_: store it on your server like your secret key.

Sandbox and live have their own endpoints and secrets. Live endpoints must use https.

Verify every event

Each request carries a MYIDII-Signature header. Check it against the raw request body, before parsing it as JSON, or the signature won't match.

app/api/webhooks/myidii/route.ts
import { Myidii } from "@myidii/node";

export async function POST(req: Request) {
  const raw = await req.text();
  let event;
  try {
    event = Myidii.webhooks.constructEvent(raw, req.headers.get("myidii-signature"), process.env.MYIDII_WEBHOOK_SECRET!);
  } catch {
    return new Response("Bad signature", { status: 400 });
  }

  if (event.type === "session.completed") {
    const session = event.data; // the session object
    // Mark the person as verified if session.status === "passed"
  }
  return new Response("ok");
}

Respond quickly

Reply with any 2xx status within 10 seconds. Do slow work after you reply, in a queue or background job. Redirects aren't followed.

Retries

If your endpoint doesn't reply with 2xx, we try again after 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours: six tries over about seven hours. Every try is listed in the dashboard with your response, and Resend delivers any event again.

Events can arrive more than once and out of order. Use the event id to skip ones you've already handled, and the session's own status as the truth.

Events

See Webhook events for every event and its contents.

On this page