Authenticate a widget user by phone number
curl --request POST \
--url http://localhost:8080/widget/authenticate-user-by-phone \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "<string>",
"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>",
"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-by-phone"
payload = {
"phone": "<string>",
"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>",
"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({
phone: '<string>',
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>',
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-by-phone', 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-phone",
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([
'phone' => '<string>',
'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>',
'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-by-phone"
payload := strings.NewReader("{\n \"phone\": \"<string>\",\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 \"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-by-phone")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"<string>\",\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 \"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-by-phone")
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 \"phone\": \"<string>\",\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 \"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 by phone number
Get a verified widget contact token from a phone number and save the contact profile in the same call. Use when your customers sign in with their phone and have no email address on file.
POST
/
widget
/
authenticate-user-by-phone
Authenticate a widget user by phone number
curl --request POST \
--url http://localhost:8080/widget/authenticate-user-by-phone \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "<string>",
"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>",
"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-by-phone"
payload = {
"phone": "<string>",
"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>",
"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({
phone: '<string>',
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>',
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-by-phone', 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-phone",
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([
'phone' => '<string>',
'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>',
'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-by-phone"
payload := strings.NewReader("{\n \"phone\": \"<string>\",\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 \"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-by-phone")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"<string>\",\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 \"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-by-phone")
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 \"phone\": \"<string>\",\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 \"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 with an API key that has the
widget:write scope. It returns the same verified token as Authenticate contact. Pass that token to the widget through user.token.
- Matching: spaces and a leading
+in the number you send don’t matter, so+14155550123,14155550123, and+1 415 555 0123all identify the same contact. - Several matches: when more than one contact has the number, the one created first is used. Contacts created with Authenticate contact by external ID are never matched by phone.
- No match: a new contact is created with the phone number and the fields you send.
- Profile fields:
name,language,customData,chat_context, andhttp_action_overridesare optional and saved on the contact, as in Authenticate contact. A field you send replaces the contact’s value, andcustomDatakeys are merged into the existing ones. - Personal access:
mcp_accessapplies only to the returned token and is not saved, so send it on every call that needs it. The exception ismcp_access.credentials: those tokens are saved for the contact, as in Authenticate contact. - Validation: the number must include its country code. A national-only number such as
0770096918is rejected with400.
email. For customers with an email, use Authenticate contact.Authorizations
Body
application/json
Was this page helpful?