Skip to main content

Callbacks

Instead of polling for a result, you can let IDkollen POST it to your server when it is ready. This page applies to every callback IDkollen sends: eID results, age verifications and the TeleID, TeleSign, SafeMail and FormID events.

Delivery​

POST {{ callbackUrl }}
Content-Type: application/json
User-Agent: IDkollen/2.0
X-Signature-SHA256: base64(hmacSha256(hmacKey, body))
  • Respond with any 2xx status to acknowledge the callback. The response body is ignored.
  • IDkollen waits at most 5 seconds for your server to connect and respond.
  • Redirects are not followed.
  • A callback is sent once and never retried. If your server is down, times out or answers anything but 2xx, the callback is lost. Keep polling as a fallback for results you have not received a callback for, for example with the GET endpoint of the flow a while after it should have finished.
  • Callbacks are sent from the IP addresses listed in the Overview. Allow them in your firewall.

Do the minimum work needed before responding (verify the signature, store the payload, respond 2xx), and process the result afterwards. A slow handler that runs past the timeout loses the callback.

Whitelisting​

The callback URL must be whitelisted by IDkollen before it is used. There are two options:

  • A static URL. IDkollen calls it for every request, and you don't send a callbackUrl.
  • One or more whitelisted domains. You send a callbackUrl with each request, on one of those domains.

TeleID, TeleSign, SafeMail and FormID events always go to your company's static callback URL.

To set up callback URLs, email support@idkollen.se.

Signature​

Each callback is signed so that you can check that it was sent by IDkollen and was not modified on the way. The X-Signature-SHA256 header is the Base64-encoded HMAC SHA-256 of the request body, using a key shared between you and IDkollen.

Your server should reject any callback whose X-Signature-SHA256 header does not match the expected signature.

warning

Calculate the signature from the raw request body, exactly as received. Don't parse the JSON and serialize it again first: a change in formatting, key order or spacing gives a different signature.

The header is only sent if your account has an HMAC key. If you don't have one, request it from support@idkollen.se.

Verifying with an SDK​

Every SDK has a helper that verifies the signature in constant time.

var valid = CallbackSignature.Verify(rawBody, signatureHeader, hmacKey);

Verifying without an SDK​

import { createHmac, timingSafeEqual } from "node:crypto";

function isValidSignature(rawBody, signatureHeader, hmacKey) {
const expected = createHmac("sha256", hmacKey).update(rawBody).digest();
const received = Buffer.from(signatureHeader ?? "", "base64");

return received.length === expected.length && timingSafeEqual(received, expected);
}

With Express, read the raw body with express.raw({ type: "application/json" }) rather than express.json().

Compare signatures with a constant-time function, as above, and not with ==.

Events​

eID results​

The body is the same JSON object as the COMPLETED or FAILED result of the flow's GET endpoint. See Fetch result on each provider's pages, for example BankID (SE) authentication.

ProviderCallbacks for
BankID (SE)Authentication, signing, age verification
BankID (NO)Authentication, signing, age verification
Freja eIDAuthentication, signing, age verification
MitIDAuthentication, signing, age verification
VippsAuthentication
FTNAge verification (authentication has no callback)

The refId you sent when starting the flow is included, so you can match the callback to your own records.

TeleID completed​

Sent when a TeleID identification is completed. Fetch the log with GET /v3/teleid/{id}.

{
"type": "TELEID_COMPLETED",
"log": {
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12"
}
}

TeleSign completed​

Sent when a TeleSign signing is completed. Fetch the log with GET /v3/telesign/{id}.

{
"type": "TELESIGN_COMPLETED",
"log": {
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12"
}
}

SafeMail message received​

Sent when a message reaches your SafeMail inbox. Fetch it with GET /v3/safemail/inbox/{id}.

{
"type": "MESSAGE_RECEIVED",
"message": {
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12"
}
}

FormID submitted​

Sent when a form is submitted. The answers arrive as a SafeMail inbox message, which you fetch with GET /v3/safemail/inbox/{id}.

{
"type": "FORMID_SUBMITTED",
"message": {
"id": "1668b9da-bff1-4dfc-ad48-60507b5a8d12"
},
"form": {
"name": "Contact form"
}
}

New event types may be added in the future. Respond 2xx to events you don't recognize, and ignore them.