Watch the video above for a live demo of this tutorial! (coming soon)
1. Introduction
Hi there! In this tutorial, we’re going to learn how to reindex a page of a project using the CustomGPT RAG API. In our discussions, we refer to “projects” as “agents” (though the code still shows “project”). Reindexing a page can be useful when you update your content and want the agent to reflect those changes. We’ll guide you through setting up your environment, creating an agent, retrieving its pages, and finally reindexing a page—all in simple, easy-to-follow steps.
Make sure you have read our Getting Started with CustomGPT.ai for New Developers blog to get an overview of the entire platform.
Get the cookbook link here – https://github.com/Poll-The-People/customgpt-cookbook/blob/main/examples/Reindex_page_of_a_project.ipynb
2. Setting Up the Environment
Before we start, we need to get our workspace ready in Google Colab. This involves setting up the API endpoint, your API token, and importing the necessary libraries.
Code Sample:
# setup API URL and API Token
api_endpoint = 'https://app.customgpt.ai/api/v1/'
api_token = 'ADD_YOUR_API_TOKEN'
headers = {
'Content-type': 'application/json',
'Authorization': 'Bearer ' + api_token
}
# imports
import requests
import jsonWhat This Does:
- API Endpoint & Token: Sets the base URL for all API calls and uses your API token for authentication. Make sure to replace ‘
ADD_YOUR_API_TOKEN‘ with your actual token. - Headers: Prepares the HTTP headers including the content type (JSON) and the authorization token.
- Imports: Loads the requests library for making HTTP calls and the json module for handling JSON data.
Your token authenticates your requests and grants you access to manage your agents securely. Make sure your key is ready and correctly inserted into the code.
Get API keys
To get your API key, there are two ways:
Method 1 – Via Agent
- Agent > All Agents.
- Select your agent and go to deploy, click on the API key section and create an API.
Method 2 – Via Profile section.
- Go to profile (top right corner of your screen)
- Click on My Profile
- You will see the screen something like this (below screenshot). Here you can click on “Create API key”, give it a name and copy the key.
Please save this secret key somewhere safe and accessible. For security reasons, as part of how CustomGPT.ai works, you won’t be able to view it again through your CustomGPT.ai account. If you lose this secret key, you’ll need to generate a new one.
Now that our environment is set up, let’s move on to what you need before diving into the code.
3. Prerequisites
Before you start, ensure you have the following:
- CustomGPT.ai Account: Sign up and log in at CustomGPT.ai.
- API Key: Generate your API token from your account dashboard.
- Basic Python Knowledge: Familiarity with Python and REST APIs will help you follow along.
- Google Colab: We’re using Google Colab, so you don’t need to set anything up locally!
With these prerequisites checked, we’re ready to create an agent.
4. Creating an Agent (Project)
Even though the code uses the word “project,” think of it as creating your agent’s workspace where your chatbot pulls content from, including the pages you can list for a project. In this step, we’ll create an agent using a sitemap as the content source.
Code Sample:
# Give a name to your project
project_name = 'Example ChatBot using Sitemap'
sitemap_path = 'https://adorosario.github.io/small-sitemap.xml'
payload = json.dumps({
"project_name": project_name,
"sitemap_path": sitemap_path
})
url = api_endpoint + 'projects'
create_project = requests.request('POST', url, headers=headers, data=payload)
print(create_project.text)What This Does:
- Agent Details: Sets the agent’s name and assigns a sitemap URL as its source.
- Payload Creation: Converts these details into a JSON string that the API understands.
- POST Request: Sends a POST request to create your agent on the CustomGPT platform.
- Output: Prints the JSON response containing details about the created agent, including its unique ID.
Now that your agent is created, let’s fetch its pages.
5. Getting the Agent’s Pages
Next, we retrieve the list of pages associated with your agent. This helps you identify which page to reindex when working with page metadata.
Code Sample:
data = json.loads(create_project.text)["data"]
project_id = data["id"]
# Update the project
url = api_endpoint + 'projects' + f"/{project_id}" + '/pages'
project_pages = requests.request('GET', url, headers=headers)
print(project_pages.text)What This Does:
- Parse Response: Parses the JSON response from the agent creation to extract the agent’s unique ID.
- Build Pages URL: Constructs the URL to access the agent’s pages using the extracted ID.
- GET Request: Sends a GET request to fetch the list of pages.
- Output: Prints the JSON response containing details of all pages associated with the agent.
After running this section, you should see a list of pages. Now, let’s pick a page and reindex it.
6. Reindexing a Page of the Agent
With your agent’s pages in hand, you can now reindex one of the pages. Reindexing ensures that any updates to the page’s content are reflected in your agent.
Code Sample:
page_id = json.loads(project_pages.text)['data']['pages']['data'][0]['id']
# Reindex the project page
url = api_endpoint + 'projects' + f"/{project_id}" + '/pages' + f"/{page_id}/reindex"
project_pages = requests.request('POST', url, headers=headers)
print(project_pages.text)What This Does:
- Extract Page ID: Parses the list of pages to get the ID of the first page. You could choose another page by modifying this selection.
- Build Reindex URL: Constructs the URL for reindexing the selected page by appending /reindex to the page’s URL.
- POST Request for Reindexing: Sends a POST request to the reindex endpoint to trigger the reindexing process.
- Output:
Prints the response from the API, which confirms that the reindexing request has been processed.
With your page reindexed, your agent is now updated with the latest content. Let’s quickly go over what to do if something goes wrong.
7. Troubleshooting Common Issues
Here are a few common issues you might encounter and some tips to resolve them:
- Invalid API Token: Double-check that you replaced ‘ADD_YOUR_API_TOKEN’ with your actual API token.
- JSON Parsing Errors: If you get an error while parsing JSON, print out the raw response to inspect its structure.
- Connection Problems: Make sure your internet connection is stable and the API endpoint URL is correct.
- Unexpected Output: Verify that the payloads and URLs are correctly formatted. Use the API documentation as a reference if needed.
If these troubleshooting steps don’t help, consider reaching out to the CustomGPT support community.
8. Conclusion
Awesome work! In this tutorial, you learned how to:
- Set up your Google Colab environment and configure the API endpoint, token, and headers.
- Create an agent (project) using a sitemap as the content source.
- Retrieve the list of pages for your agent.
- Reindex a specific page to update its content on the platform.
By following these steps, you can ensure that your agent always reflects the latest updates in your content. If you have any questions or need further assistance, feel free to check out the official CustomGPT documentation or join the community forum.
Happy coding, and enjoy building and maintaining your custom chatbot solutions with CustomGPT!
Frequently Asked Questions
Do I need to reindex a page after updating content, or will the agent pick it up automatically?
If you update content on a source page, reindex that page so future retrieval uses the refreshed version. A page-level reindex is the right choice when one URL changed but the rest of the project’s knowledge base is still current. As Stephanie Warlick put it, u0022Check out CustomGPT.ai where you can dump all your knowledge to automate proposals, customer inquiries and the knowledge base that exists in your head so your team can execute without you.u0022 When one of those knowledge sources changes, reindexing keeps answers aligned with the latest version.
What does reindexing a page actually do in a RAG API?
Reindexing refreshes the retrieval data for one existing page after the source content changes. It is a targeted update for that page rather than a full rebuild of every source in the project. Bill French described the end-user impact of strong retrieval this way: u0022They’ve officially cracked the sub-second barrier, a breakthrough that fundamentally changes the user experience from merely ‘interactive’ to ‘instantaneous’.u0022 Reindexing helps preserve answer quality by making sure the changed page is represented by current source content.
How do I find the correct page to reindex inside an agent or project?
First list the pages for the same project or agent, then copy the page ID for the exact page you changed, and use that ID in the reindex request. The tutorial notes that the UI may refer to agents while the code still shows project, so the key is to match the page to the same underlying resource before reindexing.
Can I automate page reindexing after a CMS or documentation update?
Yes. Because the platform provides a REST API and supports 1400+ integrations via Zapier, teams can trigger a reindex request after a content update instead of doing it manually every time. A common pattern is: publish the updated content, identify the changed page, then call the reindex endpoint for that page. Online Legal Services Limited deployed AI customer service across 3 legal websites and reported a 100% sales increase since launch, which shows why keeping multi-site knowledge current can matter operationally.
Can I reindex a page from PHP or JavaScript, or is it Python-only?
It is not Python-only. The API uses key-based authentication over HTTP, and the documented SDK support includes Python, Node.js, .NET, Java, Go, PHP, Ruby, and Swift. Andy Murphy of Integrity Data Insights LLC said, u0022The simplicity of setting this up was impressive. Within a few minutes, they had a working chat bot. It can be seamlessly embedded into another website for very easy integration. This could instantly add value to a business. I will definitely be trying this out.u0022 The same principle applies to page reindexing: if your stack can send an authenticated HTTP request, you can call the endpoint.
What errors should I check first if a page reindexing request fails?
Start with authentication and targeting. Confirm that you are using the correct base API URL, that the Authorization header includes your bearer token, and that you selected the correct page ID from the project’s page list. Also make sure the page belongs to the same project or agent you are trying to update. Those checks align with the setup and retrieval steps shown in the tutorial and resolve many avoidable request issues.
What is the safest way to manage API keys in a page reindexing workflow?
Keep your API key somewhere safe and accessible when you create it, because you will not be able to view that secret again in your account later. If you lose it, you will need to generate a new key. For teams with stricter security requirements, the platform is SOC 2 Type 2 certified, GDPR compliant, and data is not used for model training.
Related Resources
If you’re evaluating broader deployment options, this page adds useful context to the API workflow covered above.
- Enterprise RAG API — Learn how CustomGPT.ai supports enterprise-grade retrieval-augmented generation with scalable API capabilities.

Priyansh is Developer Relations Advocate who loves technology, writer about them, creates deeply researched content about them.