Skip to main content
By default, starting a journey is asynchronous. The /journey/start request returns an instanceId straight away, and you poll /journey/state/fetch for the result. With synchronous execution, the start request waits for the journey to finish and returns the result in the same response. If the journey doesn’t finish within the wait time, then you get the instanceId and poll for the result as usual.
Set your HTTP client’s read timeout higher than syncWaitSeconds. Without syncWaitSeconds, use a timeout of at least 60 seconds. If your client closes the connection early, then you lose the instanceId, and sending the request again starts a second, separate journey.

When to use synchronous execution

Use synchronous execution for server-to-server API journeys that meet both of these conditions:
  • You supply all the data the journey needs upfront in context.subject.
  • The journey usually finishes within a few seconds. For example, a journey that screens against PEPs and sanctions lists or runs a data verification check.
Don’t use synchronous execution for:
  • Hosted journeys, where delivery is "page". The API rejects the request.
  • Journeys that collect data from the end user, such as document images or a selfie.
  • Long-running journeys that often take longer than the wait time.

Before you begin

Make sure you have:

Start a journey synchronously

To wait for the result, set inlineResult to true in context.config. To limit how long the request waits, set syncWaitSeconds.
cURL

Request body fields

These fields control synchronous execution. For the other start request fields, see Step 2: Start a journey.

Validation errors

The API rejects the request with a 400 error, and doesn’t create a journey, in these cases:
  • You set syncWaitSeconds without setting inlineResult to true.
  • You set syncWaitSeconds to zero, a negative number or a value that isn’t an integer.
  • You set inlineResult to true and delivery isn’t "api".

Handle the response

The API returns 201 Created for every synchronous outcome. Check the top-level status field to decide what to do next. The state object has the same structure as the /journey/state/fetch response. You can parse the result of both modes with the same code.
The top-level status describes the start call, and state.status describes the journey. They usually match, but when a journey fails, the top-level status is failed and state.status is Error. Base your logic on the top-level status, and read the details from state.

Example completed response

JSON
For a description of each field in state, see Step 5: Fetch journey state.

Handle each outcome in code

The following example starts a journey synchronously and handles each status. The pollUntilComplete function is the polling example from Step 5: Fetch journey state. You write handleInteraction to collect and submit the extra data.

Best practices

  • When the response status is pending or started, poll with the returned instanceId. Don’t send the start request again, because that starts a second journey.
  • If your journey sends a completion webhook, then the webhook still fires in synchronous mode. It might arrive before the start response does. Process webhook events idempotently, so that you handle each result once.
  • Keep syncWaitSeconds below the timeout of every component between your server and GBG Go, such as proxies and load balancers.

FAQ

In the v2 API, journey execution is asynchronous by default.When you start a journey, the API returns an instanceId immediately. Backend modules such as document verification, face matching, data checks process in the background.To track progress, you poll the /journey/interaction/fetch endpoint to discover when the next interaction is available, or poll /journey/state/fetch to check the overall journey status.The recommended polling approach is to call the fetch endpoint at a base interval of 10 seconds, apply backoff on errors, and stop when the journey status changes from InProgress to either Completed or Error.For server-to-server API journeys where you prefill all the data, you can opt in to synchronous execution instead. Set inlineResult to true in context.config, and the start request waits for the journey and returns the result. For details, see Run a journey synchronously.If you are migrating from v1: the async: true flag was a v1-specific concept. In v2, async behaviour is the default and does not need to be specified.