Authenticate a widget user by your own user id
curl --request POST \
--url http://localhost:8080/widget/authenticate-user-by-external-id \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"external_id": "<string>",
"email": "[email protected]",
"mcp_access": {
"server_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"account_id": "<string>",
"credentials": [
{
"server_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"access_token": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
}
]
},
"name": "<string>",
"avatar_url": "<string>",
"phone": "<string>",
"customData": {},
"chat_context": "<string>",
"http_action_overrides": {
"query_params": {},
"path_params": {},
"body_params": {},
"headers": {}
},
"expires_in_seconds": 43260,
"primary_external_id": "<string>"
}
'import requests
url = "http://localhost:8080/widget/authenticate-user-by-external-id"
payload = {
"external_id": "<string>",
"email": "[email protected]",
"mcp_access": {
"server_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"account_id": "<string>",
"credentials": [
{
"server_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"access_token": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
}
]
},
"name": "<string>",
"avatar_url": "<string>",
"phone": "<string>",
"customData": {},
"chat_context": "<string>",
"http_action_overrides": {
"query_params": {},
"path_params": {},
"body_params": {},
"headers": {}
},
"expires_in_seconds": 43260,
"primary_external_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
external_id: '<string>',
email: '[email protected]',
mcp_access: {
server_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
account_id: '<string>',
credentials: [
{
server_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
access_token: '<string>',
expires_at: '2023-11-07T05:31:56Z'
}
]
},
name: '<string>',
avatar_url: '<string>',
phone: '<string>',
customData: {},
chat_context: '<string>',
http_action_overrides: {query_params: {}, path_params: {}, body_params: {}, headers: {}},
expires_in_seconds: 43260,
primary_external_id: '<string>'
})
};
fetch('http://localhost:8080/widget/authenticate-user-by-external-id', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/widget/authenticate-user-by-external-id",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'external_id' => '<string>',
'email' => '[email protected]',
'mcp_access' => [
'server_ids' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'account_id' => '<string>',
'credentials' => [
[
'server_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'access_token' => '<string>',
'expires_at' => '2023-11-07T05:31:56Z'
]
]
],
'name' => '<string>',
'avatar_url' => '<string>',
'phone' => '<string>',
'customData' => [
],
'chat_context' => '<string>',
'http_action_overrides' => [
'query_params' => [
],
'path_params' => [
],
'body_params' => [
],
'headers' => [
]
],
'expires_in_seconds' => 43260,
'primary_external_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8080/widget/authenticate-user-by-external-id"
payload := strings.NewReader("{\n \"external_id\": \"<string>\",\n \"email\": \"[email protected]\",\n \"mcp_access\": {\n \"server_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"account_id\": \"<string>\",\n \"credentials\": [\n {\n \"server_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"access_token\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"name\": \"<string>\",\n \"avatar_url\": \"<string>\",\n \"phone\": \"<string>\",\n \"customData\": {},\n \"chat_context\": \"<string>\",\n \"http_action_overrides\": {\n \"query_params\": {},\n \"path_params\": {},\n \"body_params\": {},\n \"headers\": {}\n },\n \"expires_in_seconds\": 43260,\n \"primary_external_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8080/widget/authenticate-user-by-external-id")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"external_id\": \"<string>\",\n \"email\": \"[email protected]\",\n \"mcp_access\": {\n \"server_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"account_id\": \"<string>\",\n \"credentials\": [\n {\n \"server_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"access_token\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"name\": \"<string>\",\n \"avatar_url\": \"<string>\",\n \"phone\": \"<string>\",\n \"customData\": {},\n \"chat_context\": \"<string>\",\n \"http_action_overrides\": {\n \"query_params\": {},\n \"path_params\": {},\n \"body_params\": {},\n \"headers\": {}\n },\n \"expires_in_seconds\": 43260,\n \"primary_external_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/widget/authenticate-user-by-external-id")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"external_id\": \"<string>\",\n \"email\": \"[email protected]\",\n \"mcp_access\": {\n \"server_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"account_id\": \"<string>\",\n \"credentials\": [\n {\n \"server_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"access_token\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"name\": \"<string>\",\n \"avatar_url\": \"<string>\",\n \"phone\": \"<string>\",\n \"customData\": {},\n \"chat_context\": \"<string>\",\n \"http_action_overrides\": {\n \"query_params\": {},\n \"path_params\": {},\n \"body_params\": {},\n \"headers\": {}\n },\n \"expires_in_seconds\": 43260,\n \"primary_external_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>",
"contact": {
"id": "<string>",
"external_id": "<string>",
"primary_external_id": "<string>"
}
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Contacts
Authenticate a widget user by your own user id
Get a verified widget contact token for a user identified by your own user ID. Use when several of your users can share an email or phone, or when users can change them.
POST
/
widget
/
authenticate-user-by-external-id
Authenticate a widget user by your own user id
curl --request POST \
--url http://localhost:8080/widget/authenticate-user-by-external-id \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"external_id": "<string>",
"email": "[email protected]",
"mcp_access": {
"server_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"account_id": "<string>",
"credentials": [
{
"server_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"access_token": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
}
]
},
"name": "<string>",
"avatar_url": "<string>",
"phone": "<string>",
"customData": {},
"chat_context": "<string>",
"http_action_overrides": {
"query_params": {},
"path_params": {},
"body_params": {},
"headers": {}
},
"expires_in_seconds": 43260,
"primary_external_id": "<string>"
}
'import requests
url = "http://localhost:8080/widget/authenticate-user-by-external-id"
payload = {
"external_id": "<string>",
"email": "[email protected]",
"mcp_access": {
"server_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"account_id": "<string>",
"credentials": [
{
"server_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"access_token": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
}
]
},
"name": "<string>",
"avatar_url": "<string>",
"phone": "<string>",
"customData": {},
"chat_context": "<string>",
"http_action_overrides": {
"query_params": {},
"path_params": {},
"body_params": {},
"headers": {}
},
"expires_in_seconds": 43260,
"primary_external_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
external_id: '<string>',
email: '[email protected]',
mcp_access: {
server_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
account_id: '<string>',
credentials: [
{
server_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
access_token: '<string>',
expires_at: '2023-11-07T05:31:56Z'
}
]
},
name: '<string>',
avatar_url: '<string>',
phone: '<string>',
customData: {},
chat_context: '<string>',
http_action_overrides: {query_params: {}, path_params: {}, body_params: {}, headers: {}},
expires_in_seconds: 43260,
primary_external_id: '<string>'
})
};
fetch('http://localhost:8080/widget/authenticate-user-by-external-id', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8080",
CURLOPT_URL => "http://localhost:8080/widget/authenticate-user-by-external-id",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'external_id' => '<string>',
'email' => '[email protected]',
'mcp_access' => [
'server_ids' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'account_id' => '<string>',
'credentials' => [
[
'server_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'access_token' => '<string>',
'expires_at' => '2023-11-07T05:31:56Z'
]
]
],
'name' => '<string>',
'avatar_url' => '<string>',
'phone' => '<string>',
'customData' => [
],
'chat_context' => '<string>',
'http_action_overrides' => [
'query_params' => [
],
'path_params' => [
],
'body_params' => [
],
'headers' => [
]
],
'expires_in_seconds' => 43260,
'primary_external_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:8080/widget/authenticate-user-by-external-id"
payload := strings.NewReader("{\n \"external_id\": \"<string>\",\n \"email\": \"[email protected]\",\n \"mcp_access\": {\n \"server_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"account_id\": \"<string>\",\n \"credentials\": [\n {\n \"server_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"access_token\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"name\": \"<string>\",\n \"avatar_url\": \"<string>\",\n \"phone\": \"<string>\",\n \"customData\": {},\n \"chat_context\": \"<string>\",\n \"http_action_overrides\": {\n \"query_params\": {},\n \"path_params\": {},\n \"body_params\": {},\n \"headers\": {}\n },\n \"expires_in_seconds\": 43260,\n \"primary_external_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:8080/widget/authenticate-user-by-external-id")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"external_id\": \"<string>\",\n \"email\": \"[email protected]\",\n \"mcp_access\": {\n \"server_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"account_id\": \"<string>\",\n \"credentials\": [\n {\n \"server_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"access_token\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"name\": \"<string>\",\n \"avatar_url\": \"<string>\",\n \"phone\": \"<string>\",\n \"customData\": {},\n \"chat_context\": \"<string>\",\n \"http_action_overrides\": {\n \"query_params\": {},\n \"path_params\": {},\n \"body_params\": {},\n \"headers\": {}\n },\n \"expires_in_seconds\": 43260,\n \"primary_external_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/widget/authenticate-user-by-external-id")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"external_id\": \"<string>\",\n \"email\": \"[email protected]\",\n \"mcp_access\": {\n \"server_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"account_id\": \"<string>\",\n \"credentials\": [\n {\n \"server_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"access_token\": \"<string>\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n }\n ]\n },\n \"name\": \"<string>\",\n \"avatar_url\": \"<string>\",\n \"phone\": \"<string>\",\n \"customData\": {},\n \"chat_context\": \"<string>\",\n \"http_action_overrides\": {\n \"query_params\": {},\n \"path_params\": {},\n \"body_params\": {},\n \"headers\": {}\n },\n \"expires_in_seconds\": 43260,\n \"primary_external_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>",
"contact": {
"id": "<string>",
"external_id": "<string>",
"primary_external_id": "<string>"
}
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Call this endpoint from your backend with an API key that has the
You can create B and C before the main account:
widget:write scope. It returns the same verified token as Authenticate contact. Pass that token to the widget through user.token.
- Matching: the contact is found by
external_idalone. Email and phone are optional details on the contact: they can change, and several contacts can share them. - First call: a new contact is created with the
external_idand the details you send, even when another contact already has the same email or phone. - Later calls: the contact with that
external_idis updated with the details you send, such as a new email or phone. - Other ways in: email, phone, and messaging channels, and Authenticate contact, keep identifying people by email or phone. They never match a contact that has an
external_id, so a message from the same address belongs to a separate contact. - Validation:
external_idis required, can’t be blank, and is at most 255 characters.
http_action_overrides for your AI actions and mcp_access for personal connections.
external_id identifies the contact. It is different from the widget’s user.externalId option, which only scopes session history in the browser.
Link accounts to a main contact
Send optionalprimary_external_id to record the main account’s external_id within your organization. Each contact keeps its own external_id and session history. The main contact does not need to exist yet, and several contacts can point to the same main account.
| Contact | external_id | primary_external_id |
|---|---|---|
| Main account | 1111 | null |
| Linked account B | 2222 | 1111 |
| Linked account C | 3333 | 1111 |
{
"external_id": "2222",
"primary_external_id": "1111",
"name": "Jane Doe"
}
- Omit the field to preserve the current relationship. A new contact starts with
null. - Send
nullto remove the relationship. - Send a string to set or replace the relationship, including with an ID that does not exist yet. Leading and trailing whitespace is removed; the remaining value must contain 1–255 characters.
- Direct references: a primary contact can have its own primary account. If B points to A and A points to C, both references are stored as supplied; B continues to point to A. This also works when A is created after B.
- Indirect cycles are allowed: A can point to B while B points to A. These references are stored without following the chain. If your integration follows these references, track visited contacts and stop when a contact repeats.
- No self-links: a contact cannot use its own
external_idas itsprimary_external_id. This returns400without saving the contact changes.
contact.external_id and the saved contact.primary_external_id. Contact detail, list, and search responses also expose both, as do contacts in session, investigation, CSAT, session search and blocklist responses, and the contact object in webhooks. Set it through this authentication endpoint or the contact create and update endpoints; email/phone authentication does not set it.
In the dashboard, the contact page, contact preview, and inbox sidebar can show sessions from the entire connected group within your organization. Links are followed in both directions, including chains, cycles, and shared references to a main account that has not been created yet. Each session appears once and remains owned by its original contact. On the contact page, the contact preview and the mobile inbox sidebar, agents can switch between All connected contacts and This contact; the desktop inbox sidebar always shows all connected contacts. Session permissions still apply. See Connected contact history.
Changing or clearing a reference updates the combined history on its next refresh, including past sessions. Another path between the contacts can keep them connected. This does not merge contacts, change authentication, expand customer widget history, or change general inbox contact filters or public session searches.Authorizations
Body
application/json
The primary account's external_id within your organization. The primary contact does not need to exist yet. Chains and indirect cycles are allowed; direct self-links are rejected. Omit to preserve the current value, send null to unlink, or send a string to set or replace it. The reference does not merge contacts or change customer access. Dashboard contact history can include all connected contacts, subject to the viewer’s session permissions.
Required string length:
1 - 255Was this page helpful?