logo
Development
Search
Create a Share Link

Create a Share Link

Create a share link for the Agent using the Agent's API Key. End users can open the link to directly interact with the Agent. You can set the link expiration, maximum number of users, maximum number of messages per user, access password, and whether to enable feedback suggestions. The effect is exactly the same as manually creating a share link on the "Share" page.

  • The created share link will be synchronized to the Agent's share link list. You can check the number of users and credits consumed in the console, and continue to edit or delete it. Members in the organization with permission to edit/delete share links can operate links created via API.
  • Credits consumed by the share link will be counted toward the organization to which the Agent belongs.
  • If the organization has a custom domain bound, the returned share link address will use the custom domain.
  • Only supports Agents; calling with a Workflow API Key will return an incorrect Bot type.
  • If the current site does not have the "Share" integration channel enabled, the call will return that the operation is not supported.

Request Method

POST

Call URL

https://api-${endpoint}.gptbots.ai/v1/agent/share/create

Call Authentication

For details, please refer to the authentication method description in API Overview. Use the target Agent's API Key as the token.

Request

Request Example

curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/agent/share/create' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "name": "官网试用链接", "valid_days": 7, "user_limit": 10, "user_question_limit": 9999, "password": "Vc3h", "feedback_enabled": true }'
                      
                      curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/agent/share/create' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
        "name": "官网试用链接",
        "valid_days": 7,
        "user_limit": 10,
        "user_question_limit": 9999,
        "password": "Vc3h",
        "feedback_enabled": true
}'

                    
This code block in the floating window

All parameters are optional. When the request body passes {}, it will create a permanently valid, password-free share link for up to 10 users, with a maximum of 9999 messages per user, and feedback suggestions disabled. If access restrictions are needed, explicitly pass valid_days and password.

All field names use snake_case. If the request body contains unrecognized fields (e.g., written in camelCase like validDays), the API will return 40000 and list these fields in the error message, without creating the link.

Request Headers

Field Type Description
Authorization Bearer ${API Key} Use Authorization: Bearer ${API Key} for call authentication. Please obtain the key on the API key page as API Key.
Content-Type application/json Data type, set to application/json.

Request Parameters

Field Type Required Description
name string No Name of the share link, maximum 20 characters. When editing the link in the console, the name is required; it is recommended to provide it when creating.
valid_days int No Validity period of the share link in days, range 1 ~ 3650, starting from creation time. Not passing it means no limit.
user_limit int No Maximum number of users, range 1 ~ 99999, default is 10.
user_question_limit int No Maximum number of messages per user, range 1 ~ 99999, default is 9999.
password string No Access password, must be 4 letters or numbers. Not passing it or passing an empty string means no password is required.
feedback_enabled boolean No Whether to enable feedback suggestions, default false.

Response

Response Example

{ "code": 0, "message": "OK", "data": { "share_id": "66f8c2a1e4b0a93c5d7f1a20", "link": "https://www.gptbots.ai/s/csAbC123", "expire_time": 1760112000000 } }
                      
                      {
  "code": 0,
  "message": "OK",
  "data": {
    "share_id": "66f8c2a1e4b0a93c5d7f1a20",
    "link": "https://www.gptbots.ai/s/csAbC123",
    "expire_time": 1760112000000
  }
}

                    
This code block in the floating window

Successful Response

Field Type Description
share_id string Share link ID.
link string The share link address, can be directly sent to end users for access.
expire_time long Share link expiration time, timestamp in milliseconds. If valid indefinitely, it is null.

Failed Response

Field Type Description
code int Error code.
message string Error details.

Error Codes

Code Message
40000 Parameter error (including field value out of range, field type error, or unrecognized fields)
40001 Requests are too frequent, please try again later (up to 30 calls per minute per Agent)
40008 Requests are too frequent, please try again later (exceeds API RPM limit of the plan)
40010 Operation not supported (share link integration not enabled on current site)
40101 Header Authorization is empty
40127 Developer authentication failed
40378 Agent has been deleted
20055 API functionality is forbidden, please ensure API switch is turned on
403171 Bot type is incorrect