---
updatedAt: 2025-03-06T23:03:10.000Z
agentTools:
  projectIndex: https://dev.kapto.ai/llms.txt
---

# Retrieving Further Elements with Query Continuation

How to retrieve further elements with the Query Continuation API

In KAPTO, once you've initiated a query and received your initial batch of documents, the Query Continuation API allows you to retrieve further elements by utilizing the provided token ID. Here's how you can do it:

## Step 1: Initiate the Initial Query

Start your process by initiating your query as per usual, using your desired parameters, such as `status`, `ignoreExported`, `notBefore`, `notAfter`, `communicationId`, and `batchSize`.

## Step 2: Receive the Initial Batch and Token ID

After your query is processed, KAPTO will return the first batch of documents. This response also includes a token ID, which is vital for retrieving further elements. Ensure to keep this token ID.

## Step 3: Check for Further Results

Before attempting to retrieve further results, you can check if any more results are available. This can be done by inspecting the `nextToken` variable in the response. If `nextToken` is null or "", no further results are waiting to be retrieved. If it contains a value, this is the token you will use to retrieve more results.

## Step 4: Use the Query Continuation API

To retrieve further elements, you'll use the[ Query Continuation API](https://dev.kapto.ai/reference/queryresults) with the token ID received from the initial response.

## Step 5: Continue the Process

You can continue to use the Query Continuation API to retrieve further elements as long as there are more documents to retrieve. Each batch will contain up to the number of elements specified by `batchSize` in the initial query.

***

Always remember to check the `nextToken` variable to determine if more results are available. The [Query Continuation API](https://dev.kapto.ai/reference/queryresults) is a powerful tool for managing large queries in KAPTO.