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
2xxstatus 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 theGETendpoint 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
callbackUrlwith 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.
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.
- C#
- Dart
- Go
- JavaScript
- Java / Kotlin
- PHP
- Python
- Ruby
- Rust
- Swift
var valid = CallbackSignature.Verify(rawBody, signatureHeader, hmacKey);
final valid = verifyCallbackSignature(rawBodyBytes, request.headers['x-signature-sha256']!, hmacKey);
valid := identisure.VerifyCallbackSignature(rawBody, r.Header.Get("X-Signature-SHA256"), hmacKey)
import { verifyCallbackSignature } from "@identisure/client";
const valid = await verifyCallbackSignature(rawBody, req.headers["x-signature-sha256"], hmacKey);
boolean valid = CallbackSignature.verify(rawBody, request.getHeader("X-Signature-SHA256"), hmacKey);
use Identisure\Client\CallbackSignature;
$valid = CallbackSignature::verify($rawBody, $request->getHeaderLine('X-Signature-SHA256'), $hmacKey);
from identisure_client import verify_callback_signature
valid = verify_callback_signature(raw_body, headers["X-Signature-SHA256"], hmac_key)
valid = Identisure.verify_callback_signature(raw_body, signature_header, hmac_key)
let valid = identisure_client::verify_callback_signature(&raw_body, signature_header, hmac_key);
let valid = CallbackSignature.verify(body: rawBody, signature: signatureHeader, secret: hmacKey)
Verifying without an SDK
- Node.js
- Python
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().
import base64
import hashlib
import hmac
def is_valid_signature(raw_body: bytes, signature_header: str, hmac_key: str) -> bool:
expected = hmac.new(hmac_key.encode(), raw_body, hashlib.sha256).digest()
return hmac.compare_digest(base64.b64encode(expected).decode(), signature_header or "")
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.
| Provider | Callbacks for |
|---|---|
| BankID (SE) | Authentication, signing, age verification |
| BankID (NO) | Authentication, signing, age verification |
| Freja eID | Authentication, signing, age verification |
| MitID | Authentication, signing, age verification |
| Vipps | Authentication |
| FTN | Age 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.