Integrate as a Provider
Audience: mobile, backend, and product engineers at an organisation that shares verified KYC data (bank, MFI, telco). Before this page: your sidecar is running, the CamDX
resolve/t{n}andpingservices are published, and your Requester partners are allowlisted. See Set up the sidecar. Status checks (step 7) are optional and require a CamDL Document Store, akyc-status-v1service on CamDX, or both. Contracts: Sidecar API reference.
Integration requires a QR scanner or deep-link handler, a consent screen, and three backend calls—plus an invalidation call whenever verified customer data changes in your core system. After the customer approves, your sidecar sends the auth token to the Auth Portal and serves the Requester's subsequent fetch over CamDX automatically.
Step 1: Receive the login token in your app
The QR code on the Auth Portal encodes the Requester's login token (a JWT string). The customer enters your mobile app in one of two ways:
| Entry path | Payload received by your app |
|---|---|
| Scans the QR code with your in-app scanner | Raw QR text: the login token |
| Taps your logo on the Auth Portal on the same phone | Your registered deep link with the token in q: {deeplink_scheme}?q={login token} (or &q= if your scheme already includes a query string) |
Register your deep-link scheme with the network operator in your Auth Portal member record, and enforce the following:
- Require the customer to be authenticated in your app. The share is always bound to the signed-in customer, never to an identifier from the token.
- Forward the token to your backend for verification; do not decode or trust it in the mobile app.
- Accept only strings structured as a JWT (three dot-separated base64url segments). Display
"This QR code is not supported by this app"otherwise.
Step 2: Verify the login token
curl -s -X POST "$SIDECAR_URL/api/v1/provider/token/verify" \
-H "Content-Type: application/json" \
-H "x-api-key: $SIDECAR_API_KEY" \
-H "x-api-secret: $SIDECAR_API_SECRET" \
-d '{ "token": "eyJhbGciOiJFUzUxMiIs..." }'
{
"valid": true,
"payload": {
"qr_type": "ekyc_request_v1",
"tier": 1,
"accept": ["BANKA", "YOURORG"],
"ref_id": "0199a7e2-…",
"jti": "0199a7e2-…",
"callback": "https://wallet.example.com.kh/ekyc/callback",
"callback_type": "web",
"iss": "ekyc.wallet.example.com.kh",
"iss_code": "EWALLET",
"iat": 1790000000,
"exp": 1790000900
}
}
The sidecar accepts the token only when all of the following checks pass; otherwise it returns 400 with the specific reason (see Troubleshooting):
- The ES512 signature verifies against an
ekyc_pubTXT record onpayload.iss. - The token is unexpired (
exp) andiatis not in the future. - Your
ISS_CODEis included inpayload.accept. payload.iss_codematches an enabled partner in your allowlist with the Requester role, andpayload.issis a registered domain for that partner.payload.tierdoes not exceed that partner's Max tier.
Step 3: Show the consent screen
The consent screen protects the customer against phishing. It must present:
-
Requester identity: the Requester's name and logo from your own partner directory (matched by
payload.iss_code), with the verified domainpayload.issshown underneath. Never display unverified names from external sources. -
Data to be shared, in plain language corresponding to
payload.tier:Tier Description shown to the customer T0 Phone number, full name, ID type, and ID number T1 T0, plus email (if held), date of birth, gender, nationality, ID issue and expiry dates, place of birth, and current address T2 T1, plus face photo T3 T2, plus photos of the front and back of the ID card -
Allow and Deny actions, requiring step-up re-authentication (PIN or biometrics) before executing Allow.
-
Remaining validity: the login token expires at
payload.exp.
If the customer chooses Deny, do not call the sidecar. Confirm in your app that no data was shared.
Step 4: Submit or authorise
After Allow, your backend calls one of two endpoints. Both return an attestation_ref, which you store on the customer record.
Always pass payload.tier from the verified login token.
4a. First share: POST /api/v1/provider/kyc/submit
Submit only KYC data verified through your own onboarding process. The sidecar wraps the payload in an OpenAttestation document, signs it with your attestation wallet, encrypts it with AES-256-GCM, and caches it.
{
"tier": 1,
"user_id": "CIF-000123",
"login_token": "eyJhbGciOiJFUzUxMiIs...",
"data": {
"user_info": {
"phone_number": "+85512345678",
"first_name": "Somnang",
"last_name": "Chan",
"document_type": "NID",
"document_id": "123456789",
"email": "somnang@example.com",
"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": {
"address_line_1": "No. 12, Street 310",
"village": "…", "village_code": "…",
"commune": "…", "commune_code": "…",
"district": "…", "district_code": "…",
"province": "Phnom Penh", "province_code": "12",
"country": "Cambodia", "country_code": "KHM",
"postal_code": "120101"
}
}
}
}
user_idis your internal customer reference (such as a CIF). It is opaque to the sidecar and returned to the Requester asref_id. Do not use a national ID number or phone number.- Required fields vary by
tier; see KYC data by tier. - If the customer already has an active attestation,
submitreturns409with the activeattestation_refwhen available. Invalidate the old attestation first. - T2 adds
face_image(base64) andface_image_integrity_hash(SHA-256 of the image). T3 addsdocument_imageanddocument_image_back(base64). The maximum request body size is 20 MB.
4b. Returning customer: POST /api/v1/provider/kyc/authorize
{
"user_id": "CIF-000123",
"attestation_ref": "0199a7e3-5b2c-7c1e-9f4a-2d8b6e0c1a77",
"tier": 1,
"login_token": "eyJhbGciOiJFUzUxMiIs..."
}
tier is required and must not exceed the tier of the cached attestation (400 Requested Tier 2 exceeds cached Tier 1). If a higher tier is needed, invalidate the existing attestation and call submit with the higher-tier data.
Response (both calls): 201
{
"user_id": "CIF-000123",
"status": "submitted",
"attestation_ref": "0199a7e3-5b2c-7c1e-9f4a-2d8b6e0c1a77",
"auth_payload": {
"payload": { "auth_token": "eyJhbGciOiJFUzUxMiIs..." },
"payload_signature": "MIGIAkIB…"
}
}
statusissubmittedorauthorized.- Store
attestation_refalongside the customer ID and tier. - Before returning, the sidecar records the consent, creates a provide session, and delivers the auth token to the Auth Portal over CamDX. The Auth Portal then redirects the customer back to the Requester. Your backend does not need to process
auth_payload; do not log it. - Display a confirmation to the customer (for example,
"Shared with <Requester name>").
If delivery to the Auth Portal fails, the call returns 500 (Failed to submit consent to the auth portal or Auth portal rejected consent: HTTP …). Display an error confirming no data was shared and allow the customer to scan again.
Step 5: Serve the Requester (automatic)
Shortly afterward, the Requester's sidecar calls your resolve/t{tier} service over CamDX. Your sidecar handles this automatically:
- Verifies that the auth token was issued by your sidecar and is unexpired (5-minute lifetime).
- Verifies the Requester's signature over the auth token against keys at the Requester's registered Domains in your allowlist.
- Confirms that
X-Road-Clientmatches the Requester'scamdx_member_code. - Rejects already-redeemed tokens and verifies that the consent record matches that Requester.
- Decrypts the attestation, obfuscates fields above the requested tier (which cannot exceed the authorised tier), and returns the document.
- Marks the session
completedand records aprovidedtransaction.
Monitor these exchanges in the sidecar backoffice under Sessions (direction: provided).
Step 6: Invalidate stale data
Your core system determines when verified data is stale. The sidecar does not evaluate whether a profile change is material. Invalidate the active attestation as soon as verified customer data changes in your core system—for example after repeated eKYC or a verified profile update—without waiting for a share flow.
Invalidation retires that attestation version. Consent and sharing permissions remain separate; when the customer next shares their profile, the normal sharing flow delivers the replacement attestation.
This guide uses invalidation for the product lifecycle; OpenAttestation and CamDL call the on-chain operation revocation. Calling /kyc/invalidate marks the attestation invalidated in the sidecar database and, if the attestation declared a CamDL check, queues an on-chain Merkle root revocation on CamDL.
POST /api/v1/provider/kyc/invalidate
{
"user_id": "CIF-000123",
"attestation_ref": "0199a7e3-5b2c-7c1e-9f4a-2d8b6e0c1a77",
"reason": "profile_updated"
}
| Field | Rules |
|---|---|
user_id | Same customer reference passed to submit |
attestation_ref | UUID of the attestation to retire (must belong to user_id) |
reason | Optional: profile_updated, ekyc_repeated, data_correction, or other. Enumerated values ensure no personal data enters the audit log. |
login_token | Deprecated and ignored. Accepted for backward compatibility with older callers, but neither required nor verified. |
{
"user_id": "CIF-000123",
"attestation_ref": "0199a7e3-5b2c-7c1e-9f4a-2d8b6e0c1a77",
"status": "invalidated",
"invalidated_at": "2026-11-18T09:58:12.000Z",
"already_invalidated": false,
"camdl_publication": "pending"
}
In a single database transaction, the sidecar records the invalidation timestamp, wipes the encrypted attestation payload and image blobs, and appends an audit event—while retaining the issuance reference, Merkle root, and delivery records needed to answer status queries. If the attestation declared CamDL, the sidecar queues the on-chain revocation.
- Idempotent: repeating the call returns
200with the originalinvalidated_atandalready_invalidated: true, without affecting any replacement attestation. - Asynchronous blockchain publication: CamDL publication runs in the background with retries.
camdl_publicationreportspending,confirmed,failed, ornot_declared. While pending, your sidecar immediately blocksauthorize/resolveand answersinvalidatedon the CamDX status service. - Strict matching: an unknown or mismatched
attestation_refreturns404. - Immediate cut-off: once committed,
authorizeandresolvereject the retired attestation; any pending share must be initiated again.
Invalidate first, then submit
A customer may hold at most one active attestation. Calling kyc/submit while an active attestation exists returns 409 without modifying state. Always follow this sequence:
- Call
POST /kyc/invalidatewith the storedattestation_ref. - Call
POST /kyc/submitwith the updated data and replace the storedattestation_refwith the new reference returned.
If submit fails, the old attestation remains invalidated; retry submit.
Attestation lifecycle
Attestations do not expire and remain active until invalidated by the Provider. Ensure your core system calls kyc/invalidate on every relevant KYC update, as invalidation is the sole mechanism for retiring stale data.
Step 7: Offer status checks (optional)
Status checks let Requesters verify whether a held attestation has been invalidated. They are optional and never block sharing. Each attestation declares its supported check methods in its signed payload based on ATTESTATION_STATUS_CHECKS; your core API calls remain unchanged.
ATTESTATION_STATUS_CHECKS | Declared in new attestations |
|---|---|
none (default) | No checks; Requesters report not_supported |
camdl | CamDL Document Store check |
camdx | CamDX status service check |
camdl,camdx | Both |
Changes to ATTESTATION_STATUS_CHECKS affect only newly issued attestations. Existing attestations retain their original declarations and remain usable.
CamDL: your own Document Store
Each Provider deploys and owns its OpenAttestation Document Store on CamDL. Because the store address and chain ID are embedded in each attestation, Requesters need no Provider-specific store configuration.
- Deploy an OpenAttestation Document Store on CamDL from your attestation wallet's address so the wallet holds the revocation role.
- Configure
DOCUMENT_STORE_ADDRESS,RPC_URL, andCAMDL_CHAIN_ID(andCAMDL_CHAIN_NAMEif different fromCAMDL). The sidecar refuses to start ifATTESTATION_STATUS_CHECKSincludescamdland any of these variables is missing or invalid. - TSC, as CamDL chain owner, funds Provider sidecar wallets so the sidecar does not need to manage token balances.
Issuance requires no on-chain write; the DNS-DID signature establishes authenticity, and only invalidation writes a revocation to CamDL.
CamDX: the kyc-status-v1 service
Ask your Security Server administrator to publish the status service on your Provider subsystem:
| CamDX service path | Sidecar endpoint |
|---|---|
kyc-status-v1 | POST /api/v1/provider/kyc/status |
Grant access only to allowlisted Requesters. The service answers queries only for attestations delivered to the calling Requester, returning not_found identically whether a Merkle root is unknown or was delivered to a different organisation. If you publish the service under a code other than kyc-status-v1, set CAMDX_STATUS_SERVICE_CODE to match.
See Environment variables for all status-check settings, and Integrate as a Requester, step 5 for the consumer flow.
Example: Node.js (Express)
Minimal backend implementation covering steps 2 to 4 using the invalidate-then-submit sequence from step 6. requireCustomer represents your app session authentication, and kycStore represents your verified KYC store and attestation reference table.
import express from "express";
const SIDECAR = process.env.SIDECAR_URL!;
const sidecarHeaders = {
"Content-Type": "application/json",
"x-api-key": process.env.SIDECAR_API_KEY!,
"x-api-secret": process.env.SIDECAR_API_SECRET!,
};
const callSidecar = async (path: string, body: unknown) => {
const r = await fetch(`${SIDECAR}${path}`, {
method: "POST",
headers: sidecarHeaders,
body: JSON.stringify(body),
});
const json = await r.json();
if (!r.ok) throw Object.assign(new Error(json.message), { status: r.status });
return json;
};
export const router = express.Router();
// Step 2: the app posts the scanned token; return data needed for the consent screen.
router.post("/ekyc/verify", requireCustomer, async (req, res) => {
try {
const { payload } = await callSidecar("/api/v1/provider/token/verify", { token: req.body.token });
const requester = await partnerDirectory.byCode(payload.iss_code); // your partner names and logos
res.json({ requester, domain: payload.iss, tier: payload.tier, expiresAt: payload.exp });
} catch (e: any) {
res.status(400).json({ message: "This request cannot be verified. Nothing was shared." });
}
});
// Step 4: the customer tapped Allow and completed step-up authentication.
router.post("/ekyc/allow", requireCustomer, requireStepUpAuth, async (req, res) => {
const loginToken: string = req.body.token;
const { payload } = await callSidecar("/api/v1/provider/token/verify", { token: loginToken });
const tier: number = payload.tier;
const customer = req.customer;
const saved = await kycStore.attestationFor(customer.id); // { attestationRef, tier, dataVersion } | null
let result;
if (saved && saved.tier >= tier && saved.dataVersion === customer.kycVersion) {
result = await callSidecar("/api/v1/provider/kyc/authorize", {
user_id: customer.cif, attestation_ref: saved.attestationRef, tier, login_token: loginToken,
});
} else {
if (saved) {
await callSidecar("/api/v1/provider/kyc/invalidate", {
user_id: customer.cif, attestation_ref: saved.attestationRef, reason: "profile_updated",
});
}
result = await callSidecar("/api/v1/provider/kyc/submit", {
tier, user_id: customer.cif, login_token: loginToken,
data: { user_info: await kycStore.verifiedUserInfo(customer.id, tier) },
});
await kycStore.saveAttestation(customer.id, {
attestationRef: result.attestation_ref, tier, dataVersion: customer.kycVersion,
});
}
res.json({ shared: true, status: result.status });
});
The demo partner portal (eykc-web-portal, run with APP_MODE=PROVIDER) provides a complete reference implementation in Next.js.
Provider checklist
- Mobile app accepts the login token via QR scan and registered deep link, and only for an authenticated customer.
- Backend verifies every login token via
/provider/token/verifybefore rendering consent. - Consent screen displays the Requester's name, logo, and verified domain from your partner directory, lists the tier fields, and requires step-up re-authentication before Allow.
- Deny sends nothing to the sidecar and confirms to the customer that no data was shared.
-
kyc/submitsends only verified KYC data matching the schema forpayload.tier. -
attestation_ref, tier, anduser_idare stored per customer, andsubmitvsauthorizeis selected as shown in step 4. -
user_idis an internal customer reference, never a national ID or phone number. - Verified KYC updates (repeated eKYC, profile edits) call
kyc/invalidateimmediately, before any replacementkyc/submit(409otherwise). - Stored
attestation_refis updated whenever a replacement attestation is submitted. - If offering status checks:
ATTESTATION_STATUS_CHECKSis configured, your CamDL Document Store is deployed (camdl), andkyc-status-v1is published on your Security Server (camdx). - Only
resolve/t{n},ping, and (if enabled)kyc-status-v1are exposed on CamDX, restricted to allowlisted Requesters. - Login tokens, auth payloads, API secrets, and personal data are excluded from logs.
- End-to-end tests pass for every tier served, plus deny, expiry, replay, and disabled Requester scenarios. See Guide Phase 7.