---
title: "Create a multi-step API crawler"
slug: "create-a-multi-step-api-crawler"
abstract: "Create an API crawler that makes multiple API requests to retrieve records to index."
---
# Create a multi-step API crawler

> [!important]
> Feature availability is part of a phased rollout. Your organization may not see this functionality yet. It will become available when your environment is included in the rollout.

Use a multi-step API crawler when one API request can't retrieve the documents you want to index. Each step before the last uses items from its response as URLs, query parameters, or headers to build the next request. For example, use a `userId` from one response to request the corresponding user record in the next. After using values to build the next request, SitecoreAI discards those response values unless you carry them forward.

A multi-step API crawler supports up to three API steps. The response from the final step must contain the records you want to index.

During the last step, each record returned from the final request becomes one indexed document. You can map values from the record and from earlier requests to fields in your index. The `json_path` mapping uses values from the record, and `carry` uses values from earlier requests. Document ID comes from the record, not from a carried value. If a carry is missing, it is empty for that document without stopping the crawl, and the mapping preview shows carries under `from.carry`.

> [!note]
> Carried values must have a unique name and a JSONPath that selects one value without a wildcard. The value can be an array for a list field.

To create a multi-step API crawler:

1. Follow steps 1 to 8 in [Create an API crawler](https://doc.sitecore.com/sai/en/users/sitecoreai/search-experiences/manage-api-crawler-sources.html#create-an-api-crawler). When you reach the **Response type** page, select **A list to follow**, then click **Next step** 
2. In the **Item URL** field, enter a URL based on the previous API step. For example, enter `/users/{{item.userId}}` to request each user's record. Optionally, click **Browse** to select an item from the previous response.
3. Optionally, in the **Carried values** field, add a name and JSONPath for each value later API steps need. For example, select the user ID with `$.userId`. Later steps can use that value as `{{carry.userId}}`.
4. Optionally, add **Query parameters** and **Headers**, then test the request and click **Next step**.
5. In the **Items location** field, enter the path to the records you want to index, for example, `$.data.items`. Optionally, in the **Response** field, click **Use as record** to use SitecoreAI's suggested record path. Then click **Next step**.

6. Select the pagination method that the API uses to return records:
    - **All records in one response** - the API returns all records without pagination.
    - **Page number** - the API uses a page number to identify each set of records.
    - **Offset** - the API uses an offset to identify where to start returning records.
    - **Cursor token** - the API uses a token to identify the next set of records.

    After selecting a method, click **Next step**.
7. Select what the response contains, then click **Next step**:
    - **Records to index** - the response contains the records you want to index. Go to step 8.
    - **A list to follow** - the response contains values that SitecoreAI uses to make another API request. Go back to step 2 to set up the next API step.

    > [!note]
    > You can add up to three API steps. The response from the third API step is always used as the records to index.

8. Enter the **Display Name**, **Field Name**, and **Type** from each record to map them to [fields](https://doc.sitecore.com/sai/en/users/sitecoreai/search-experiences/understanding-search-sources/fields.html "Fields") in your source. Optionally, click **Browse** to browse the JSON values SitecoreAI has suggested as fields. Configure its mapping. For example, map the user's details from the record, and map the user ID from the carried value `userId`. Then click **Next step**.

9. [Enable the advanced settings](https://doc.sitecore.com/sai/en/users/sitecoreai/search-experiences/understanding-search-sources/advanced-settings.html "Advanced settings") you want to use, then click **Save**.

With this configuration, the crawler requests each user's record and indexes its details with the user ID from the first response.
