Java / Kotlin SDK
The official RDCPASS SDK for Java / Kotlin, published on Maven Central as cd.rdcpass:rdcpass-java. It signs every request, encrypts and decrypts payloads with AES-256-GCM, presents your mTLS client certificate, adds idempotency keys, retries transient failures and verifies webhooks — the complete security stack described in Authentication, handled for you.
Installation
Add cd.rdcpass:rdcpass-java to your project:
<dependency>
<groupId>cd.rdcpass</groupId>
<artifactId>rdcpass-java</artifactId>
<version>1.4.0</version>
</dependency>Requirements
- Java 11+ or later.
- Outbound HTTPS (TLS 1.2 or later) to
gateway.staging.rdcpass.cdfor the staging environment andapi.rdcpass.cdfor production. In production, calls must come from an IP address on your application’s allowlist. - An RDCPASS application with API credentials, created in the console — see Sandbox.
Configuration
Create one client and reuse it across your application: it is safe for concurrent use and keeps connections open between calls. The environment selects the base URL; keys and certificates issued for one environment are rejected by the other.
| Environment | RDCPASS_ENVIRONMENT | Base URL |
|---|---|---|
| Staging environment | sandbox | https://gateway.staging.rdcpass.cd |
| Production | production | https://api.rdcpass.cd |
Configure a client for the staging environment explicitly:
import cd.rdcpass.Environment;
import cd.rdcpass.RdcPass;
// Staging environment: https://gateway.staging.rdcpass.cd
RdcPass client = RdcPass.builder()
.environment(Environment.SANDBOX)
.keyId("key_test_3c7e1a9f42")
.keySecret(System.getenv("RDCPASS_KEY_SECRET"))
.encryptionKey(System.getenv("RDCPASS_ENCRYPTION_KEY"))
.build();Credentials
| Credential | Environment variable | Description |
|---|---|---|
| Key ID | RDCPASS_KEY_ID | Public identifier of your HMAC key, sent with every request (key_test_… in staging, key_live_… in production). |
| Key secret | RDCPASS_KEY_SECRET | HMAC-SHA256 signing secret. Never sent over the network. |
| Payload Encryption Key | RDCPASS_ENCRYPTION_KEY | AES-256-GCM key used to encrypt requests and decrypt responses, and to verify webhook signatures. |
| Environment | RDCPASS_ENVIRONMENT | sandbox or production. Defaults to sandbox. |
| mTLS client certificate and key | — | Issued by RDCPASS for your application; required in production. Must belong to the same application as the key ID. Loaded from files in the client configuration. |
Production and environment variables
When no credentials are passed, the client reads the four environment variables above. In production, add your mTLS client certificate and private key:
import java.nio.file.Path;
import cd.rdcpass.RdcPass;
// fromEnv() reads RDCPASS_KEY_ID, RDCPASS_KEY_SECRET,
// RDCPASS_ENCRYPTION_KEY and RDCPASS_ENVIRONMENT.
// Production (https://api.rdcpass.cd) also requires your mTLS client certificate.
RdcPass client = RdcPass.builder()
.fromEnv()
.clientCertificate(Path.of("/etc/rdcpass/client.crt"), Path.of("/etc/rdcpass/client.key"))
.build();Keep secrets out of source code
Load the key secret, the Payload Encryption Key and the certificate’s private key from environment variables or a secrets manager. Never commit them, and never ship them in a mobile or browser application — the SDK is for server-side use.Your first request
Validate a customer by RDCPASS ID with KYC Validation. The SDK encrypts and signs the request, decrypts the response and returns a typed kyc_validation object:
import java.time.LocalDate;
import java.util.List;
import cd.rdcpass.RdcPass;
import cd.rdcpass.models.Identifier;
import cd.rdcpass.models.Match;
import cd.rdcpass.models.kyc.KycValidation;
import cd.rdcpass.models.kyc.KycValidationCreateParams;
public class ValidateIdentity {
public static void main(String[] args) {
RdcPass client = RdcPass.builder().fromEnv().build();
KycValidation validation = client.kyc().validations().create(
KycValidationCreateParams.builder()
.reference("cust-0001")
.identifier(Identifier.rdcpassId("COD-2103-0214-4937"))
.match(Match.builder()
.fullName("Kabeya Mwamba Tshisekedi")
.dateOfBirth(LocalDate.of(1988, 4, 12))
.build())
.purpose("customer_onboarding")
.scopes(List.of("kyc.documents.primary", "kyc.phone_numbers"))
.build());
System.out.println(validation.getResult()); // VERIFIED
System.out.println(validation.getKyc().getBasic().getFullName()); // Kabeya Mwamba Tshisekedi
System.out.println(validation.getScopesWithheld()); // []
}
}{
"id": "kyc_8d2f6a1c93",
"object": "kyc_validation",
"livemode": true,
"reference": "cust-0001",
"status": "completed",
"result": "verified",
"certified_account": true,
"identifier": {
"type": "rdcpass_id",
"value": "COD-2103-0214-4937"
},
"match": {
"full_name": "match",
"date_of_birth": "match",
"age": "not_provided",
"score": 0.98
},
"account": {
"rdcpass_id": "COD-2103-0214-4937",
"status": "active",
"certified": true,
"created_at": "2025-03-14T09:22:41Z",
"level_of_assurance": "LOA3"
},
"kyc": {
"basic": {
"full_name": "Kabeya Mwamba Tshisekedi",
"first_name": "Kabeya",
"last_name": "Tshisekedi",
"date_of_birth": "1988-04-12",
"age": 38,
"gender": "male",
"nationality": "COD"
},
"documents": {
"primary": {
"type": "passport",
"number": "OB1234567",
"issued_at": "2022-06-01",
"expires_at": "2027-05-31",
"issuing_authority": "Direction Générale de Migration",
"status": "valid",
"image": {
"content_type": "image/jpeg",
"url": "https://files.rdcpass.cd/d/9f2c41e8b7a3?sig=Qm9fX2t5Y19zaWc&exp=1790418002",
"expires_at": "2026-09-26T10:20:02Z"
}
}
},
"phone_numbers": [
{
"number": "+243812345678",
"operator": "Vodacom",
"is_primary": true,
"verified": true
},
{
"number": "+243991234567",
"operator": "Airtel",
"is_primary": false,
"verified": true
}
]
},
"scopes_applied": [
"kyc.basic",
"kyc.documents.primary",
"kyc.phone_numbers"
],
"scopes_withheld": [],
"purpose": "customer_onboarding",
"created_at": "2026-09-26T10:15:02Z"
}Every field is documented in KYC Validation.
Calling every service
Every service is exposed as a resource on the client, named after its endpoint. Parameters and responses use the same names and shapes as the API reference.
KYC Validation
Look up an identity by RDCPASS ID, passport, CENI voter card, driving licence or national ID. The result is verified, not_found or not_certified. Reference →
KycValidation validation = client.kyc().validations().create(
KycValidationCreateParams.builder()
.identifier(Identifier.passport("OB1234567"))
.purpose("customer_onboarding")
.scopes(List.of()) // basic KYC only
.build());
System.out.println(validation.getResult()); // VERIFIED | NOT_FOUND | NOT_CERTIFIEDFace Recognition
Compare a photo — sent as base64 data or a url — with the enrolled face of an identity. reason is required; the result is match or no_match. Reference →
byte[] photo = Files.readAllBytes(Path.of("selfie.jpg"));
FaceRecognition recognition = client.face().recognitions().create(
FaceRecognitionCreateParams.builder()
.image(FaceImage.ofData(Base64.getEncoder().encodeToString(photo)))
.identifier(Identifier.rdcpassId("COD-2103-0214-4937"))
.reason("Current account opening at Gombe branch, Kinshasa")
.purpose("customer_onboarding")
.build());
System.out.println(recognition.getResult()); // MATCH | NO_MATCHAge Verification
Check whether a person is over a threshold without receiving their date of birth; read over_threshold. Reference →
AgeVerification verification = client.age().verifications().create(
AgeVerificationCreateParams.builder()
.identifier(Identifier.rdcpassId("COD-2103-0214-4937"))
.threshold(18)
.purpose("age_gating")
.build());
System.out.println(verification.isOverThreshold()); // trueKYB Verification
Verify a business by rccm, id_nat or nif, and receive its officers and beneficial owners if your application is granted those scopes. Reference →
KybVerification business = client.kyb().verifications().create(
KybVerificationCreateParams.builder()
.identifier(BusinessIdentifier.rccm("CD/KIN/RCCM/23-B-01234"))
.match(BusinessMatch.builder().businessName("Congo Digital Solutions SARL").build())
.purpose("customer_onboarding")
.scopes(List.of("kyb.officers", "kyb.beneficial_owners"))
.build());
System.out.println(business.getResult());AML/CTF Screening
Screen a subject against the requested checks; enable monitoring to be notified of new hits. Read risk_level. Reference →
AmlScreening screening = client.aml().screenings().create(
AmlScreeningCreateParams.builder()
.subject(AmlSubject.of(Identifier.rdcpassId("COD-1907-5521-0386")))
.checks(List.of("sanctions", "pep", "adverse_media", "watchlists", "high_risk_jurisdictions"))
.monitoring(true)
.purpose("regulatory_compliance")
.build());
System.out.println(screening.getRiskLevel()); // LOW | MEDIUM | HIGHCredit Scoring
Requires the customer’s consent in the RDCPASS app (consent.method: rdcpass_app). Returns a score and a band. Reference →
CreditScore credit = client.credit().scores().create(
CreditScoreCreateParams.builder()
.identifier(Identifier.rdcpassId("COD-2103-0214-4937"))
.consent(Consent.rdcpassApp("cns_5e8a2d71c4"))
.purpose("credit_assessment")
.build());
System.out.println(credit.getScore() + " " + credit.getBand());Fraud Reporting
Report a confirmed or suspected fraud, such as identity_usurpation, against a subject, with a description. Reference →
FraudReport report = client.fraud().reports().create(
FraudReportCreateParams.builder()
.type("identity_usurpation")
.subject(FraudSubject.of(Identifier.rdcpassId("COD-2103-0214-4937")))
.description("Account opened with a stolen passport at an agent in Lubumbashi.")
.build());
System.out.println(report.getId() + " " + report.getStatus());Login with RDCPASS
The login helper builds the /v1/oidc/authorize URL with state and a PKCE code_challenge (S256), exchanges the authorization code at /v1/oidc/token with the matching code_verifier, and calls /v1/oidc/userinfo. See Login with RDCPASS.
// 1. Build the authorize URL. The SDK generates state and the PKCE
// code_verifier / code_challenge (S256) for you.
AuthorizationRequest auth = client.login().createAuthorizationUrl(
AuthorizationUrlParams.builder()
.clientId("app_8f2a1c0e9b")
.redirectUri("https://yourapp.example.com/callback")
.scopes(List.of("openid", "profile", "rdcpass:kyc.phone_numbers"))
.build());
// Store auth.getState() and auth.getCodeVerifier() in the user's session,
// then redirect to auth.getUrl().
// 2. On your callback, check state and exchange the code.
if (!returnedState.equals(session.getState())) {
throw new IllegalStateException("state mismatch");
}
TokenResponse tokens = client.login().exchangeCode(
ExchangeCodeParams.builder()
.clientId("app_8f2a1c0e9b")
.code(code)
.codeVerifier(session.getCodeVerifier())
.redirectUri("https://yourapp.example.com/callback")
.build());
UserInfo user = client.login().userInfo(tokens.getAccessToken());Batches & async
Every service accepts batches at /batches: up to 50 items synchronously, or up to 10,000 asynchronously. With the async option the SDK sends Prefer: respond-async and returns a 202 job or batch object immediately.
- Wait — the wait helper polls
/v1/batches/{id}(or/v1/jobs/{id}for a single async call) with backoff until the status is final, or until your timeout elapses. - Iterate — the results helper pages through
/v1/batches/{id}/resultsand followsnext_cursorfor you. - Or subscribe — instead of polling, handle the
batch.completedandbatch.completed_with_errorswebhooks.
// Submit up to 10,000 items asynchronously (Prefer: respond-async).
Batch batch = client.kyc().validations().batches().create(
KycValidationBatchCreateParams.builder()
.purpose("customer_onboarding")
.addItem(KycValidationCreateParams.builder()
.reference("cust-0001").identifier(Identifier.rdcpassId("COD-2103-0214-4937")).build())
.addItem(KycValidationCreateParams.builder()
.reference("cust-0002").identifier(Identifier.ceni("1234567890123")).build())
.build(),
RequestOptions.builder().respondAsync(true).build());
// Poll GET /v1/batches/{id} until the batch reaches a final status.
Batch done = client.batches().waitFor(batch.getId(), Duration.ofSeconds(5), Duration.ofMinutes(30));
System.out.println(done.getStatus() + " " + done.getSucceededItems() + " " + done.getFailedItems());
// Iterate every result; autoPager() follows next_cursor page by page.
for (BatchResult item : client.batches().results(batch.getId(), ListParams.limit(500)).autoPager()) {
System.out.println(item.getReference() + " " + item.getStatus());
}Batch quota is separate from single-call quota, and batch items are billed at the discounted batch rate — see Rate limits and Billing.
Webhooks
The webhook helper checks X-RDCPASS-Webhook-Signature — HMAC-SHA256 of {timestamp}.{rawBody} with your Payload Encryption Key — using a constant-time comparison, rejects deliveries whose X-RDCPASS-Webhook-Timestamp is more than 5 minutes from your clock (configurable), and parses the envelope { id, object: "event", type, livemode, created_at, data: { object, previous_attributes } } into a typed event.
@PostMapping("/webhooks/rdcpass")
public ResponseEntity<Void> rdcpassWebhook(@RequestBody byte[] rawBody, @RequestHeader HttpHeaders headers) {
// Use the raw body: the signature covers "{timestamp}.{rawBody}".
Event event;
try {
event = client.webhooks().constructEvent(rawBody, headers.toSingleValueMap());
} catch (SignatureVerificationException e) {
return ResponseEntity.badRequest().build();
}
switch (event.getType()) {
case "kyc_validation.completed":
System.out.println(event.getData().getObject(Job.class).getStatus());
break;
case "batch.completed":
case "batch.completed_with_errors":
Batch batch = event.getData().getObject(Batch.class);
System.out.println(batch.getId() + " " + batch.getFailedItems());
break;
default:
break;
}
return ResponseEntity.ok().build();
}Pass the raw request body, exactly as received — a body parsed and re-serialized by your framework will not match the signature. Respond with a 2xx within 5 seconds and deduplicate on the event id, which is also sent as X-RDCPASS-Webhook-Id. See Webhooks.
Errors
Every API error — { error, message } in the response body — is raised as RdcPassException, which carries getCode(), getStatus(), getMessage(), getRequestId(). Network failures and timeouts that exhaust their retries raise a separate connection error. Quote the request ID when you contact RDCPASS support.
| Code | HTTP | What to do |
|---|---|---|
invalid_identifier | 400 | The identifier is malformed for its type. Fix the input; do not retry. |
insufficient_balance | 402 | Your prepaid balance is too low. Top up in the console. |
scope_not_granted | 403 | A requested scope is not granted to your application. Remove it or request it in the console. |
purpose_not_approved | 403 | The purpose is not approved for your application. |
rate_limited | 429 | Too many requests per second. Retried automatically after Retry-After. |
batch_quota_exceeded | 429 | Your batch quota is used up. Separate from single-call quota. |
try {
client.kyc().validations().create(
KycValidationCreateParams.builder()
.identifier(Identifier.rdcpassId("COD-2103-0214-4937"))
.purpose("customer_onboarding")
.scopes(List.of("kyc.biometrics.iris"))
.build());
} catch (RdcPassException e) {
System.err.println(e.getStatus() + " " + e.getCode() + " " + e.getMessage() + " " + e.getRequestId());
if ("scope_not_granted".equals(e.getCode())) {
// 403: request the scope for your application in the console
}
}The full list is in Errors.
Retries & idempotency
- Automatic idempotency keys. Every POST is sent with a generated
Idempotency-Key, reused on each retry of that request, so a retried call is never processed or billed twice. - What is retried.
429responses,5xxresponses, connection failures and timeouts. Other4xxerrors are raised immediately. - Backoff. Exponential backoff with jitter, starting at 0.5 seconds and capped at 8 seconds;
Retry-Afteris honoured when present. Up to 3 retries by default. - Configurable. Change the number of retries per client or per request, and pass your own idempotency key to keep retries safe across process restarts.
RdcPass client = RdcPass.builder()
.fromEnv()
.maxRetries(5) // default 3; set 0 to disable
.build();
// Every POST gets an Idempotency-Key automatically. Pass your own to make
// retries safe across process restarts:
client.fraud().reports().create(
FraudReportCreateParams.builder()
.type("identity_usurpation")
.subject(FraudSubject.of(Identifier.rdcpassId("COD-2103-0214-4937")))
.description("Account opened with a stolen passport.")
.build(),
RequestOptions.builder()
.idempotencyKey("fraud-case-INC-2026-88213")
.maxRetries(1)
.build());Timeouts & logging
Each attempt times out after 30 seconds by default; set a different timeout per client or per request. Logs are written through your language’s standard logging interface. They include method, path, status, duration, retry attempts and request ID — never decrypted payloads, secrets or personal data.
// The SDK logs through SLF4J under the "cd.rdcpass" logger —
// set it to DEBUG in your logging configuration to trace requests.
RdcPass client = RdcPass.builder()
.fromEnv()
.timeout(Duration.ofSeconds(20)) // per attempt (default 30s)
.build();
// Override per request.
client.aml().screenings().create(
AmlScreeningCreateParams.builder()
.subject(AmlSubject.of(Identifier.rdcpassId("COD-1907-5521-0386")))
.purpose("regulatory_compliance")
.build(),
RequestOptions.builder().timeout(Duration.ofSeconds(60)).build());
// Every resource also has an async variant returning CompletableFuture:
// client.async().kyc().validations().create(params)Upgrading & versioning
cd.rdcpass:rdcpass-javafollows semantic versioning: only major versions contain breaking changes.- Each major version receives security and bug fixes for 24 months after the next major version is released.
- Every release, with upgrade notes for each major version, is listed in the Changelog.
- New API fields and events arrive in minor releases, so keep the SDK up to date to use them.
Integrating without an SDK? See Authentication to sign, encrypt and send requests yourself.