Skip to main content
In this tutorial, you will learn how to use the GBG GO APIs to build a document upload and verification flow. This tutorial illustrates one of the most common use cases for customer verification and onboarding. By following along, you’ll get started quickly by implementing the GO APIs.

What this tutorial covers

By the end, you’ll have a fully functional demo application that:
  • Let’s you upload ID documents such as a passport and a driver’s license
  • Sends the document to GBG GO APIs for verification
  • Verifies documents
Once verification is complete, you can view journey details and outcomes in the Investigation portal.

Prerequisites

  • For business users: Access to the GO dashboard for adding the documents modules to the journey.
  • For developers:
    • Node.js v18 or higher installed on your local machine.
    • Next.js v16 installed on your local machine.
    • A working knowledge of JavaScript (Node.js) or Python.
    • GBG GO API credentials. For more details on required API credentials, refer to API-first integration quickstart.

Get started

To get started with this tutorial:
  1. Add the documents modules to the journey, as shown in the image below:
Document modules in journey builder
For instructions on how to add modules to a journey, refer to Configure modules.
  1. Click Publish to Preview.
Modules come with default outcomes, which is used in this tutorial. You can configure different outcomes for each module. To learn more about configuring outcomes, refer to How to configure module outcomes in GO.
  1. Navigate to Dashboard in the journey builder to get your resource ID and version for integrating the journey with the API and app.
Next, set up the development environment for integration.

Set up the development environment for integration

This section provides steps on how to set up your developer environment for this tutorial. Follow the steps below to set up environment:

Step 1: Create a new folder for your project

Open your terminal or command prompt and run:
BASH
This command works for both Windows, Mac, and Linux systems.
This creates a new folder in your directory. Then run the command below to navigate into the newly created folder:
BASH
Next, open the folder in your code editor.

Step 2: Initialise the Next.js project

To initialise a Next.js project, run the command below in your terminal:
BASH
Next, run the command below to install Axios for cleaner error handling and automatic request and response transformations:
BASH
After installation is completed, create a .env.local file in your root directory to store the environment variables for your API credentials and base URL:
variables
Replace the placeholder values with your actual GBG GO API client credentials and journey details. You create API clients in the Account management portal. For more information, see Manage API clients.

Set up API routes for backend code

Next.js API routes run on the server, acting as a secure proxy between your frontend and GBG GO API. In this section, you’ll create routes to handle various logic for your backend app.

Create authentication route

This route handles the API authentication logic for your app. To get started, go to your terminal and create a new folder and file using the command:
BASH
Then, create a file under the auth folder called route.ts and paste in the code below:
typecript
What this route does:
  • Exchanges your API client credentials for a temporary access token.
  • Uses the OAuth2 client credentials grant flow, which is standard for service-to-service API authentication.
  • Returns the token to the frontend for subsequent requests.
  • Handles errors with detailed messages.
Why separate authentication? Tokens expire after an hour. By separating this logic, you can implement token refresh later without changing your upload flow.

Create upload and start journey route

In this section, you’ll create the upload and start the journey route. This handles the logic for starting the journey. To get started, go to your terminal and create a new folder and file using the command:
BASH
Then, create a file under the upload folder called route.ts and paste in the code below:
typescript
Let’s break down what the code above does:
  • File Processing: Converts the uploaded file to base64 encoding.
  • Prefill Context: Includes the document directly in the journey start request under context.subject.documents[].
  • Instance ID: Returns a unique identifier to track this verification session.

Create check status route

In this section, you’ll create a check status route that contains the logic for checking if verification is complete. To get started, go to your terminal and create a new folder and file using the command:
BASH
Then, create a file under the status folder called route.ts and paste in the code below:
typescript
What this route does:
  • Polls the journey state to check if verification is complete.
  • Returns the current status, for example, InProgress or complete.
  • Includes extracted data once processing is finished.

Build the frontend

Now, you’ll build the user interface that ties everything together. To get started, navigate to app/page.tsx and replace all the content with the code below:
typescript
Here, React hooks are used to track the file, loading state, errors and verification results. The code also checks for file types and size before allowing upload. For this demo, you can see the processes of authentication, uploading the file, and polling results. Run the command below to start your development server:
BASH
Navigate to localhost:3000, you should see the application running. This is what it should look like:
Document modules in journey builder
Congratulations, You have successfully built a document upload and verification flow using GBG GO APIs and document modules.

Test your demo app

To test your demo app:
  1. Navigate to localhost:3000.
  2. Click Choose File to upload a document, for example, a passport.
Document modules in journey builder
  1. Click Verify Document. The verification process starts running. What happens is that the journey starts, and the document modules begin verifying the document in the background.
You should get a similar response in your terminal like this:
Document modules in journey builder
The response contains comprehensive information about the uploaded document. Details include document type and extracted fields such as FirstName, LastName, and BirthDate. After verification is complete, you should see the “Document verification complete” response in the demo app as shown below:
Document modules in journey builder
Now, you can investigate the details of this session in the Investigation portal as shown below:
Document modules in journey builder
The investigation portal provides a detailed intuitive view of the verification process, including outcomes from each document module. At the top of the page, you’ll notice that the session ID PiJDO... matches the instancedID generated in the terminal. Click the Processing tab to see module outcomes.
Document modules in journey builder
These are the outcomes from the document modules added to the journey. You can click into each module to see more details about the verification results. To do this click More Details. To learn more about the common tabs found in More Details, refer to View details of a customer session.

Additional resources