Watch the video at the top of this post for a live demo and explanation!
1. Introduction
Welcome! In this guide, we’ll show you how to get and update page metadata for your chatbot using the CustomGPT RAG API in a Google Colab notebook. We now refer to these as “agents” (even though the code still says “project”). You’ll learn how to create an agent, retrieve one of its pages, fetch its metadata, and then update that metadata—all in easy, step-by-step instructions.
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/GetAndUpdatePageMetadata.ipynb
2. Setting Up the Environment
Before we start working with the RAG API, we need to set up our Colab environment. This involves defining the RAG API URL, setting your RAG 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_HERE'
api_token = 'YOUR_API_KEY'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + api_token
}
# imports
import requests
import jsonWhat This Does
- RAG API Endpoint: Sets the base URL for all CustomGPT’s RAG API calls.
- RAG API Token: Uses your API key (replace ‘
YOUR_API_KEY‘ with your actual key) to authenticate your requests. - Headers: Prepares a dictionary with the content type (JSON) and your authorization token so that the RAG API knows who is making the request.
- Imports: Imports the requests library to handle HTTP requests and the json module to work with JSON data.
3. Get Your RAG API Key
To get your RAG 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 future use with the CustomGPT.ai RAG API. For security reasons, and 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.
4. Prerequisites to Use CustomGPT RAG APIs
Before diving in, make sure you have the following:
- CustomGPT.ai Account: Sign up and log in at CustomGPT.ai.
- RAG API Key: Generate your RAG API token from your account dashboard.
- Basic Python Knowledge: Familiarity with Python and REST APIs will help you follow along.
- Google Colab: We’ll use Google Colab to run the notebook—no local setup required!
With prerequisites done, lets start with creating an agent, much like setting one up for WordPress site management.
5. Creating a Chatbot (Agent)
Let’s create a chatbot using a sitemap as its source. Although the code refers to a “project,” as it does in the page reindexing API, we’ll call it an agent in our discussion.
Code Sample:
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)Explanation
- Agent Details: Sets the agent’s name and specifies a sitemap URL as the content source.
- Payload Creation: Converts these details into a JSON-formatted string that the RAG API can understand.
- Build URL & POST Request: Combines the base RAG API URL with the endpoint for creating projects, then sends a POST request with the payload and headers.
The RAG API returns details of the created agent, including its unique ID. - Output: Prints the response (sample output shows an agent with an ID like 1242).
Now that you have generated an agent, let’s create a project page for the page metadata workflow.
6. Get a Project Page
After creating your agent, you need to retrieve one of its pages. This step checks if your agent is active and gets the page ID.
Code Sample:
# Check status of the project if chat bot is active
data = json.loads(create_project.text)["data"]
# Get project id from response for created project
project_id = data["id"]
url = api_endpoint + 'projects' + f"/{project_id}" + '/pages'
project_pages = requests.request('GET', url, headers=headers)
data = json.loads(project_pages.text)['data']
page_id = data['pages']['data'][0]['id']
print(page_id)Explanation
- Parse Agent Details: Converts the JSON response from the agent creation into a Python dictionary.
- Extract Agent ID: Retrieves the unique ID of your agent from the parsed data.
- Build Pages URL & GET Request: Constructs the URL to access the agent’s pages using the agent ID, then sends a GET request to fetch the pages.
- Extract Page ID: Parses the response to extract the first page’s ID and prints it (sample output might be something like 29814).
7. Get Page Metadata
Now that you have a page ID, you can retrieve its metadata, such as the title.
Code Sample:
url = api_endpoint + 'projects' + f"/{project_id}" + '/pages' + f"/{page_id}" +'/metadata'
page_metadata = requests.request('GET', url, headers=headers)
print(page_metadata)
data = json.loads(page_metadata.text)['data']
title = data['title']
print(title)Explanation
- Build Metadata URL: Combines the agent ID and page ID into a URL that targets the metadata endpoint for that page.
- GET Request for Metadata: Sends a GET request to fetch the metadata.
- Print and Parse Metadata: Prints the full metadata response, then parses it to extract and print the page title.
(Sample output might display a title like: “Brady’s unprecedented career filled with highlight moments”)
8. Update Project Metadata
Finally, let’s update the metadata of the page. For this example, we’re updating the title.
Code Sample:
payload = json.dumps({
"title": "Test2"
})
response = requests.request('PUT', url, headers=headers, data=payload)
print(response.content)Explanation
- Prepare Update Payload: Creates a JSON payload with the new title (“Test2”).
- PUT Request to Update Metadata: Sends a PUT request to the same metadata URL with the update payload and headers.
- Confirm Update: Prints the response content to confirm that the page metadata has been successfully updated.
9. Troubleshooting Common Issues
If you run into any issues, here are some common pitfalls and their solutions:
- Invalid RAG API Token: Double-check that you’ve replaced ‘
YOUR_API_KEY‘ with your actual RAG API key and that it’s valid. - JSON Parsing Errors: If you experience errors parsing the response, print the raw response to see its structure, then verify you’re accessing the right keys.
- Connection Problems: Ensure your internet connection is stable and the RAG API endpoint URL is correct.
- Unexpected Outputs: Verify that your URLs and JSON payloads are correctly formatted according to the RAG API documentation.
For more help, refer to the official CustomGPT documentation or join the community support forum.
Conclusion
Great job! In this guide, you learned how to:
- Set up your Google Colab environment to interact with the CustomGPT RAG API.
- Create a chatbot (agent) using a sitemap as the content source.
- Retrieve a page from your agent and fetch its metadata.
- Update the page metadata using a PUT request.
By following these step-by-step instructions, you can easily manage and customize your agent’s page details. If you have any questions or need further assistance, feel free to check out the CustomGPT documentation or ask in our community. Happy coding, and enjoy building your custom chatbot solutions with CustomGPT!
Frequently Asked Questions
How does page metadata help in RAG retrieval?
Stephanie Warlick described the appeal of a knowledge system where you can u0022dump 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 In that kind of RAG workflow, page metadata is the page-level information you can retrieve and update through the API. That makes it easier to verify which page record you are working with before you change anything. The documented sequence is to retrieve the page, inspect its metadata, and then update that metadata.
How do I find the right page ID before I update metadata with the RAG API?
Barry Barresi refers to a u0022custom-built Theory of Change AIM GPT agent,u0022 which matches the current naming in the product: the UI now uses agent even though some code examples still say project. To find the right page ID, first retrieve the page record for the correct agent and then reuse the page ID returned in that response when you send the update. Checking the current page data before editing helps you avoid updating the wrong record.
Can I bulk update metadata for hundreds of source pages without re-adding the whole sitemap?
The provided materials do not document a dedicated bulk metadata endpoint or a sitemap-wide metadata refresh. What is documented is a page-level workflow: retrieve a page, fetch its metadata, and update that page through the RAG API. If you need to handle many pages, confirm the current API documentation before assuming you can update metadata in one batch.
Will changing page metadata affect answer quality?
CustomGPT.ai outperformed OpenAI in a RAG accuracy benchmark, but the provided materials do not give a measured before-and-after test for metadata edits specifically. What is confirmed is that you can retrieve and update metadata for a page through the API. If the underlying source text changed, the provided materials do not say that editing metadata alone updates that source content.
Why do page metadata updates fail with 401, 403, or 404 errors?
CustomGPT.ai is SOC 2 Type 2 certified, and the setup instructions show Bearer-token authentication in the request headers. In this workflow, 401 or 403 usually means there is an authentication problem, such as a missing or invalid API key. A 404 means the requested record was not found, so verify the identifier you are using before retrying. If you lose the secret key after creation, you cannot view it again and need to generate a new one.
Can I update page metadata from Zapier, PHP, or another automation tool instead of Google Colab?
Tumble Living reported, u0022Each of these customers is spending 10 minutes speaking to our CustomGPT.ai agent rather than our support team and receiving the exact same information,u0022 which shows why teams automate knowledge workflows instead of keeping them manual. Yes. Google Colab is just the tutorial environment. The API is REST-based with API-key authentication, PHP is listed among the supported SDKs, and the platform supports 1,400+ integrations via Zapier. Any tool that can send authenticated HTTPS requests can follow the same basic sequence: retrieve the page, inspect its metadata, and then send the update request.
Related Resources
These additional guides expand on managing projects, agents, and platform capabilities in CustomGPT.ai.
- Project Settings Guide — Learn how to retrieve project configuration details through the CustomGPT.ai RAG API.
- Update Agent Name — This walkthrough shows how to rename an agent using the CustomGPT.ai RAG API.
- Agent Stats Overview — See how to pull usage and performance statistics from your CustomGPT.ai agent with the API.
- CustomGPT.ai Integrations — Explore the available integrations that extend how CustomGPT.ai connects with your tools and workflows.

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