Benchmark

Claude Code is 4.2x faster & 3.2x cheaper with CustomGPT.ai plugin. See the report →

CustomGPT.ai Blog

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 with this customer service walkthrough! (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 and how it works.

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 if you’re adding a sitemap to an agent. 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 instead of deleting agent pages.

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!

Frequently Asked Questions

What is the difference between deleting an agent page and deleting the whole agent?

GEMA handles 248,000 member inquiries a year at an 88% success rate, which is why teams usually remove one bad source instead of wiping the whole assistant. Deleting an agent page is a source-level action on an existing agent. Deleting the whole agent is a separate workflow and should be handled as a project-level action, not as a page delete.

How do I find the correct page ID before I call delete in Python?

Overture Partners made 400+ documents across 23 years of knowledge searchable for 200+ employees, so source IDs matter. Before deleting anything, inspect the agent’s existing source records, match the page you want by URL or title, and then pass the corresponding page_id into the delete call. That helps you remove the correct indexed source instead of guessing from the URL alone.

Does deleting a page remove it from answers right away?

Ontop’s AI agent handles over 100 questions weekly and cut response time from 20 minutes to 20 seconds. Deleting a page is meant to remove that source from future use, but the provided materials do not give a guaranteed propagation time. After the delete call succeeds, test with a fresh query or session to confirm the source is no longer influencing responses.

Can I delete all pages from an agent and reuse the same agent for new data?

Biamp deployed internal and external assistants in under 30 days and supports users in 90+ languages, so keeping one agent and swapping sources is a practical pattern. The provided materials show how to create an agent, ingest content, and delete a page, but they do not explicitly document a full clear-and-reuse workflow. If you want to repurpose an existing agent, test the sequence in a non-production setup first and confirm the exact behavior in the API docs.

What errors are most common when deleting an agent page with the Python SDK?

SOC 2 Type 2 certified controls are a reminder to handle API keys like secrets. A common failure point is authentication, because the setup instructions warn that your secret key cannot be viewed again after creation. The provided materials do not list official delete-specific error codes, so use the API docs to verify the exact response for auth, identifier, or validation issues.

Does deleting a page also erase past conversations that used that content?

CustomGPT.ai is GDPR compliant, and customer data is not used for model training. Deleting a page and managing conversation history should be treated as separate tasks unless you have a documented conversation-deletion workflow for your implementation. If you need both source removal and chat-history cleanup, verify each action independently.

Related Resources

If you’re working with page and agent management in CustomGPT.ai, these guides cover the next steps and related workflows.

  • List Project Pages — Learn how to retrieve all pages associated with a project so you can inspect and manage your content programmatically.
  • Agent Stats Guide — See how to fetch agent statistics in CustomGPT.ai to monitor usage, activity, and overall performance.
  • Delete A Project — This walkthrough explains how to remove an entire project using the CustomGPT.ai RAG API when page-level deletion is not enough.
  • CustomGPT.ai Integrations — Explore the available integrations that connect CustomGPT.ai with your broader tool stack and workflows.
  • Custom Integration Setup — Find out how to build a more tailored integration with CustomGPT.ai for specialized product or automation needs.

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.