Query User CDP
Query User CDP
Allows developers to query Agent/Workflow user CDP (Customer Data Platform) information, including user ID, anonymous ID, and conversation type, using either a user ID or an anonymous ID.
User CDP information is stored under each Agent/Workflow, meaning data for the same user is isolated between different Agents/Workflows.
Request Method
GET
Endpoint
https://api.${endpoint}/v1/user/get-user-cdp
Authentication
Refer to the API Overview for details on authentication methods.
Request
Request Examples
- Query by
user_id:
curl -X GET 'https://api.${endpoint}/v1/user/get-user-cdp?user_id=BC123' \
-H 'Authorization: Bearer ${token}'
curl -X GET 'https://api.${endpoint}/v1/user/get-user-cdp?user_id=BC123' \
-H 'Authorization: Bearer ${token}'
This code block in the floating window
- Query by
anonymous_id:
curl -X GET 'https://api.${endpoint}/v1/user/get-user-cdp?anonymous_id=22ses32dsafdabd1w2sad' \
-H 'Authorization: Bearer ${token}'
curl -X GET 'https://api.${endpoint}/v1/user/get-user-cdp?anonymous_id=22ses32dsafdabd1w2sad' \
-H 'Authorization: Bearer ${token}'
This code block in the floating window
- Query by both
user_idandanonymous_id:
curl -X GET 'https://api.${endpoint}/v1/user/get-user-cdp?user_id=BC123&anonymous_id=22ses32dsafdabd1w2sad' \
-H 'Authorization: Bearer ${token}'
curl -X GET 'https://api.${endpoint}/v1/user/get-user-cdp?user_id=BC123&anonymous_id=22ses32dsafdabd1w2sad' \
-H 'Authorization: Bearer ${token}'
This code block in the floating window
The
anonymous_idfor the current user can be obtained from "Agent/Workflow Configuration - Global Variables".
Request Headers
| Field | Type | Description |
|---|---|---|
| Authorization | Bearer ${token} | Use Authorization: Bearer ${token} for authentication. Obtain your key as ${token} from the API Key page. |
Query Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| user_id | string | Developer-defined user ID. | false |
| anonymous_id | string | An anonymous ID generated by the GPTBots platform, usually based on the unique identifier from a third-party platform. Can be obtained from "Agent/Workflow Configuration - Global Variables". | false |
- At least one of
user_idoranonymous_idmust be provided; otherwise, a parameter error will be returned.- You can query all bound information for a user by providing only
user_id.- You can query user information associated with an anonymous ID by providing only
anonymous_id.- You can perform a precise query by providing both
user_idandanonymous_id.
Response
Response Body
{
"code": 0,
"message": "OK",
"data": {
"user1": {
"user_id": "user1",
"anonymous_ids": [
{
"anonymous_id": "aId3",
"conversation_type": "WEB",
"source_id": null
}
]
},
"67b58121035e5b152b0419ee": {
"user_id": "67b58121035e5b152b0419ee",
"anonymous_ids": [
{
"anonymous_id": "aId3",
"conversation_type": "C",
"source_id": null
}
]
}
}
}
{
"code": 0,
"message": "OK",
"data": {
"user1": {
"user_id": "user1",
"anonymous_ids": [
{
"anonymous_id": "aId3",
"conversation_type": "WEB",
"source_id": null
}
]
},
"67b58121035e5b152b0419ee": {
"user_id": "67b58121035e5b152b0419ee",
"anonymous_ids": [
{
"anonymous_id": "aId3",
"conversation_type": "C",
"source_id": null
}
]
}
}
}
This code block in the floating window
Successful Response
The response is an object where the key is the user_id, and the value is the CDP information for that user:
| Field | Type | Description |
|---|---|---|
| {user_id} | object | An object keyed by the user ID, containing the user's complete CDP information. |
| {user_id}.user_id | string | User ID. |
| {user_id}.anonymous_ids | array | All anonymous IDs currently bound to this user ID and their conversation types. |
| {user_id}.anonymous_ids[].anonymous_id | string | Anonymous ID. |
| {user_id}.anonymous_ids[].conversation_type | string | Conversation type. A mapping table can be found in the conversation types section of the User Overview. |
| {user_id}.anonymous_ids[].source_id | string | Source ID from the conversation platform. For example, if integrating with TELEGRAM and adding 2 TG Bots, each Bot will have its own Source ID. |
Error Response
| Field | Type | Description |
|---|---|---|
| code | int | Error code |
| message | string | Error message |
Status Codes
| Status Code | Description |
|---|---|
| 200 | Success |
| 400 | Parameter error (no query parameters provided) |
| 401 | Unauthorized |
| 403 | Permission denied |
| 500 | Server error |
