Authenticate a widget user
curl --request POST \
--url http://localhost:8080/widget/authenticate-user \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"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
}
'import requests
url = "http://localhost:8080/widget/authenticate-user"
payload = {
"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
}
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({
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
})
};
fetch('http://localhost:8080/widget/authenticate-user', 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",
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([
'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
]),
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"
payload := strings.NewReader("{\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}")
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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\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}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/widget/authenticate-user")
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 \"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}"
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
Authenticate a widget user — authenticate the contacts. Use when authenticating widget visitors against your own identity provider.
POST
/
widget
/
authenticate-user
Authenticate a widget user
curl --request POST \
--url http://localhost:8080/widget/authenticate-user \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"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
}
'import requests
url = "http://localhost:8080/widget/authenticate-user"
payload = {
"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
}
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({
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
})
};
fetch('http://localhost:8080/widget/authenticate-user', 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",
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([
'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
]),
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"
payload := strings.NewReader("{\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}")
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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\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}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/widget/authenticate-user")
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 \"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}"
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 after verifying the customer’s identity. Saved
http_action_overrides are available to authenticated widget sessions; supplying the same email through non-verified visitor data does not grant access to them.
Send expires_in_seconds (120 to 86,400) for a token that stops working after that many seconds; omit it for a token that never expires. The lifetime applies only to the returned token, not to http_action_overrides. Renew it from the widget with user.refreshToken, and sign a visitor out with Revoke contact. See Short-lived tokens and renewal.
mcp_access.credentials saves tokens your backend already holds for the user, so personal connections work without Connect. They are stored for the contact and never included in the returned token. See Skip Connect.Authorizations
Body
application/json
Was this page helpful?