Skip to main content

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} and ping services 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, a kyc-status-v1 service 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.

CustomerYour mobile appYour backendYour sidecarAuth PortalRequestersidecarScan QR (oropen deep link)1Login token +signed-in customer2POST /api/v1/provider/token/verify3valid · Requester · tier4Consent screen data5Allow + PIN /biometrics6Approved7ifNo attestation yet (or data changed)POST /api/v1/provider/kyc/submit8elseHas attestation_refPOST /api/v1/provider/kyc/authorize910Attest, encrypt, record consent,issue auth tokenConsent + auth token(via CamDX)11attestation_ref+ auth_payload12"Shared with <Requester>"13Minutes later, no code needed on your sideresolve/t{tier} via CamDX14Signed attestation,fields above tier hidden15

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 pathPayload received by your app
Scans the QR code with your in-app scannerRaw QR text: the login token
Taps your logo on the Auth Portal on the same phoneYour 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_pub TXT record on payload.iss.
  • The token is unexpired (exp) and iat is not in the future.
  • Your ISS_CODE is included in payload.accept.
  • payload.iss_code matches an enabled partner in your allowlist with the Requester role, and payload.iss is a registered domain for that partner.
  • payload.tier does not exceed that partner's Max tier.

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 domain payload.iss shown underneath. Never display unverified names from external sources.

  • Data to be shared, in plain language corresponding to payload.tier:

    TierDescription shown to the customer
    T0Phone number, full name, ID type, and ID number
    T1T0, plus email (if held), date of birth, gender, nationality, ID issue and expiry dates, place of birth, and current address
    T2T1, plus face photo
    T3T2, 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.

NoYesNoYesthenCustomer tapped AllowStored attestation_reffor this customer?KYC data changed since, orrequested tier above thestored tier?POST /kyc/authorizePOST /kyc/submitwith verified KYC dataPOST /kyc/invalidatethe old attestation

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_id is your internal customer reference (such as a CIF). It is opaque to the sidecar and returned to the Requester as ref_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, submit returns 409 with the active attestation_ref when available. Invalidate the old attestation first.
  • T2 adds face_image (base64) and face_image_integrity_hash (SHA-256 of the image). T3 adds document_image and document_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…"
}
}
  • status is submitted or authorized.
  • Store attestation_ref alongside 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:

  1. Verifies that the auth token was issued by your sidecar and is unexpired (5-minute lifetime).
  2. Verifies the Requester's signature over the auth token against keys at the Requester's registered Domains in your allowlist.
  3. Confirms that X-Road-Client matches the Requester's camdx_member_code.
  4. Rejects already-redeemed tokens and verifies that the consent record matches that Requester.
  5. Decrypts the attestation, obfuscates fields above the requested tier (which cannot exceed the authorised tier), and returns the document.
  6. Marks the session completed and records a provided transaction.

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.

Invalidation and revocation

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"
}
FieldRules
user_idSame customer reference passed to submit
attestation_refUUID of the attestation to retire (must belong to user_id)
reasonOptional: profile_updated, ekyc_repeated, data_correction, or other. Enumerated values ensure no personal data enters the audit log.
login_tokenDeprecated 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 200 with the original invalidated_at and already_invalidated: true, without affecting any replacement attestation.
  • Asynchronous blockchain publication: CamDL publication runs in the background with retries. camdl_publication reports pending, confirmed, failed, or not_declared. While pending, your sidecar immediately blocks authorize/resolve and answers invalidated on the CamDX status service.
  • Strict matching: an unknown or mismatched attestation_ref returns 404.
  • Immediate cut-off: once committed, authorize and resolve reject 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:

  1. Call POST /kyc/invalidate with the stored attestation_ref.
  2. Call POST /kyc/submit with the updated data and replace the stored attestation_ref with 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_CHECKSDeclared in new attestations
none (default)No checks; Requesters report not_supported
camdlCamDL Document Store check
camdxCamDX status service check
camdl,camdxBoth

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.

  1. Deploy an OpenAttestation Document Store on CamDL from your attestation wallet's address so the wallet holds the revocation role.
  2. Configure DOCUMENT_STORE_ADDRESS, RPC_URL, and CAMDL_CHAIN_ID (and CAMDL_CHAIN_NAME if different from CAMDL). The sidecar refuses to start if ATTESTATION_STATUS_CHECKS includes camdl and any of these variables is missing or invalid.
  3. 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 pathSidecar endpoint
kyc-status-v1POST /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/verify before 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/submit sends only verified KYC data matching the schema for payload.tier.
  • attestation_ref, tier, and user_id are stored per customer, and submit vs authorize is selected as shown in step 4.
  • user_id is an internal customer reference, never a national ID or phone number.
  • Verified KYC updates (repeated eKYC, profile edits) call kyc/invalidate immediately, before any replacement kyc/submit (409 otherwise).
  • Stored attestation_ref is updated whenever a replacement attestation is submitted.
  • If offering status checks: ATTESTATION_STATUS_CHECKS is configured, your CamDL Document Store is deployed (camdl), and kyc-status-v1 is published on your Security Server (camdx).
  • Only resolve/t{n}, ping, and (if enabled) kyc-status-v1 are 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.