Integrate as a Requester
Audience: backend and front-end engineers at an organisation that receives verified KYC data (e-wallet, insurer, fintech). Before this page: your sidecar is running and your Provider partners are allowlisted and verified with Ping. See Set up the sidecar. Contracts: Sidecar API reference.
Integration requires four additions to your sign-up flow: an entry-point button, a redirect to the Auth Portal, a callback handler, and a server-side fetch call—plus optional status checks for held attestations (step 5). Your sidecar handles token signing, CamDX transport, and attestation verification before returning plain KYC fields to your backend.
Step 1: Request a login token
When the customer chooses to verify with a Provider, your backend requests a login token from your sidecar. Never call the sidecar from a browser or mobile app, as your API credentials must remain on your servers.
curl -s -X POST "$SIDECAR_URL/api/v1/requester/token/request" \
-H "Content-Type: application/json" \
-H "x-api-key: $SIDECAR_API_KEY" \
-H "x-api-secret: $SIDECAR_API_SECRET" \
-d '{ "tier": 1, "callback": "https://wallet.example.com.kh/ekyc/callback", "callback_type": "web" }'
{ "token": "eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9..." }
| Field | Rules |
|---|---|
tier | 0 to 3. Request the lowest tier required by your onboarding flow. Each Provider caps the tier it will serve to you via maxTier. |
callback | Absolute URL where the Auth Portal returns the customer with the auth token. Register your callback base URL with the network operator. |
callback_type | web for browser flows, or mobile when the callback targets an app universal link or App Link. |
The sidecar opens a request session and signs the token with your private key. The accept claim lists the codes of enabled Provider partners in your allowlist, which determines which Providers the Auth Portal displays.
Bind the flow to the customer session. The JWT payload is signed rather than encrypted. Decode its ref_id claim and store it in the customer's server-side session; the auth token returned on your callback carries the same ref_id, allowing you to verify that the callback belongs to the customer who initiated the request.
Step 2: Send the customer to the Auth Portal
Redirect the customer's browser to the Auth Portal login URL with the URL-encoded login token:
{AUTH_PORTAL_URL}/login?token={login token}
The network operator provides AUTH_PORTAL_URL during registration. The Auth Portal:
- Verifies that your organisation is an
ACTIVEmember and validates the token signature against yourekyc_pubDNS record. - Displays your branding, the QR code, and the eligible Providers.
If validation fails, the portal displays an error instead of a QR code. See Troubleshooting.
On mobile, open the Auth Portal in the system browser or an in-app browser tab so the customer can also tap a Provider to launch that Provider's app on the same device.
Step 3: Handle the callback
Once the customer approves the share in the Provider's app, the Auth Portal redirects back to your callback URL with the auth token in the q query parameter (preserving any existing query parameters):
https://wallet.example.com.kh/ekyc/callback?q=eyJhbGciOiJFUzUxMiIs...
In your callback handler:
- Read
q. If it is missing, return the customer to the start of sign-up. - Decode the auth token's
ref_idand verify it matches theref_idsaved in step 1. Reject any mismatch. - Call
kyc/fetch(step 4) immediately from your backend. The auth token is single-use and expires 5 minutes after approval. - Never write the auth token to logs, analytics, or error reports.
The portal redirects to your callback only on approval. If the customer denies consent or the session expires, the portal displays the outcome on its own page; provide a restart path on your sign-up page that requests a fresh login token.
Step 4: Fetch the verified data
curl -s -X POST "$SIDECAR_URL/api/v1/requester/kyc/fetch" \
-H "Content-Type: application/json" \
-H "x-api-key: $SIDECAR_API_KEY" \
-H "x-api-secret: $SIDECAR_API_SECRET" \
-d '{ "auth_token": "eyJhbGciOiJFUzUxMiIs...", "tier": 1 }'
tier must not exceed the tier requested in step 1 (normally the same value).
Before responding, your sidecar:
- Verifies the auth token against the Provider's
ekyc_pubDNS key and registered partner domain, checking thataudmatches yourISS_CODE, the token is unexpired, and the issuer is an enabled Provider partner. - Confirms that your request session is still open and the tier is within the requested limit.
- Calls the Provider's
resolve/t{tier}endpoint over CamDX, signing the auth token with your private key. - Verifies the returned OpenAttestation document: Merkle root integrity, issuer signature, DNS-DID record, and registered Provider domain match.
- Encrypts and stores the attestation locally under a new
ekyc_ref. - Marks the session
completedand writes arequestedtransaction record.
Fetch does not run a status check.
Response (200), abridged:
{
"ref_id": "CIF-000123",
"tier": 1,
"data": {
"version": "https://schema.openattestation.com/2.0/schema.json",
"data": { "user_info": { "first_name": "<salt>:string:Somnang", "…": "…" }, "issuers": [ "…" ] },
"signature": { "type": "SHA3MerkleProof", "targetHash": "…", "proof": [], "merkleRoot": "…" },
"privacy": { "obfuscatedData": [ "…" ] },
"proof": [ { "type": "OpenAttestationSignature2018", "…": "…" } ]
},
"attested": {
"user_info": {
"phone_number": "+85512345678",
"first_name": "Somnang",
"last_name": "Chan",
"document_type": "NID",
"document_id": "123456789",
"dob": "1990-01-01",
"gender": "M",
"nationality": "KHM",
"issue_date": "2020-01-01",
"expiry_date": "2030-01-01",
"place_of_birth": "Phnom Penh",
"current_address": { "village": "…", "commune": "…", "district": "…", "province": "…", "country": "Cambodia", "…": "…" }
},
"issuers": [ { "id": "did:ethr:0x…", "identityProof": { "type": "DNS-DID", "location": "ekyc.bank.com.kh" }, "…": "…" } ]
},
"ekyc_ref": "0b9d3d3e-6a51-4f7e-9a7e-8a4b3c1d2e10"
}
| Field | Purpose |
|---|---|
attested.user_info | Plain verified values for pre-filling your onboarding form. T2 adds face_image and face_image_integrity_hash; T3 adds document_image and document_image_back (base64). Fields above the approved tier are absent. |
data | Signed OpenAttestation document with higher-tier fields obfuscated. Store as compliance evidence, as it can be re-verified independently against the Provider's DNS records. |
ref_id | The Provider's customer reference (user_id). Retain alongside the evidence for audit and dispute resolution. |
tier | Tier actually served. |
ekyc_ref | Your sidecar's UUID for the stored attestation. Store this on your customer record to read the attestation back, check its status, or delete it. Each fetch generates a new ekyc_ref. |
Present the pre-filled fields for customer confirmation, then store the confirmed data under your own KYC and retention policies.
Step 5: Keep received attestations current
Attestations do not expire and remain valid until invalidated by the Provider (for example, when a customer repeats eKYC or updates verified profile details). Once invalidated, the held copy should be treated as retired.
Your sidecar encrypts and retains every fetched attestation under its ekyc_ref. Use the three endpoints below with your API key headers to inspect, check, or remove stored attestations.
The product workflow refers to retiring an attestation as invalidation; OpenAttestation and CamDL call the corresponding on-chain operation revocation. When a Provider publishes a revocation on CamDL, status checks report the attestation as invalidated.
Read back an attestation
curl -s "$SIDECAR_URL/api/v1/requester/kyc/0b9d3d3e-6a51-4f7e-9a7e-8a4b3c1d2e10" \
-H "x-api-key: $SIDECAR_API_KEY" \
-H "x-api-secret: $SIDECAR_API_SECRET"
{
"ekyc_ref": "0b9d3d3e-6a51-4f7e-9a7e-8a4b3c1d2e10",
"provider": { "code": "BANK01", "name_en": "Bank One", "camdx_member_code": "CAMBODIA/COM/BANK01/EKYC" },
"request_ref_id": "0199a7e2-…",
"tier": 3,
"merkle_root": "3f0c…",
"data": { "…": "signed OA document exactly as received, images re-injected" },
"attested": { "user_info": {} },
"declared_checks": { "camdl": true, "camdx": true },
"last_status": {
"status": "current",
"checked_at": "2026-11-18T10:00:01.000Z",
"invalidated_at": null
},
"received_at": "2026-11-18T09:00:00.000Z"
}
data matches the exact signed document delivered by the Provider so it remains independently verifiable. declared_checks indicates which status sources the attestation declares, and last_status is null until a status check has been run. Read-back requests are recorded in the sidecar audit trail.
Check status
curl -s "$SIDECAR_URL/api/v1/requester/kyc/0b9d3d3e-6a51-4f7e-9a7e-8a4b3c1d2e10/status" \
-H "x-api-key: $SIDECAR_API_KEY" \
-H "x-api-secret: $SIDECAR_API_SECRET"
{
"ekyc_ref": "0b9d3d3e-6a51-4f7e-9a7e-8a4b3c1d2e10",
"status": "invalidated",
"checked_at": "2026-11-18T10:00:01.000Z",
"invalidated_at": "2026-11-18T09:58:12.000Z",
"sources": {
"camdl": { "status": "current", "reason": null, "invalidated_at": null,
"checked_at": "2026-11-18T10:00:01.000Z" },
"camdx": { "status": "invalidated", "reason": null, "invalidated_at": "2026-11-18T09:58:12.000Z",
"checked_at": "2026-11-18T10:00:01.000Z" }
}
}
The sidecar executes the checks declared by the attestation (bounded by STATUS_CHECK_TIMEOUT_MS), stores the result, and returns the overall and per-source statuses.
status | Meaning |
|---|---|
current | Every declared check confirmed the attestation has not been invalidated. |
invalidated | The Provider invalidated the attestation; treat the stored data as retired. |
unknown | A declared check could not complete (for example due to a timeout or outage). Status is inconclusive. |
not_supported | The attestation declares no status checks. No network call is made, and no reissuance is needed. |
Overall status resolution (evaluated in order):
- No checks declared →
not_supported. - Any source reports
invalidated, or invalidation was confirmed by an earlier check →invalidated. - Every declared source reports
current→current. - Otherwise →
unknown.
Invalidation is irreversible: once confirmed, the overall status remains invalidated. When a source reports unknown, reason identifies the cause (timeout, unreachable, http_error, bad_response, bad_signature, not_found, member_mismatch, chain_mismatch, not_configured, or malformed_declaration). See Troubleshooting.
Failed checks do not produce HTTP errors; the endpoint returns 200 with unknown.
Delete an attestation
curl -s -X DELETE "$SIDECAR_URL/api/v1/requester/kyc/0b9d3d3e-6a51-4f7e-9a7e-8a4b3c1d2e10" \
-H "x-api-key: $SIDECAR_API_KEY" \
-H "x-api-secret: $SIDECAR_API_SECRET"
Returns 204 with no body. The sidecar deletes the encrypted document and image blobs while retaining a non-PII metadata record (reference, Provider, tier, Merkle root, last status, timestamps). Subsequent read-back, status, and delete requests return 404.
Recommended practice
- Poll held attestations periodically via
GET …/{ekyc_ref}/status(for example daily or prior to high-risk operations). - When
statusisinvalidated, treat the held data as retired and prompt the customer to re-share via the standard cross-provider flow, which yields a replacementekyc_ref.
Status checks are optional and never block attestation retrieval or storage. Define your own policy for handling unknown and not_supported results, as well as data retention—the sidecar never purges stored attestations automatically.
Error handling
All error responses share the format { "status": "error", "error": "<type>", "message": "<text>" }:
| Status | Typical message | Cause | Customer message and action |
|---|---|---|---|
400 | Auth token has expired | More than 5 minutes elapsed after approval | "Your approval expired. Please try again." Start a new flow. |
400 | Request session is not in a fetchable state: completed | Auth token for this session was already redeemed | Do not retry; use the previously fetched data or start a new flow. |
400 | Token is invalid or expired | Underlying login token expired (15 minutes) or session not found | Start a new flow. |
400 | Requested tier 2 exceeds authorized tier 1 | tier in kyc/fetch exceeds the tier in the login token | Fix your request to match the requested tier. |
400 | Provider is not in the allowlist. | Provider is missing, disabled, or lacks the Provider role, or camdx_code differs | Check the partner entry under Partners in the backoffice. |
400 | Auth token aud … does not match this service | Token was issued for a different Requester | Reject as invalid or misrouted. |
400 | Provider refused the KYC request | Provider's sidecar returned 4xx on resolve | "We couldn't retrieve your details. Please try again." Check the Provider's logs if it persists. |
401 | Missing API Key or Secret / Invalid or expired API Key | Core API credentials missing, invalid, revoked, or expired | Check or rotate the core system's API key via the Admin API. |
404 | Attestation not found | Unknown or deleted ekyc_ref | Do not retry; use a valid reference or ask the customer to re-share. |
500 | Provider KYC resolution failed: HTTP … | Provider's sidecar returned 5xx on resolve | "We couldn't retrieve your details. Please try again." Alert operations if repeated. |
500 | Failed to retrieve KYC from provider | CamDX Security Server or Provider sidecar unreachable | Same as above. |
500 | Attestation verification failed: … / Attestation issuer is not a registered domain of this provider | Document failed integrity, signature, DNS-DID, or partner domain verification | Do not accept the data. Alert operations and the Provider. |
For additional causes and fixes, see Troubleshooting.
Example: Node.js (Express)
Minimal backend implementation covering steps 1 to 4, assuming server-side session storage (such as express-session). Decoding the JWT locally only extracts ref_id; the sidecar performs full cryptographic verification. Step 5 can be implemented as a scheduled background job calling the status endpoint.
import express from "express";
const SIDECAR = process.env.SIDECAR_URL!; // e.g. https://sidecar.internal.example.com.kh
const PORTAL = process.env.AUTH_PORTAL_URL!; // provided at registration
const CALLBACK = "https://wallet.example.com.kh/ekyc/callback";
const TIER = 1;
const sidecarHeaders = {
"Content-Type": "application/json",
"x-api-key": process.env.SIDECAR_API_KEY!,
"x-api-secret": process.env.SIDECAR_API_SECRET!,
};
// Reads ref_id without verifying; the sidecar performs signature verification.
const refIdOf = (jwt: string): string | undefined => {
try {
return JSON.parse(Buffer.from(jwt.split(".")[1], "base64url").toString()).ref_id;
} catch {
return undefined;
}
};
export const router = express.Router();
router.post("/ekyc/start", async (req, res) => {
const r = await fetch(`${SIDECAR}/api/v1/requester/token/request`, {
method: "POST",
headers: sidecarHeaders,
body: JSON.stringify({ tier: TIER, callback: CALLBACK, callback_type: "web" }),
});
if (!r.ok) return res.status(502).send("eKYC is unavailable, please try again later");
const { token } = await r.json();
req.session.ekycRefId = refIdOf(token);
res.redirect(`${PORTAL}/login?token=${encodeURIComponent(token)}`);
});
router.get("/ekyc/callback", async (req, res) => {
const authToken = typeof req.query.q === "string" ? req.query.q : "";
const expected = req.session.ekycRefId;
delete req.session.ekycRefId;
if (!authToken || !expected || refIdOf(authToken) !== expected) {
return res.redirect("/signup?ekyc=restart");
}
const r = await fetch(`${SIDECAR}/api/v1/requester/kyc/fetch`, {
method: "POST",
headers: sidecarHeaders,
body: JSON.stringify({ auth_token: authToken, tier: TIER }),
});
if (!r.ok) {
const err = await r.json().catch(() => ({}));
console.warn("eKYC fetch failed", r.status, err.message); // never log the token
return res.redirect("/signup?ekyc=failed");
}
const kyc = await r.json();
await saveEvidence(req.session.userId, kyc.data, kyc.ref_id, kyc.tier, kyc.ekyc_ref); // your persistence logic
req.session.prefill = kyc.attested.user_info;
res.redirect("/signup/confirm");
});
The demo partner portal (eykc-web-portal, run with APP_MODE=REQUESTER) provides a complete reference implementation in Next.js.
Requester checklist
- Only your backend communicates with the sidecar; API credentials are stored in a secret manager, never in browser or mobile code.
- Requested tier is the minimum required by your onboarding workflow.
- Callback URL uses HTTPS and its base URL is registered with the network operator.
- Callback handler validates
ref_idagainst the customer session and callskyc/fetchimmediately. - Auth tokens, API secrets, and personal data are excluded from logs, analytics, and error reporting.
- Every error scenario maps to a clear customer message and a restart path.
- Signed OpenAttestation documents (
data) are retained as evidence alongsideref_id, Provider code, and timestamp. - Customer KYC data is stored under your KYC and data retention policies.
-
ekyc_refis stored on each customer record. - Policies are defined for status-check frequency, handling
unknownandnot_supported, and prompting re-authentication when an attestation becomesinvalidated. - Stored attestations are deleted by
ekyc_refaccording to your retention schedule. - End-to-end tests pass for every tier you use, plus deny, expiry, replay, and disabled Provider scenarios. See Guide Phase 7.