### Install Onfido Java API Client Locally Source: https://github.com/onfido/onfido-java/blob/master/README.md Use this command to install the API client library to your local Maven repository. ```shell mvn clean install ``` -------------------------------- ### createWorkflowRun Source: https://context7.com/onfido/onfido-java/llms.txt Start a Studio workflow for an applicant. This initiates an automated Onfido Studio workflow, optionally passing custom input data that can drive conditional branching within the workflow. ```APIDOC ## createWorkflowRun ### Description Start a Studio workflow for an applicant. This initiates an automated Onfido Studio workflow, optionally passing custom input data that can drive conditional branching within the workflow. ### Method `createWorkflowRun(WorkflowRunBuilder)` ### Parameters #### Request Body - `workflowId` (UUID) - Required - The ID of the workflow to start. - `applicantId` (string) - Required - The ID of the applicant. - `customData` (Map) - Optional - Custom data to pass to the workflow. ### Request Example ```java import com.onfido.model.WorkflowRun; import com.onfido.model.WorkflowRunBuilder; import com.onfido.model.WorkflowRunStatus; import java.util.HashMap; import java.util.Map; import java.util.UUID; UUID workflowId = UUID.fromString("e8c921eb-0495-44fe-b655-bcdcaffdafe5"); try { // Basic workflow run WorkflowRun run = onfido.createWorkflowRun( new WorkflowRunBuilder() .workflowId(workflowId) .applicantId(applicantId) ).execute(); System.out.println("Run ID: " + run.getId()); System.out.println("Workflow ID: " + run.getWorkflowId()); System.out.println("Status: " + run.getStatus()); // With custom input data Map customData = new HashMap<>(); customData.put("age", 25); customData.put("is_employed", true); WorkflowRun runWithInputs = onfido.createWorkflowRun( new WorkflowRunBuilder() .workflowId(UUID.fromString("45092b29-f220-479e-aa6f-a6f989baac4c")) .applicantId(applicantId) .customData(customData) ).execute(); System.out.println("Auto-approved status: " + runWithInputs.getStatus()); // APPROVED } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` ### Response #### Success Response - `WorkflowRun` object containing details of the initiated workflow run. #### Response Example ```json { "id": "...", "workflowId": "e8c921eb-0495-44fe-b655-bcdcaffdafe5", "status": "IN_PROGRESS", "createdAt": "..." } ``` #### Error Response `ApiException` with HTTP status code and message. ``` -------------------------------- ### Manage Checks with Onfido Java SDK Source: https://context7.com/onfido/onfido-java/llms.txt Provides examples for finding a specific check, listing all checks for an applicant, and resuming a paused check using the Onfido Java SDK. Includes basic error handling. ```java try { Check check = onfido.findCheck(checkId).execute(); System.out.println("Status: " + check.getStatus()); List checks = onfido.listChecks(applicantId).execute().getChecks(); checks.forEach(c -> System.out.println(c.getId() + " - " + c.getStatus())); onfido.resumeCheck(checkId); // resumes a paused check (no .execute() needed) } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Client Initialization Source: https://context7.com/onfido/onfido-java/llms.txt Configure the DefaultApi instance with your API token and optional region/proxy settings before making any API calls. ```APIDOC ## Client Initialization Configure the `DefaultApi` instance with your API token and optional region/proxy settings before making any API calls. ```java import com.onfido.api.DefaultApi; import com.onfido.ApiClient.Region; import com.onfido.Configuration; import com.onfido.ApiException; import java.net.InetSocketAddress; import java.net.Proxy; // Basic setup (defaults to EU region) DefaultApi onfido = new DefaultApi(Configuration.getDefaultApiClient() .setApiToken(System.getenv("ONFIDO_API_TOKEN")) .setRegion(Region.EU) // Region.EU, Region.US, or Region.CA .setConnectTimeout(60_000) // 60 seconds (default: 30s) .setReadTimeout(60_000)); // With HTTP proxy DefaultApi onfidoWithProxy = new DefaultApi(Configuration.getDefaultApiClient() .setApiToken(System.getenv("ONFIDO_API_TOKEN")) .setRegion(Region.US) .setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.example.com", 3128)))); // Base URLs by region: // EU: https://api.eu.onfido.com/v3.6 // US: https://api.us.onfido.com/v3.6 // CA: https://api.ca.onfido.com/v3.6 ``` ``` -------------------------------- ### Extract Structured Data from Document Source: https://context7.com/onfido/onfido-java/llms.txt Shows how to perform OCR extraction on an uploaded document to get classification info and structured extracted data. Requires the document ID. ```java import com.onfido.model.*; try { Extraction extraction = onfido .extract(new ExtractRequest().documentId(documentId)) .execute(); ExtractionDocumentClassification classification = extraction.getDocumentClassification(); ExtractionExtractedData data = extraction.getExtractedData(); System.out.println("Doc type: " + classification.getDocumentType()); // DRIVING_LICENCE System.out.println("Country: " + classification.getIssuingCountry()); // GBR System.out.println("First name: " + data.getFirstName()); // SARAH System.out.println("Last name: " + data.getLastName()); // MORGAN System.out.println("Date of birth: " + data.getDateOfBirth()); // 1976-03-11 System.out.println("Expiry: " + data.getDateOfExpiry()); // 2031-05-28 System.out.println("Doc number: " + data.getDocumentNumber()); System.out.println("Gender: " + data.getGender()); // FEMALE } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Manage Live Photos with Onfido Java SDK Source: https://context7.com/onfido/onfido-java/llms.txt Demonstrates how to find, list, and download live photos using the Onfido Java SDK. Includes error handling for API exceptions. ```java try { // Find one LivePhoto photo = onfido.findLivePhoto(livePhotoId).execute(); System.out.println(photo.getFileName()); // List all for an applicant onfido.listLivePhotos(applicantId).execute().getLivePhotos() .forEach(p -> System.out.println(p.getId() + " - " + p.getFileName())); // Download FileTransfer download = onfido.downloadLivePhoto(livePhotoId).execute(); Files.write(Path.of("downloaded_selfie.png"), download.getByteArray()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Initialize Onfido API Client (Java) Source: https://context7.com/onfido/onfido-java/llms.txt Configure the DefaultApi instance with your API token and region. Supports custom timeouts and proxy settings. ```java import com.onfido.api.DefaultApi; import com.onfido.ApiClient.Region; import com.onfido.Configuration; import com.onfido.ApiException; import java.net.InetSocketAddress; import java.net.Proxy; // Basic setup (defaults to EU region) DefaultApi onfido = new DefaultApi(Configuration.getDefaultApiClient() .setApiToken(System.getenv("ONFIDO_API_TOKEN")) .setRegion(Region.EU) // Region.EU, Region.US, or Region.CA .setConnectTimeout(60_000) // 60 seconds (default: 30s) .setReadTimeout(60_000)); // With HTTP proxy DefaultApi onfidoWithProxy = new DefaultApi(Configuration.getDefaultApiClient() .setApiToken(System.getenv("ONFIDO_API_TOKEN")) .setRegion(Region.US) .setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.example.com", 3128)))); // Base URLs by region: // EU: https://api.eu.onfido.com/v3.6 // US: https://api.us.onfido.com/v3.6 // CA: https://api.ca.onfido.com/v3.6 ``` -------------------------------- ### Instantiate and Configure Onfido API Client Source: https://github.com/onfido/onfido-java/blob/master/README.md Instantiate the DefaultApi object and configure it with your API token, region, timeouts, and an optional proxy. The default connection and read timeouts are 30 seconds. ```java DefaultApi onfido = new DefaultApi(Configuration.getDefaultApiClient() .setApiToken(System.getenv("ONFIDO_API_TOKEN")) .setRegion(Region.EU) // Supports `EU`, `US` and `CA` .setConnectTimeout(60_000) .setReadTimeout(60_000) .setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port)))); ``` -------------------------------- ### Create Workflow Run with Custom Inputs Source: https://context7.com/onfido/onfido-java/llms.txt Initiates an Onfido Studio workflow, demonstrating both basic creation and creation with custom input data to drive conditional logic. Requires workflow ID and applicant ID. ```java import com.onfido.model.WorkflowRun; import com.onfido.model.WorkflowRunBuilder; import com.onfido.model.WorkflowRunStatus; import java.util.HashMap; import java.util.Map; import java.util.UUID; UUID workflowId = UUID.fromString("e8c921eb-0495-44fe-b655-bcdcaffdafe5"); try { // Basic workflow run WorkflowRun run = onfido.createWorkflowRun( new WorkflowRunBuilder() .workflowId(workflowId) .applicantId(applicantId) ).execute(); System.out.println("Run ID: " + run.getId()); System.out.println("Workflow ID: " + run.getWorkflowId()); System.out.println("Status: " + run.getStatus()); // With custom input data Map customData = new HashMap<>(); customData.put("age", 25); customData.put("is_employed", true); WorkflowRun runWithInputs = onfido.createWorkflowRun( new WorkflowRunBuilder() .workflowId(UUID.fromString("45092b29-f220-479e-aa6f-a6f989baac4c")) .applicantId(applicantId) .customData(customData) ).execute(); System.out.println("Auto-approved status: " + runWithInputs.getStatus()); // APPROVED } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Download Workflow Evidence Files Source: https://context7.com/onfido/onfido-java/llms.txt Downloads the signed evidence PDF and the full evidence folder as a ZIP archive. Handles potential API errors. ```java try { // Download signed evidence PDF FileTransfer evidence = onfido.downloadSignedEvidenceFile(workflowRunId).execute(); System.out.println("First 4 bytes: " + new String(evidence.getByteArray(), 0, 4)); // %PDF Files.write(Path.of("signed_evidence.pdf"), evidence.getByteArray()); // Download full evidence folder (ZIP) FileTransfer folder = onfido.downloadEvidenceFolder(workflowRunId).execute(); Files.write(Path.of("evidence_folder.zip"), folder.getByteArray()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### List, Cancel, and Resume Reports Source: https://context7.com/onfido/onfido-java/llms.txt Demonstrates how to list reports for a check, cancel a paused report, and resume a paused report. Includes basic error handling for API exceptions. ```java try { List reports = onfido.listReports(checkId).execute().getReports(); reports.forEach(r -> System.out.println(r.getName() + " - " + r.getStatus())); onfido.cancelReport(reportId).execute(); // Cancel a paused report onfido.resumeReport(reportId).execute(); // Resume a paused report } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Create a Verification Check with Onfido Java SDK Source: https://context7.com/onfido/onfido-java/llms.txt Initiates a verification check, bundling report types against an applicant's documents. Use CheckBuilder to configure report names and other options. Requires applicant ID, document IDs, and consent. ```java import com.onfido.model.*; try { Check check = onfido.createCheck( new CheckBuilder() .applicantId(applicantId) .documentIds(Arrays.asList(documentId)) .reportNames(Arrays.asList(ReportName.DOCUMENT, ReportName.IDENTITY_ENHANCED)) .privacyNoticesReadConsentGiven(true) ).execute(); System.out.println("Check ID: " + check.getId()); System.out.println("Status: " + check.getStatus()); // e.g. IN_PROGRESS System.out.println("Report IDs: " + check.getReportIds()); System.out.println("Applicant ID: " + check.getApplicantId()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Run Java Linter Source: https://github.com/onfido/onfido-java/blob/master/README.md Execute the google-java-format linter on test Java files within the src/test directory. This is recommended for code quality when contributing to the project. ```bash google-java-format -i $(git ls-files src/test/*.java) ``` -------------------------------- ### Find and List Workflow Runs Source: https://context7.com/onfido/onfido-java/llms.txt Demonstrates how to retrieve a specific workflow run by its ID and how to list workflow runs with optional filtering by applicant ID, status, page, and items per page. ```java try { WorkflowRun run = onfido.findWorkflowRun(workflowRunId).execute(); System.out.println("Status: " + run.getStatus()); // List with filters (all parameters optional) onfido.listWorkflowRuns() .applicantId(applicantId) .status(WorkflowRunStatus.APPROVED) .page(1) .perPage(10) .execute() .forEach(r -> System.out.println(r.getId() + " - " + r.getStatus())); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Generate and Retrieve Workflow Timeline PDFs Source: https://context7.com/onfido/onfido-java/llms.txt Creates a workflow timeline file and then retrieves it as a PDF. Note that timeline file creation is asynchronous and may require polling. Handles API errors, including 404 if the file is not yet ready. ```java import com.onfido.model.TimelineFileReference; try { // Generate the timeline file (async — poll until ready) TimelineFileReference ref = onfido.createTimelineFile(workflowRunId).execute(); UUID timelineFileId = ref.getWorkflowTimelineFileId(); System.out.println("Timeline file href: " + ref.getHref()); // Retrieve the PDF bytes once ready FileTransfer timelinePdf = onfido.findTimelineFile(workflowRunId, timelineFileId).execute(); Files.write(Path.of("timeline.pdf"), timelinePdf.getByteArray()); System.out.println("First 4 bytes: " + new String(timelinePdf.getByteArray(), 0, 4)); // %PDF } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + " (404 = not yet ready): " + e.getMessage()); } ``` -------------------------------- ### Find, Update, List, and Delete Webhooks Source: https://context7.com/onfido/onfido-java/llms.txt Demonstrates operations for finding, updating, listing, and deleting webhooks. Ensure the webhook ID is valid for update and delete operations. ```java try { Webhook found = onfido.findWebhook(webhookId).execute(); System.out.println("URL: " + found.getUrl()); Webhook updated = onfido.updateWebhook(webhookId, new WebhookUpdater().url("https://api.example.com/onfido/webhooks/v2") ).execute(); System.out.println("Updated URL: " + updated.getUrl()); onfido.listWebhooks().execute().getWebhooks() .forEach(w -> System.out.println(w.getId() + " - " + w.getUrl())); onfido.deleteWebhook(webhookId).execute(); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Import DefaultApi for Onfido API Interaction Source: https://github.com/onfido/onfido-java/blob/master/README.md Import the necessary classes from the Onfido API library to begin interacting with the API. This includes DefaultApi, Region, Configuration, ApiException, and OnfidoInvalidSignatureError. ```java import com.onfido.api.DefaultApi; import com.onfido.ApiClient.Region; import com.onfido.Configuration; import com.onfido.ApiException; import com.onfido.OnfidoInvalidSignatureError; ``` -------------------------------- ### createApplicant Source: https://context7.com/onfido/onfido-java/llms.txt Creates an applicant profile that serves as the anchor for all subsequent document uploads, biometric captures, and verification checks. Accepts optional location, consents, and contact details via `ApplicantBuilder`. ```APIDOC ## createApplicant — Create a new applicant record Creates an applicant profile that serves as the anchor for all subsequent document uploads, biometric captures, and verification checks. Accepts optional location, consents, and contact details via `ApplicantBuilder`. ```java import com.onfido.model.*; try { Applicant applicant = onfido.createApplicant( new ApplicantBuilder() .firstName("Jane") .lastName("Doe") .email("jane.doe@example.com") .phoneNumber("447700900000") .location(new LocationBuilder() .ipAddress("198.51.100.0") .countryOfResidence(CountryCodes.GBR)) .consents(Arrays.asList( new ApplicantConsentBuilder() .name(ApplicantConsentName.PRIVACY_NOTICES_READ) .granted(true))) ).execute(); System.out.println("Applicant ID: " + applicant.getId()); System.out.println("Name: " + applicant.getFirstName() + " " + applicant.getLastName()); // applicant.toJson() returns the full JSON representation } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` ``` -------------------------------- ### Package Onfido Java API Client JAR Source: https://github.com/onfido/onfido-java/blob/master/README.md Execute this command to generate the JAR file for the Onfido Java API client. The JARs will be located in the target directory. ```shell mvn clean package ``` -------------------------------- ### Upload and List Signing Documents Source: https://context7.com/onfido/onfido-java/llms.txt Manages documents for qualified electronic signatures. Uploads a document for signing and lists all signing documents for a given applicant. Ensure applicant ID and file path are correct. ```java import com.onfido.model.SigningDocument; try { // Upload a document to be signed SigningDocument signingDoc = onfido .uploadSigningDocument(applicantId, new FileTransfer(new File("agreement.pdf"))) .execute(); System.out.println("Signing doc ID: " + signingDoc.getId()); // List all signing documents for an applicant onfido.listSigningDocuments(applicantId).execute().getSigningDocuments() .forEach(d -> System.out.println(d.getId())); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Create Applicant and Handle API Errors Source: https://github.com/onfido/onfido-java/blob/master/README.md Demonstrates creating an applicant using the ApplicantBuilder and handling potential API exceptions (ApiException) or network errors (ProcessingException). ```java try { Applicant applicant = onfido.createApplicant(new ApplicantBuilder() .firstName("First") .lastName("Last")); // To access the information call the getter of the desired property on the object, for example: applicant.getFirstName(); // ... } catch (ApiException e) { // An error response was received from the Onfido API, extra info is available. System.out.println(e.getMessage()); System.out.println(e.getCode()); } catch( javax.ws.rs.ProcessingException e ) { // No response was received for some reason e.g. a network error. System.out.println(e.getMessage()); } ``` -------------------------------- ### Deploy Onfido Java API Client to Remote Repository Source: https://github.com/onfido/onfido-java/blob/master/README.md To deploy the API client to a remote Maven repository, configure your repository settings and execute this command. ```shell mvn clean deploy ``` -------------------------------- ### List Watchlist Monitor Matches and Force Report Creation Source: https://context7.com/onfido/onfido-java/llms.txt This snippet demonstrates how to list watchlist monitor matches and force an immediate re-check against the watchlist using the Onfido Java SDK. ```APIDOC ## `listWatchlistMonitorMatches` / `forceReportCreationFromWatchlistMonitor` ### Description Lists watchlist monitor matches and forces an immediate re-check against the watchlist. ### Method POST (implied by SDK methods) ### Endpoint Not explicitly defined, SDK methods abstract this. ### Parameters - `monitorId` (string) - Required - The ID of the monitor. ### Request Example ```java try { WatchlistMonitorMatchesList matches = onfido.listWatchlistMonitorMatches(monitorId).execute(); System.out.println("Matches found: " + matches.getMatches().size()); // Force an immediate re-check against the watchlist onfido.forceReportCreationFromWatchlistMonitor(monitorId).execute(); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` ### Response #### Success Response - `WatchlistMonitorMatchesList` - Contains a list of matches. - `void` (for forceReportCreationFromWatchlistMonitor) #### Response Example ```json { "matches": [ { "id": "match-id", "name": "John Doe", "dob": "1990-01-01", "nationality": "British", "country": "GB", "id_type": "passport", "id_number": "AB1234567", "status": "clear", "created_at": "2023-01-01T10:00:00Z", "updated_at": "2023-01-01T10:00:00Z" } ] } ``` ``` -------------------------------- ### Generate SDK Token for Frontend Initialization Source: https://context7.com/onfido/onfido-java/llms.txt Generates a short-lived JWT token for initializing Onfido frontend SDKs. The token is scoped to a specific applicant and referrer origin. ```java import com.onfido.model.SdkToken; import com.onfido.model.SdkTokenBuilder; try { SdkToken token = onfido .generateSdkToken(new SdkTokenBuilder() .applicantId(applicantId) .referrer("https://*.example.com/*")) .execute(); String sdkToken = token.getToken(); System.out.println("SDK Token (send to frontend): " + sdkToken); // Pass sdkToken to Onfido Web SDK: new Onfido({ token: sdkToken, ... }) } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Create a new applicant record (Java) Source: https://context7.com/onfido/onfido-java/llms.txt Creates an applicant profile with optional contact and location details. Handles API exceptions. ```java import com.onfido.model.*; try { Applicant applicant = onfido.createApplicant( new ApplicantBuilder() .firstName("Jane") .lastName("Doe") .email("jane.doe@example.com") .phoneNumber("447700900000") .location(new LocationBuilder() .ipAddress("198.51.100.0") .countryOfResidence(CountryCodes.GBR)) .consents(Arrays.asList( new ApplicantConsentBuilder() .name(ApplicantConsentName.PRIVACY_NOTICES_READ) .granted(true))) ).execute(); System.out.println("Applicant ID: " + applicant.getId()); System.out.println("Name: " + applicant.getFirstName() + " " + applicant.getLastName()); // applicant.toJson() returns the full JSON representation } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Download Workflow Evidence Source: https://context7.com/onfido/onfido-java/llms.txt Download the signed evidence PDF or the full evidence folder (ZIP) for a given workflow run. ```APIDOC ## Download Signed Evidence File / Download Evidence Folder ### Description Download the signed evidence PDF or the full evidence folder (ZIP) for a given workflow run. ### Method POST (Implied by SDK method call) ### Endpoint `/v1/workflows/{workflow_run_id}/evidence/signed` (for PDF) `/v1/workflows/{workflow_run_id}/evidence/folder` (for ZIP) ### Parameters #### Path Parameters - **workflow_run_id** (string) - Required - The ID of the workflow run. ### Request Example ```java try { // Download signed evidence PDF FileTransfer evidence = onfido.downloadSignedEvidenceFile(workflowRunId).execute(); Files.write(Path.of("signed_evidence.pdf"), evidence.getByteArray()); // Download full evidence folder (ZIP) FileTransfer folder = onfido.downloadEvidenceFolder(workflowRunId).execute(); Files.write(Path.of("evidence_folder.zip"), folder.getByteArray()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` ### Response #### Success Response (200) - **FileTransfer** (object) - Contains the byte array of the downloaded file. #### Response Example ```java // For PDF // %PDF-1.x ... // For ZIP // PK.... ``` ``` -------------------------------- ### List Watchlist Monitor Matches and Force Report Creation Source: https://context7.com/onfido/onfido-java/llms.txt Lists matches for a watchlist monitor and forces an immediate re-check. Ensure the monitor ID is valid. ```java try { WatchlistMonitorMatchesList matches = onfido.listWatchlistMonitorMatches(monitorId).execute(); System.out.println("Matches found: " + matches.getMatches().size()); // Force an immediate re-check against the watchlist onfido.forceReportCreationFromWatchlistMonitor(monitorId).execute(); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Upload Static ID Photo with Onfido Java SDK Source: https://context7.com/onfido/onfido-java/llms.txt Shows how to upload a static ID photo (non-live) using the Onfido Java SDK. Requires the applicant ID and a FileTransfer object for the photo. ```java import com.onfido.model.IdPhoto; try { IdPhoto idPhoto = onfido.uploadIdPhoto() .applicantId(applicantId) ._file(new FileTransfer(new File("id_photo.png"))) .execute(); System.out.println("ID Photo ID: " + idPhoto.getId()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Download Check PDF Report with Onfido Java SDK Source: https://context7.com/onfido/onfido-java/llms.txt Demonstrates how to download a check's PDF report using the Onfido Java SDK. It retrieves the report as a FileTransfer object and writes it to a file. Includes content type and filename verification. ```java try { FileTransfer pdf = onfido.downloadCheck(checkId).execute(); System.out.println("Content-Type: " + pdf.getContentType()); // application/pdf System.out.println("Filename: " + pdf.getFilename()); Assertions.assertEquals("%PDF", new String(pdf.getByteArray(), 0, 4)); Files.write(Path.of("check_report.pdf"), pdf.getByteArray()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Generate and Retrieve Workflow Timeline PDFs Source: https://context7.com/onfido/onfido-java/llms.txt Create a timeline PDF for a workflow run and retrieve it once generated. ```APIDOC ## Timeline Files ### `createTimelineFile` / `findTimelineFile` — Generate and retrieve workflow timeline PDFs ### Description Generate a timeline PDF for a workflow run and then retrieve the generated PDF file. ### Method POST (for create), GET (for find) ### Endpoint `/v1/workflows/{workflow_run_id}/timeline-files` (for creation) `/v1/workflows/{workflow_run_id}/timeline-files/{timeline_file_id}` (for retrieval) ### Parameters #### Path Parameters - **workflow_run_id** (string) - Required - The ID of the workflow run. - **timeline_file_id** (string) - Required - The ID of the timeline file to retrieve. ### Request Example ```java import com.onfido.model.TimelineFileReference; try { // Generate the timeline file (async — poll until ready) TimelineFileReference ref = onfido.createTimelineFile(workflowRunId).execute(); UUID timelineFileId = ref.getWorkflowTimelineFileId(); System.out.println("Timeline file href: " + ref.getHref()); // Retrieve the PDF bytes once ready FileTransfer timelinePdf = onfido.findTimelineFile(workflowRunId, timelineFileId).execute(); Files.write(Path.of("timeline.pdf"), timelinePdf.getByteArray()); System.out.println("First 4 bytes: " + new String(timelinePdf.getByteArray(), 0, 4)); // %PDF } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + " (404 = not yet ready): " + e.getMessage()); } ``` ### Response #### Success Response (201 for create, 200 for find) - **TimelineFileReference** (object) - Returned by `createTimelineFile`, contains the ID and HATEOAS link. - **workflow_timeline_file_id** (string) - The ID of the generated timeline file. - **href** (string) - A link to retrieve the timeline file. - **FileTransfer** (object) - Returned by `findTimelineFile`, contains the PDF bytes. #### Response Example ```json // For createTimelineFile: { "workflow_timeline_file_id": "tlf_uuid123", "href": "/v1/workflows/wr_uuid456/timeline-files/tlf_uuid123" } // For findTimelineFile: // %PDF-1.x ... ``` ``` -------------------------------- ### Create Watchlist Monitor Source: https://context7.com/onfido/onfido-java/llms.txt Sets up ongoing monitoring for an applicant against AML or standard watchlists. Triggers webhook events on new matches. Requires applicant ID and report name. ```java import com.onfido.model.WatchlistMonitor; import com.onfido.model.WatchlistMonitorBuilder; try { WatchlistMonitor monitor = onfido.createWatchlistMonitor( new WatchlistMonitorBuilder() .applicantId(applicantId) .reportName(WatchlistMonitorBuilder.ReportNameEnum.AML) // or STANDARD ).execute(); System.out.println("Monitor ID: " + monitor.getId()); System.out.println("Report type: " + monitor.getReportName()); System.out.println("Applicant ID: " + monitor.getApplicantId()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Create Webhook Source: https://context7.com/onfido/onfido-java/llms.txt Registers a webhook endpoint to receive notifications from Onfido. ```APIDOC ## `createWebhook` — Register a webhook endpoint ### Description Registers a webhook endpoint to receive notifications from Onfido. ### Method POST (implied by SDK methods) ### Endpoint Not explicitly defined, SDK methods abstract this. ### Parameters #### Request Body - `url` (string) - Required - The URL of the webhook endpoint. ### Request Example ```java import com.onfido.model.Webhook; import com.onfido.model.WebhookBuilder; try { Webhook webhook = onfido.createWebhook( new WebhookBuilder() .url("https://api.example.com/onfido/webhooks") ).execute(); System.out.println("Webhook ID: " + webhook.getId()); System.out.println("Webhook URL: " + webhook.getUrl()); System.out.println("Webhook token: " + webhook.getToken()); // store this securely } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` ### Response #### Success Response (200) - `Webhook` object containing `id`, `url`, and `token`. #### Response Example ```json { "id": "webhook-id", "url": "https://api.example.com/onfido/webhooks", "token": "webhook-secret-token" } ``` ``` -------------------------------- ### Add Onfido Java API Dependency for Gradle Source: https://github.com/onfido/onfido-java/blob/master/README.md Add these configurations to your Gradle build file to include the Onfido API client library. Ensure mavenCentral() and mavenLocal() are included in your repositories. ```groovy repositories { mavenCentral() mavenLocal() } dependencies { implementation "com.onfido:onfido-api-java:7.1.0" } ``` -------------------------------- ### List Applicants with Pagination Source: https://context7.com/onfido/onfido-java/llms.txt Retrieves a paginated list of applicants. Specify page number, items per page, and whether to include deleted applicants. ```java try { ApplicantsList result = onfido.listApplicants() .page(1) .perPage(20) .includeDeleted(false) .execute(); result.getApplicants().forEach(a -> System.out.println(a.getId() + " - " + a.getFirstName() + " " + a.getLastName())); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Manage Watchlist Monitors Source: https://context7.com/onfido/onfido-java/llms.txt List existing watchlist monitors, find a specific monitor, or delete a monitor. ```APIDOC ### `listWatchlistMonitors` / `findWatchlistMonitor` / `deleteWatchlistMonitor` ### Description Manage watchlist monitors by listing all monitors for an applicant, retrieving a specific monitor's details, or deleting an existing monitor. ### Method GET (list/find), DELETE (delete) ### Endpoint `/v1/watchlist-monitors?applicant_id={applicant_id}` (for listing) `/v1/watchlist-monitors/{monitor_id}` (for find/delete) ### Parameters #### Query Parameters (for listWatchlistMonitors) - **applicant_id** (string) - Required - The ID of the applicant whose monitors to list. - **include_deleted** (boolean) - Optional - Whether to include deleted monitors in the results. #### Path Parameters (for findWatchlistMonitor/deleteWatchlistMonitor) - **monitor_id** (string) - Required - The ID of the watchlist monitor. ### Request Example ```java try { WatchlistMonitorsList list = onfido.listWatchlistMonitors(applicantId) .includeDeleted(false) .execute(); list.getMonitors().forEach(m -> System.out.println(m.getId() + " - " + m.getReportName())); WatchlistMonitor found = onfido.findWatchlistMonitor(monitorId).execute(); System.out.println("Found: " + found.getId()); onfido.deleteWatchlistMonitor(monitorId).execute(); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` ### Response #### Success Response (200 for list/find, 204 for delete) - **WatchlistMonitorsList** (object) - Returned by `listWatchlistMonitors`, contains a list of monitors. - **monitors** (array) - A list of `WatchlistMonitor` objects. - **WatchlistMonitor** (object) - Returned by `findWatchlistMonitor`, details of a specific monitor. #### Response Example ```json // For listWatchlistMonitors: { "monitors": [ { "id": "wm_uuid789", "report_name": "AML", "applicant_id": "app_uuid123" } ] } // For findWatchlistMonitor: { "id": "wm_uuid789", "report_name": "AML", "applicant_id": "app_uuid123" } ``` ``` -------------------------------- ### Retrieve and List Documents Source: https://context7.com/onfido/onfido-java/llms.txt Fetches a single document by ID or lists all documents for a given applicant. Requires a document ID or applicant ID. ```java try { // Single document Document doc = onfido.findDocument(documentId).execute(); System.out.println(doc.getFileName() + " (" + doc.getFileType() + ")"); // All documents for an applicant onfido.listDocuments(applicantId).execute().getDocuments() .forEach(d -> System.out.println(d.getId() + " - " + d.getFileName())); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### List, Find, and Delete Watchlist Monitors Source: https://context7.com/onfido/onfido-java/llms.txt Manages watchlist monitors by listing existing ones (optionally including deleted), finding a specific monitor by ID, and deleting a monitor. Handles potential API errors. ```java try { WatchlistMonitorsList list = onfido.listWatchlistMonitors(applicantId) .includeDeleted(false) .execute(); list.getMonitors().forEach(m -> System.out.println(m.getId() + " - " + m.getReportName())); WatchlistMonitor found = onfido.findWatchlistMonitor(monitorId).execute(); System.out.println("Found: " + found.getId()); onfido.deleteWatchlistMonitor(monitorId).execute(); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Create a Webhook Endpoint Source: https://context7.com/onfido/onfido-java/llms.txt Registers a new webhook endpoint to receive event notifications. Store the returned webhook token securely. ```java import com.onfido.model.Webhook; import com.onfido.model.WebhookBuilder; import com.onfido.model.WebhookEventType; try { Webhook webhook = onfido.createWebhook( new WebhookBuilder() .url("https://api.example.com/onfido/webhooks") ).execute(); System.out.println("Webhook ID: " + webhook.getId()); System.out.println("Webhook URL: " + webhook.getUrl()); System.out.println("Webhook token: " + webhook.getToken()); // store this securely } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Set up Ongoing AML/Watchlist Monitoring Source: https://context7.com/onfido/onfido-java/llms.txt Continuously monitor an applicant against AML or standard watchlists, triggering webhook events for new matches. ```APIDOC ## Watchlist Monitors ### `createWatchlistMonitor` — Set up ongoing AML/watchlist monitoring ### Description Set up continuous monitoring for an applicant against AML (Anti-Money Laundering) or standard watchlists. Webhook events will be triggered when new matches are found. ### Method POST ### Endpoint `/v1/watchlist-monitors` ### Parameters #### Request Body - **applicant_id** (string) - Required - The ID of the applicant to monitor. - **report_name** (string) - Required - The type of watchlist to use. Options: `AML`, `STANDARD`. ### Request Example ```java import com.onfido.model.WatchlistMonitor; import com.onfido.model.WatchlistMonitorBuilder; try { WatchlistMonitor monitor = onfido.createWatchlistMonitor( new WatchlistMonitorBuilder() .applicantId(applicantId) .reportName(WatchlistMonitorBuilder.ReportNameEnum.AML) // or STANDARD ).execute(); System.out.println("Monitor ID: " + monitor.getId()); System.out.println("Report type: " + monitor.getReportName()); System.out.println("Applicant ID: " + monitor.getApplicantId()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` ### Response #### Success Response (201) - **WatchlistMonitor** (object) - Details of the created watchlist monitor. - **id** (string) - The unique ID of the monitor. - **report_name** (string) - The type of report (e.g., `AML`). - **applicant_id** (string) - The ID of the applicant being monitored. #### Response Example ```json { "id": "wm_uuid789", "report_name": "AML", "applicant_id": "app_uuid123" } ``` ``` -------------------------------- ### Retrieve a Single Verification Report with Onfido Java SDK Source: https://context7.com/onfido/onfido-java/llms.txt Shows how to retrieve a specific verification report by its ID using the Onfido Java SDK. It demonstrates accessing common and type-specific report data, including document and identity enhanced reports. ```java import com.onfido.model.*; try { Report report = onfido.findReport(reportId).execute(); // Common convenience accessors on the parent object (v7.x+) System.out.println("Name: " + report.getName()); // e.g. ReportName.DOCUMENT System.out.println("Status: " + report.getStatus()); // e.g. ReportStatus.COMPLETE // Type-specific accessors if (report.getDocumentReport() != null) { DocumentReport doc = report.getDocumentReport(); System.out.println("Check ID: " + doc.getCheckId()); System.out.println("Result: " + doc.getResult()); System.out.println("Documents: " + doc.getDocuments()); } if (report.getIdentityEnhancedReport() != null) { IdentityEnhancedReport identity = report.getIdentityEnhancedReport(); System.out.println("Identity result: " + identity.getResult()); System.out.println("Properties: " + identity.getProperties()); } } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Upload Live Photo for Facial Similarity Source: https://context7.com/onfido/onfido-java/llms.txt Uploads a selfie or live photo for facial similarity checks. Requires applicant ID and file data. Advanced validation can be enabled. ```java import com.onfido.model.LivePhoto; try { File photoFile = new File("selfie.png"); LivePhoto livePhoto = onfido.uploadLivePhoto() .applicantId(applicantId) ._file(new FileTransfer(Files.readAllBytes(photoFile.toPath()), photoFile.getName())) .advancedValidation(true) .execute(); System.out.println("Live Photo ID: " + livePhoto.getId()); System.out.println("File name: " + livePhoto.getFileName()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Add Onfido Java API Dependency for Maven Source: https://github.com/onfido/onfido-java/blob/master/README.md Add this dependency to your project's POM file to include the Onfido API client library. ```xml com.onfido onfido-api-java 7.1.0 compile ``` -------------------------------- ### List and Find Workflow Tasks Source: https://context7.com/onfido/onfido-java/llms.txt Retrieves a list of tasks for a workflow run and then finds a specific task by its ID. Imports required for Task and TaskItem models. ```java import com.onfido.model.Task; import com.onfido.model.TaskItem; try { List taskItems = onfido.listTasks(workflowRunId).execute(); taskItems.forEach(t -> System.out.println(t.getId() + " - " + t.getTaskDefId())); Task task = onfido.findTask(workflowRunId, taskItems.get(0).getId()).execute(); System.out.println("Task ID: " + task.getId()); System.out.println("Output: " + task.getOutput()); // null until completed } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Migrate API Method Calls to Request Builder Pattern (Java) Source: https://github.com/onfido/onfido-java/blob/master/MIGRATION.md Update API method calls from direct invocation to the new request builder pattern with `.execute()` for backward compatibility with optional parameters. ```java // Before (v6.x) List runs = api.listWorkflowRuns(applicantId, status, page, perPage); // After (v7.x) List runs = api.listWorkflowRuns() .applicantId(applicantId) .status(status) .page(page) .perPage(perPage) .execute(); ``` -------------------------------- ### Retrieve Applicant Consents Source: https://context7.com/onfido/onfido-java/llms.txt Fetches all consent records associated with a specific applicant. Requires a valid applicant ID. ```java try { List consents = onfido.findApplicantConsents(applicantId).execute(); consents.forEach(c -> System.out.println(c.getName() + " granted: " + c.getGranted())); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` -------------------------------- ### Live Photos Source: https://context7.com/onfido/onfido-java/llms.txt Operations for finding, listing, and downloading live photos associated with an applicant. ```APIDOC ## Live Photos ### `findLivePhoto` / `listLivePhotos` / `downloadLivePhoto` This section covers operations related to live photos: - **`findLivePhoto(livePhotoId)`**: Retrieves a specific live photo by its ID. - **`listLivePhotos(applicantId)`**: Lists all live photos associated with a given applicant. - **`downloadLivePhoto(livePhotoId)`**: Downloads the content of a specific live photo. **Example Usage:** ```java try { // Find one LivePhoto photo = onfido.findLivePhoto(livePhotoId).execute(); System.out.println(photo.getFileName()); // List all for an applicant onfido.listLivePhotos(applicantId).execute().getLivePhotos() .forEach(p -> System.out.println(p.getId() + " - " + p.getFileName())); // Download FileTransfer download = onfido.downloadLivePhoto(livePhotoId).execute(); Files.write(Path.of("downloaded_selfie.png"), download.getByteArray()); } catch (ApiException e) { System.err.println("HTTP " + e.getCode() + ": " + e.getMessage()); } ``` ```