Revoke a widget user
curl --request POST \
--url http://localhost:8080/widget/revoke-user \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contact_id": "<string>",
"external_id": "<string>",
"clear_http_action_overrides": {
"headers": true,
"query_params": true,
"path_params": true,
"body_params": true
}
}
'import requests
url = "http://localhost:8080/widget/revoke-user"
payload = {
"contact_id": "<string>",
"external_id": "<string>",
"clear_http_action_overrides": {
"headers": True,
"query_params": True,
"path_params": True,
"body_params": True
}
}
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({
contact_id: '<string>',
external_id: '<string>',
clear_http_action_overrides: {headers: true, query_params: true, path_params: true, body_params: true}
})
};
fetch('http://localhost:8080/widget/revoke-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/revoke-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([
'contact_id' => '<string>',
'external_id' => '<string>',
'clear_http_action_overrides' => [
'headers' => true,
'query_params' => true,
'path_params' => true,
'body_params' => true
]
]),
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/revoke-user"
payload := strings.NewReader("{\n \"contact_id\": \"<string>\",\n \"external_id\": \"<string>\",\n \"clear_http_action_overrides\": {\n \"headers\": true,\n \"query_params\": true,\n \"path_params\": true,\n \"body_params\": true\n }\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/revoke-user")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contact_id\": \"<string>\",\n \"external_id\": \"<string>\",\n \"clear_http_action_overrides\": {\n \"headers\": true,\n \"query_params\": true,\n \"path_params\": true,\n \"body_params\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/widget/revoke-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 \"contact_id\": \"<string>\",\n \"external_id\": \"<string>\",\n \"clear_http_action_overrides\": {\n \"headers\": true,\n \"query_params\": true,\n \"path_params\": true,\n \"body_params\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"contact": {
"id": "<string>",
"external_id": "<string>"
},
"revoked_at": "<string>",
"cleared": {
"headers": true,
"query_params": true,
"path_params": true,
"body_params": true
}
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Contacts
Revoke a widget user
Sign a widget visitor out from your backend: every widget token the contact holds stops working, and stored action request data can be removed. Use on logout.
POST
/
widget
/
revoke-user
Revoke a widget user
curl --request POST \
--url http://localhost:8080/widget/revoke-user \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contact_id": "<string>",
"external_id": "<string>",
"clear_http_action_overrides": {
"headers": true,
"query_params": true,
"path_params": true,
"body_params": true
}
}
'import requests
url = "http://localhost:8080/widget/revoke-user"
payload = {
"contact_id": "<string>",
"external_id": "<string>",
"clear_http_action_overrides": {
"headers": True,
"query_params": True,
"path_params": True,
"body_params": True
}
}
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({
contact_id: '<string>',
external_id: '<string>',
clear_http_action_overrides: {headers: true, query_params: true, path_params: true, body_params: true}
})
};
fetch('http://localhost:8080/widget/revoke-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/revoke-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([
'contact_id' => '<string>',
'external_id' => '<string>',
'clear_http_action_overrides' => [
'headers' => true,
'query_params' => true,
'path_params' => true,
'body_params' => true
]
]),
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/revoke-user"
payload := strings.NewReader("{\n \"contact_id\": \"<string>\",\n \"external_id\": \"<string>\",\n \"clear_http_action_overrides\": {\n \"headers\": true,\n \"query_params\": true,\n \"path_params\": true,\n \"body_params\": true\n }\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/revoke-user")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contact_id\": \"<string>\",\n \"external_id\": \"<string>\",\n \"clear_http_action_overrides\": {\n \"headers\": true,\n \"query_params\": true,\n \"path_params\": true,\n \"body_params\": true\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8080/widget/revoke-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 \"contact_id\": \"<string>\",\n \"external_id\": \"<string>\",\n \"clear_http_action_overrides\": {\n \"headers\": true,\n \"query_params\": true,\n \"path_params\": true,\n \"body_params\": true\n }\n}"
response = http.request(request)
puts response.read_body{
"contact": {
"id": "<string>",
"external_id": "<string>"
},
"revoked_at": "<string>",
"cleared": {
"headers": true,
"query_params": true,
"path_params": true,
"body_params": true
}
}{
"statusCode": 123,
"message": "<string>",
"error": "<string>"
}Call this endpoint from your backend with an API key that has the
widget:write scope, for example when a visitor logs out of your app.
- Who: name the contact with exactly one of
contact_id(as returned by authenticate) orexternal_id(as sent to Authenticate contact by external ID). Sending neither or both is rejected; a contact that doesn’t exist in your organization returns404. - Effect: every widget token the contact holds stops working on its next request, whether or not it has an expiry. The widget’s requests are then rejected with the code
token_revoked. - Signing in again: a token you issue after the revoke works normally.
- Stored request data:
clear_http_action_overridesremoves the parts you name from what authenticate stored for the contact’s AI actions:headers,query_params,path_paramsandbody_params. Each defaults tofalse, so nothing is removed unless you ask. The response echoes what was cleared.
user.refreshToken for a replacement once; if your backend no longer signs them in, the chat shows that the session has ended. See Sign a visitor out.Authorizations
Body
application/json
Was this page helpful?