End Users
Update end user
Update an existing end user. You can change email and metadata. The external_id cannot be changed after creation as it’s used for identity mapping.
PATCH
/
end-users
/
{id}
Update end user
curl --request PATCH \
--url https://app.usechar.ai/api/end-users/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"organization_id": "<string>",
"email": "<string>",
"metadata": "<string>",
"last_activity_at": "2023-11-07T05:31:56Z"
}
}
'import requests
url = "https://app.usechar.ai/api/end-users/{id}"
payload = { "data": {
"organization_id": "<string>",
"email": "<string>",
"metadata": "<string>",
"last_activity_at": "2023-11-07T05:31:56Z"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
organization_id: '<string>',
email: '<string>',
metadata: '<string>',
last_activity_at: '2023-11-07T05:31:56Z'
}
})
};
fetch('https://app.usechar.ai/api/end-users/{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_URL => "https://app.usechar.ai/api/end-users/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'organization_id' => '<string>',
'email' => '<string>',
'metadata' => '<string>',
'last_activity_at' => '2023-11-07T05:31:56Z'
]
]),
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 := "https://app.usechar.ai/api/end-users/{id}"
payload := strings.NewReader("{\n \"data\": {\n \"organization_id\": \"<string>\",\n \"email\": \"<string>\",\n \"metadata\": \"<string>\",\n \"last_activity_at\": \"2023-11-07T05:31:56Z\"\n }\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://app.usechar.ai/api/end-users/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"organization_id\": \"<string>\",\n \"email\": \"<string>\",\n \"metadata\": \"<string>\",\n \"last_activity_at\": \"2023-11-07T05:31:56Z\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.usechar.ai/api/end-users/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"organization_id\": \"<string>\",\n \"email\": \"<string>\",\n \"metadata\": \"<string>\",\n \"last_activity_at\": \"2023-11-07T05:31:56Z\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"organization_id": "<string>",
"external_id": "<string>",
"email": "<string>",
"metadata": "<string>",
"last_activity_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"defined": true,
"code": "BAD_REQUEST",
"status": 400,
"message": "Invalid request data",
"data": {
"code": "VALIDATION_ERROR",
"field": "email",
"details": "Invalid email format"
}
}{
"defined": true,
"code": "UNAUTHORIZED",
"status": 401,
"message": "Authentication required",
"data": {
"code": "AUTH_REQUIRED"
}
}{
"defined": true,
"code": "FORBIDDEN",
"status": 403,
"message": "Access denied",
"data": {
"code": "ACCESS_DENIED",
"reason": "Insufficient permissions"
}
}{
"defined": true,
"code": "NOT_FOUND",
"status": 404,
"message": "Resource not found",
"data": {
"code": "RESOURCE_NOT_FOUND",
"resource": "site",
"resourceId": "site_123"
}
}{
"defined": true,
"code": "CONFLICT",
"status": 409,
"message": "Resource already exists",
"data": {
"code": "DUPLICATE_RESOURCE",
"resource": "api_key"
}
}{
"defined": true,
"code": "INTERNAL_SERVER_ERROR",
"status": 500,
"message": "An internal error occurred",
"data": {
"code": "INTERNAL_ERROR"
}
}Authorizations
Response
OK
End user resource representing a user who interacts with embedded AI widgets. Identified by external_id from the embedding site.
⌘I
Update end user
curl --request PATCH \
--url https://app.usechar.ai/api/end-users/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"organization_id": "<string>",
"email": "<string>",
"metadata": "<string>",
"last_activity_at": "2023-11-07T05:31:56Z"
}
}
'import requests
url = "https://app.usechar.ai/api/end-users/{id}"
payload = { "data": {
"organization_id": "<string>",
"email": "<string>",
"metadata": "<string>",
"last_activity_at": "2023-11-07T05:31:56Z"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: {
organization_id: '<string>',
email: '<string>',
metadata: '<string>',
last_activity_at: '2023-11-07T05:31:56Z'
}
})
};
fetch('https://app.usechar.ai/api/end-users/{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_URL => "https://app.usechar.ai/api/end-users/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'organization_id' => '<string>',
'email' => '<string>',
'metadata' => '<string>',
'last_activity_at' => '2023-11-07T05:31:56Z'
]
]),
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 := "https://app.usechar.ai/api/end-users/{id}"
payload := strings.NewReader("{\n \"data\": {\n \"organization_id\": \"<string>\",\n \"email\": \"<string>\",\n \"metadata\": \"<string>\",\n \"last_activity_at\": \"2023-11-07T05:31:56Z\"\n }\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://app.usechar.ai/api/end-users/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"organization_id\": \"<string>\",\n \"email\": \"<string>\",\n \"metadata\": \"<string>\",\n \"last_activity_at\": \"2023-11-07T05:31:56Z\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.usechar.ai/api/end-users/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"organization_id\": \"<string>\",\n \"email\": \"<string>\",\n \"metadata\": \"<string>\",\n \"last_activity_at\": \"2023-11-07T05:31:56Z\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"organization_id": "<string>",
"external_id": "<string>",
"email": "<string>",
"metadata": "<string>",
"last_activity_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"defined": true,
"code": "BAD_REQUEST",
"status": 400,
"message": "Invalid request data",
"data": {
"code": "VALIDATION_ERROR",
"field": "email",
"details": "Invalid email format"
}
}{
"defined": true,
"code": "UNAUTHORIZED",
"status": 401,
"message": "Authentication required",
"data": {
"code": "AUTH_REQUIRED"
}
}{
"defined": true,
"code": "FORBIDDEN",
"status": 403,
"message": "Access denied",
"data": {
"code": "ACCESS_DENIED",
"reason": "Insufficient permissions"
}
}{
"defined": true,
"code": "NOT_FOUND",
"status": 404,
"message": "Resource not found",
"data": {
"code": "RESOURCE_NOT_FOUND",
"resource": "site",
"resourceId": "site_123"
}
}{
"defined": true,
"code": "CONFLICT",
"status": 409,
"message": "Resource already exists",
"data": {
"code": "DUPLICATE_RESOURCE",
"resource": "api_key"
}
}{
"defined": true,
"code": "INTERNAL_SERVER_ERROR",
"status": 500,
"message": "An internal error occurred",
"data": {
"code": "INTERNAL_ERROR"
}
}
