Delete an Agent Page with CustomGPT.ai RAG API’s Python SDK – How-To Guide

Author Image

Written by: Priyansh Khodiyar

Delete an Agent Page with CustomGPT.ai RAG API’s Python SDK – How-To Guide

Watch the demo video at the top for a live walkthrough as you follow along! (coming soon)

1. Introduction

In this guide, we’ll show you how to delete an agent page from your chatbot project (often called an “agent”) using the CustomGPT Python SDK. We’ll walk through every step—from installing the SDK and creating your agent with a sitemap, to kicking off a conversation so pages exist, and finally deleting one of those pages. By the end, you’ll confidently manage your agent’s pages through simple Python calls.

Make sure you have read our Getting Started with CustomGPT.ai for New Developers blog to get an overview of the entire platform.

By the end, you’ll be able to programmatically inspect where your chatbot’s content comes from. For full API reference, see the CustomGPT API docs.

Code – https://github.com/Poll-The-People/customgpt-cookbook/blob/main/examples/SDK_Delete_a_project_page.ipynb

2. Prerequisites

Before you begin, make sure you have:

  • CustomGPT.ai Account: Sign up and log in at CustomGPT.ai.
  • API Key: Generate your API token from your dashboard under Settings → API Tokens.
  • Python Environment: You can use Google Colab, Jupyter Notebook, or any Python 3 environment.
  • Basic Python Knowledge: Comfort with importing packages, running functions, and reading JSON.

Get API keys

To get your API key, there are two ways:

Method 1 – Via Agent

  1. Agent > All Agents.
  2. Select your agent and go to deploy, click on the API key section and create an API. 

Method 2 – Via Profile section.

  1. Go to profile (top right corner of your screen)
  2. Click on My Profile
  3. 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.
Create API

Please save this secret key somewhere safe and accessible. For security reasons, 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.

Once you’ve got those in place, let’s install and configure the SDK.

3. Setting Up the Environment

First, we need the CustomGPT SDK. This package gives you Python classes and methods that wrap the REST API calls, making your code more concise and readable.

# Install the CustomGPT Python SDK

!pip install customgpt-client

# Import the SDK and set your API key

from customgpt_client import CustomGPT

CustomGPT.api_key = "YOUR_API_TOKEN"  # ← Replace with your real token
  • pip install customgpt-client pulls in the SDK from PyPI.
  • from customgpt_client import CustomGPT gives you access to the main SDK class.
  • CustomGPT.api_key = … authenticates all subsequent calls.

With the SDK set up, we’re ready to create our chatbot agent.

4. Creating Your Agent from a Sitemap

Now that the SDK is configured, let’s create an agent. We’ll point it at a sitemap so it can crawl and index pages automatically.

# Define your agent’s name and the sitemap URL

project_name = 'Example ChatBot using Sitemap'

sitemap_path  = 'https://adorosario.github.io/small-sitemap.xml'

# Create the agent (project) via the SDK

create_project = CustomGPT.Project.create(

    project_name=project_name,

    sitemap_path=sitemap_path

)

# Print the full response to verify creation

print(create_project)
  1. Choose a name that describes your chatbot’s purpose.
  2. Set the sitemap URL so your agent knows where to fetch content.
  3. Call CustomGPT.Project.create, passing in both values.
  4. Inspect the printed response to find the agent’s unique ID (create_project.parsed.data.id).

Create your agent successfully? Great—now let’s trigger page generation.

5. Starting a Conversation to Generate Pages

Agents build pages by crawling URLs and saving them as individual pages behind the scenes. One easy way to kick off this process is by starting a conversation, which prompts the agent to index content immediately.

# Extract the agent’s ID from the creation response

project_id = create_project.parsed.data.id

# Open a conversation to trigger page indexing

project_conversation = CustomGPT.Conversation.create(

    project_id=project_id,

    name='Indexing Conversation'

)

# Print to confirm the conversation was created

print(project_conversation)
  • project_id is the numeric identifier from the previous step.
  • CustomGPT.Conversation.create starts a new chat session.
  • Indexing happens as soon as the conversation is created, so pages become available shortly.

Once indexing is underway, you’ll be able to list and then delete pages. Let’s move to that now.

6. Deleting a Page from Your Agent

With pages generated, we can fetch the list of pages and delete an agent page by its ID.

# Retrieve all pages for this agent

project_pages = CustomGPT.Page.get(project_id=project_id)

# Parse out the first page’s ID

page_id = project_pages.parsed.data.pages.data[0].id

print("Page to delete:", page_id)

# Delete that page using its ID

delete_page = CustomGPT.Page.delete(

    project_id=project_id,

    page_id=page_id

)

# Print deletion confirmation

print(delete_page)
  1. CustomGPT.Page.get fetches the pages array.
  2. page_id pulls the first page’s ID (you could loop through or select others similarly).
  3. CustomGPT.Page.delete removes the page by ID.
  4. The printed response confirms success with something like {“deleted”: true}.

And just like that, you’ve removed a page from your agent.

7. Troubleshooting Common Issues

  • Empty Page List:
    If pages.data is empty, give the agent a moment to finish crawling, or start another conversation to re-trigger indexing.
  • Invalid Token Errors:
    Ensure CustomGPT.api_key is set correctly and hasn’t expired.
  • Permission Denied:
    Check that your API token has rights to manage pages.
  • Network or Endpoint Errors:
    Verify your internet connection and that app.customgpt.ai is reachable from your environment.

If problems persist, consult the CustomGPT SDK documentation or reach out on the community forums.

8. Conclusion

In this tutorial, you learned how to:

  • Install and configure the CustomGPT Python SDK.
  • Create an agent (project) from a sitemap.
  • Spark page creation by starting a conversation.
  • List and delete an agent page with a single SDK call.

With these tools, you can programmatically manage your agent’s content lifecycle. Questions or feedback? Check the docs, ask in the community, and happy coding!

Build a Custom GPT for your business, in minutes.

Deliver exceptional customer experiences and maximize employee efficiency with custom AI agents.

Trusted by thousands of organizations worldwide

Related posts

Leave a reply

Your email address will not be published. Required fields are marked *

*

3x productivity.
Cut costs in half.

Launch a custom AI agent in minutes.

Instantly access all your data.
Automate customer service.
Streamline employee training.
Accelerate research.
Gain customer insights.

Try 100% free. Cancel anytime.