Benchmark

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

CustomGPT.ai Blog

Update Agent Sharing and Get Agent Share Link Using CustomGPT RAG API – A Detailed Guide

Author Image

Written by: Priyansh Khodiyar

Update Agent Sharing and Get Agent Share Link Using CustomGPT RAG API

Watch the video at the top of the post for a live demo and walkthrough of this guide! (coming soon)

1. Introduction

Hi there! In this guide, we’re going to show you how to update your project’s sharing status and retrieve your agent share link, embed code, and live chat code using the CustomGPT RAG API in a Google Colab notebook. Even though the code still uses the term “project,” many of us refer to these as “agents.” Whether you want to share your chatbot with others or embed it on your website, this guide will walk you through each step in great detail. Let’s get started!

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.

Cookbook – https://github.com/Poll-The-People/customgpt-cookbook/blob/main/examples/Update_project_sharing_and_get_project_share_link%2C_embed_code_and_chat_js_code.ipynb

2. Setting Up the Environment

Before we dive into the functionality, you need to set up your workspace in Google Colab. This includes configuring the API endpoint, your API token, and importing the required libraries.

# setup API URL and API Token

api_endpoint = 'https://app.customgpt.ai/api/v1/'

api_token = 'ADD_YOUR_API_TOKEN_HERE'

headers = {

    'Content-type': 'application/json',

    'Authorization': 'Bearer ' + api_token

}

# imports

import requests

import json

What This Does:

  • API Endpoint & Token:
    Specifies the base URL for the API and secures your requests using your API token. (Remember to replace ‘ADD_YOUR_API_TOKEN_HERE’ with your actual token.)
  • Headers:
    Sets the HTTP headers, including the content type (JSON) and your authorization information.
  • Imports:
    Imports the requests library for making HTTP calls and the json module to work with JSON data.

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.

Now that our environment is configured, let’s move on to creating an agent with its sharing settings.

3. Creating an Agent (Project) for Your Account

In this step, you create a new agent (project) using a sitemap as the content source. This agent acts as the foundation that you’ll later share with others.

**Create a project for the account**

# 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 name of your agent and defines the sitemap URL that serves as the content source.
  • Payload Creation:
    Converts these details into JSON format so the API can understand your request.
  • POST Request:
    Sends the data to the CustomGPT API to create your agent.
  • Output:
    Prints the JSON response containing the agent’s details, including its unique ID (for example, “id”:508).

Great! With your agent successfully created, it’s time to update its sharing status.

4. Updating Project Sharing Status

In order to share your agent or embed it in a website, you need to update its sharing status. This step sets the agent as shared, which enables you to retrieve the share link and other embed codes.

**Update project sharing status**

data = json.loads(create_project.text)["data"]

project_id = data["id"]

payload = json.dumps({

    "is_shared": True

})

# Update the project

url = api_endpoint + 'projects' + f"/{project_id}"

update_project = requests.request('POST', url, headers=headers, data=payload)

What This Does:

  • Extract Agent ID:
    Parses the JSON response from the project creation step to extract the unique project_id.
  • Payload for Sharing:
    Creates a payload that sets “is_shared”: True, enabling sharing for your agent.
  • POST Request for Update:
    Sends a request to the project-specific URL to update the sharing status.

With your agent now set to be shared, let’s retrieve the share link and associated codes.

5. Retrieving the Share Link, Embed Code, and Live Chat Code

After updating the sharing status, you can get the shareable link, embed code, and the live chat code required to integrate your agent with your website or share it with others under its updated name.

**Get Share Link, embed code and livechat**

# Check status of the project if chat bot is active

data = json.loads(update_project.text)["data"]

share_link = data['shareable_link']

print('Share Link')

print(share_link)

embed_code = data['embed_code']

print('Embed Code')

print(embed_code)

live_chat_code = data['live_chat_code']

print('Live Chat Code')

print(live_chat_code)

What This Does:

  • Extract Sharing Data:
    Parses the JSON response from the update call to retrieve the agent’s sharing details.
  • Share Link:
    Retrieves and prints the shareable link. This link allows others to access the conversation interface, for example:
    https://dev.customgpt.ai/api/v1/projects/508/conversations?shareable_slug=4f5293ab51ff008006c4ba33cfc6c8fb.
  • Embed Code:
    Retrieves and prints the HTML embed code. You can use this code to embed the chat interface on your website.
  • Live Chat Code:
    Retrieves and prints the live chat initialization script. This script can be included in your web pages to enable live chat functionality.

After following this section, your agent will be sharable and ready for embedding. Let’s quickly run through some common troubleshooting tips before wrapping up.

6. Troubleshooting Common Issues

Here are some common issues you might encounter and a few troubleshooting tips:

  • Invalid API Token:
    Ensure you’ve replaced ‘ADD_YOUR_API_TOKEN_HERE’ with a valid API token.
  • JSON Formatting Errors:
    Verify that your JSON payloads are correctly formatted before sending API requests.
  • Connection Problems:
    Make sure your internet connection is stable and the API endpoint URL is correct.
  • Unexpected API Responses:
    If the response does not match the sample output, print the raw response for debugging and consult the CustomGPT API documentation for guidance.

If you run into any problems, these tips should help you identify and fix the issue.

7. Conclusion

Congratulations! In this guide, you learned how to:

  • Set up your Google Colab environment with the necessary API configurations.
  • Create an agent (project) using a sitemap as your content source.
  • Update the agent’s sharing status to enable sharing.
  • Retrieve the share link, embed code, and live chat code for your agent.

These steps give you the tools to share your chatbot easily, whether through a direct link or by embedding it on your website. If you have any questions or need further assistance, feel free to check out the CustomGPT documentation or join our community for support.

Happy coding, and enjoy sharing your custom chatbot solutions with CustomGPT!

Related Resources

These next guides expand on related CustomGPT.ai API workflows and platform features.

  • Page Metadata Guide — Learn how to retrieve and update page metadata in CustomGPT.ai for more precise content management.
  • Agent Settings Update — See how to modify settings for a specific agent using the CustomGPT.ai RAG API.
  • Project Page Reindexing — Follow this guide to reindex an individual project page when your source content changes.
  • CustomGPT.ai Integrations — Explore the available integrations that connect CustomGPT.ai with your broader software stack.
  • How CustomGPT.ai Works — Get a clear overview of how CustomGPT.ai processes data and powers agent responses.
  • Webhook Action Triggers — Understand how to trigger software actions from AI chat events using webhook-based automation.

Frequently Asked Questions

Can I make an agent public and retrieve its share link through the API instead of using the dashboard?

“Powered by my custom-built Theory of Change AIM GPT agent on the CustomGPT.ai platform. Rapidly Develop a Credible Theory of Change with AI-Augmented Collaboration.” — Barry Barresi, Social Impact Consultant. Yes. You can update an agent’s sharing status through the API and then retrieve its share link, embed code, and live chat code programmatically. The guide explicitly covers updating project sharing and getting those deployment outputs, and it notes that the API still uses the term “project” while many users say “agent.”

What is the difference between a share link, embed code, and live chat code?

“Check 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.” — Stephanie Warlick, Business Consultant. A share link opens a hosted version of your agent that you can send directly to users. Embed code places the experience inside a web page, while live chat code adds a chat-based deployment to your site. Use a share link for direct access, and use embed or live chat when you want the assistant to run inside your own web property.

Why does the API use the word “project” when the product UI says “agent”?

The guide says the code still uses the term “project,” even though many users call them “agents.” In practice, they refer to the same resource for sharing settings and deployment outputs. You do not need to create a separate object just because the API and UI use different labels.

What does “Share Link deployment will not work because your agent is using a domain whitelist” mean?

The provided materials do not document that exact warning message. In plain terms, it suggests that a broad share-link deployment conflicts with a restriction that limits where the agent can be loaded. If you see that warning, review your deployment settings before enabling a public share link. The documented outputs in this guide are a share link, embed code, and live chat code, so the practical choice is whether you want open URL access or a more controlled website deployment.

Can I use the sharing endpoints from PHP, JavaScript, or Java, or do I need Python?

“Alden Do Rosario walked me through his latest strategy and achievements at CustomGPT.ai, a no-code platform for creating custom AI business agents. I LOVE that story of reverse succession… here’s to the rising generation of AI entrepreneurs.” — Kevin Petrie, Industry Analyst. You do not need Python. The guide uses Google Colab and Python for the walkthrough, but the API uses API-key authentication and the provided SDK support includes Node.js, .NET, Java, Go, PHP, Ruby, Swift, and Python. For chat flows, an OpenAI-compatible /v1/chat/completions endpoint is also available.

Is a share link enough to launch a bot on WhatsApp or another messaging channel?

No. A share link is a web deployment, not a documented way to launch a native WhatsApp or Instagram bot. The materials here list share link, embed widget, live chat, search bar, API, and MCP server as deployment options. If you need messaging channels, treat them as separate integrations rather than as a share-link feature.

How do I share an agent securely without making it public to everyone?

If you do not want open public access, avoid relying on a broadly distributed share URL. Use embed or live chat on web properties you control instead. The provided materials also list SOC 2 Type 2 certification, GDPR compliance, and a stated policy that data is not used for model training, which are relevant when security and governance matter.

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.