<iframe> on your page and receive KYC results and credential decisions directly in the parent window via an encrypted postMessage - no server-to-server webhook required for the real-time channel.
This guide covers the client-side integration only. You still need to create a request via the API to obtain a
sessionId before embedding the iframe.How It Works
- Your page generates an ECDH P-256 key pair using the Web Crypto API.
- The public key and your origin are passed as query parameters when loading the iframe.
- The backend validates your origin against the allowlist configured in the dashboard.
- After the user completes the flow, the iframe sends an encrypted
postMessageto your page. - Your page decrypts the payload using its private key to obtain the KYC result.
Prerequisites
- HTTPS - Both your page and the iframe must be served over HTTPS. The Web Crypto API is not available in insecure contexts.
- Allowed origins - Your embedding origin must be registered in the Humanos Dashboard under Settings → Notifications. Up to 10 HTTPS origins can be configured.
- A valid session - You need a
sessionIdfrom the request generation API before embedding.
Step 1: Generate an ECDH Key Pair
Generate a P-256 key pair using the Web Crypto API. Mark the private key as non-extractable so it cannot be read by other scripts on the page.keyPair.privateKey reference - you will need it later to decrypt the payload.
Step 2: Build and Load the Iframe
Construct the iframe URL by appendingpubKey and postMessageOrigin as query parameters to the Link URL.
src of your iframe element:
The
allow="camera" attribute is required if the flow includes identity
verification (KYC), as it needs camera access for the selfie and document scan
steps.Step 3: Listen for the Encrypted PostMessage
Register amessage event listener on the window. Always verify the event.origin matches the expected Humanos origin before processing.
Step 4: Decrypt the Payload
The payload is encrypted using ECDH P-256 + HKDF-SHA256 + AES-256-GCM. The decryption process derives a shared secret from the backend’s ephemeral public key and your private key, then uses HKDF to produce the AES key.Payload Structure
Once decrypted, the payload contains the KYC result and credential decisions:| Field | Type | Description |
|---|---|---|
version | string | Payload format version (currently "1") |
eventType | string | Event type (currently "kyc_complete") |
requestId | string | The request identifier |
sessionId | string | The session identifier used to load the iframe |
timestamp | string | ISO 8601 timestamp of the event |
identity | object | null | Identity data from KYC verification, or null if not applicable |
credentials | array | List of credential decisions |
Identity Object
| Field | Type | Description |
|---|---|---|
fullName | string | Full name as extracted from the document |
birth | string | Date of birth |
docId | string | Document number |
documentType | string | null | Type of document used (e.g., PASSPORT, ID_CARD) |
countryAlpha3 | string | ISO 3166-1 alpha-3 country code |
veriffRiskScore | number | null | Risk score from identity verification provider |
Credential Object
| Field | Type | Description |
|---|---|---|
id | string | Credential identifier |
name | string | Display name of the credential |
resourceType | string | Type of resource (identity, signature, consent, form, mandate) |
status | string | Decision status (accepted, rejected) |
decisionDate | string | ISO 8601 timestamp of the decision |
Wire Format
The encrypted message sent viapostMessage has the following structure:
Complete Example
Below is a self-contained example that generates a key pair, loads the iframe, listens for the encrypted message, and decrypts the payload.Security Considerations
- Origin validation - The backend validates
postMessageOriginagainst your configured allowlist. If the origin is not registered, no encrypted payload will be generated. - Non-extractable private key - The private key is generated with
extractable: false, preventing any script from reading the raw key material. - Ephemeral keys - The backend generates a fresh ephemeral key pair for each payload, so compromising one message does not compromise others.
- Authenticated encryption - AES-256-GCM provides both confidentiality and integrity. Tampered ciphertext will fail decryption.
Dashboard Configuration
To enable iframe postMessage notifications:- Navigate to Humanos Dashboard → Settings → Notifications.
- Toggle Embed notifications on.
- Add your allowed origins (HTTPS only, up to 10).
postMessage events regardless of the query parameters provided.