curl --request POST \
--url https://apix.us.amity.co/api/v5/sessions/visitor \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"authSignature": "<string>",
"authSignatureExpiresAt": "2024-12-31T23:59:59Z"
}
'import requests
url = "https://apix.us.amity.co/api/v5/sessions/visitor"
payload = {
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"authSignature": "<string>",
"authSignatureExpiresAt": "2024-12-31T23:59:59Z"
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
deviceId: '<string>',
deviceInfo: {model: '<string>', sdkVersion: '<string>'},
authSignature: '<string>',
authSignatureExpiresAt: '2024-12-31T23:59:59Z'
})
};
fetch('https://apix.us.amity.co/api/v5/sessions/visitor', 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://apix.us.amity.co/api/v5/sessions/visitor",
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([
'deviceId' => '<string>',
'deviceInfo' => [
'model' => '<string>',
'sdkVersion' => '<string>'
],
'authSignature' => '<string>',
'authSignatureExpiresAt' => '2024-12-31T23:59:59Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$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://apix.us.amity.co/api/v5/sessions/visitor"
payload := strings.NewReader("{\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"authSignature\": \"<string>\",\n \"authSignatureExpiresAt\": \"2024-12-31T23:59:59Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
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("https://apix.us.amity.co/api/v5/sessions/visitor")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"authSignature\": \"<string>\",\n \"authSignatureExpiresAt\": \"2024-12-31T23:59:59Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v5/sessions/visitor")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"authSignature\": \"<string>\",\n \"authSignatureExpiresAt\": \"2024-12-31T23:59:59Z\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"issuedAt": "2023-11-07T05:31:56Z",
"expiresAt": "2023-11-07T05:31:56Z",
"users": [
{
"userId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"_id": "<string>",
"path": "<string>",
"userInternalId": "<string>",
"userPublicId": "<string>",
"roles": [
"<string>"
],
"permissions": [
"MUTE_CHANNEL"
],
"displayName": "<string>",
"profileHandle": "<string>",
"description": "<string>",
"avatarFileId": "<string>",
"avatarCustomUrl": "<string>",
"flagCount": 123,
"hashFlag": {
"bits": 123,
"hashes": 123,
"hash": [
"<string>"
]
},
"metadata": {},
"isGlobalBan": true,
"isBrand": true,
"isDeleted": true
}
],
"roles": [],
"files": [],
"lastCachePurge": "2023-11-07T05:31:56Z",
"userType": "visitor"
}{
"status": "error",
"code": 400100,
"message": "User is banned from the system."
}{
"status": "error",
"code": 400312,
"message": "User is global banned."
}{
"status": "error",
"code": 500000,
"message": "Parameters error.",
"data": {
"detail": [
"The 'data.text' field length must be less than or equal to 20000 characters long."
]
}
}{
"status": "error",
"code": 500000,
"message": "Unexpected error"
}Register a visitor session
Register a visitor session for read-only access. Visitor users can only consume public content and cannot perform write operations.
curl --request POST \
--url https://apix.us.amity.co/api/v5/sessions/visitor \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"authSignature": "<string>",
"authSignatureExpiresAt": "2024-12-31T23:59:59Z"
}
'import requests
url = "https://apix.us.amity.co/api/v5/sessions/visitor"
payload = {
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"authSignature": "<string>",
"authSignatureExpiresAt": "2024-12-31T23:59:59Z"
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
deviceId: '<string>',
deviceInfo: {model: '<string>', sdkVersion: '<string>'},
authSignature: '<string>',
authSignatureExpiresAt: '2024-12-31T23:59:59Z'
})
};
fetch('https://apix.us.amity.co/api/v5/sessions/visitor', 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://apix.us.amity.co/api/v5/sessions/visitor",
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([
'deviceId' => '<string>',
'deviceInfo' => [
'model' => '<string>',
'sdkVersion' => '<string>'
],
'authSignature' => '<string>',
'authSignatureExpiresAt' => '2024-12-31T23:59:59Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <x-api-key>"
],
]);
$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://apix.us.amity.co/api/v5/sessions/visitor"
payload := strings.NewReader("{\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"authSignature\": \"<string>\",\n \"authSignatureExpiresAt\": \"2024-12-31T23:59:59Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
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("https://apix.us.amity.co/api/v5/sessions/visitor")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"authSignature\": \"<string>\",\n \"authSignatureExpiresAt\": \"2024-12-31T23:59:59Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v5/sessions/visitor")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"authSignature\": \"<string>\",\n \"authSignatureExpiresAt\": \"2024-12-31T23:59:59Z\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"issuedAt": "2023-11-07T05:31:56Z",
"expiresAt": "2023-11-07T05:31:56Z",
"users": [
{
"userId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"_id": "<string>",
"path": "<string>",
"userInternalId": "<string>",
"userPublicId": "<string>",
"roles": [
"<string>"
],
"permissions": [
"MUTE_CHANNEL"
],
"displayName": "<string>",
"profileHandle": "<string>",
"description": "<string>",
"avatarFileId": "<string>",
"avatarCustomUrl": "<string>",
"flagCount": 123,
"hashFlag": {
"bits": 123,
"hashes": 123,
"hash": [
"<string>"
]
},
"metadata": {},
"isGlobalBan": true,
"isBrand": true,
"isDeleted": true
}
],
"roles": [],
"files": [],
"lastCachePurge": "2023-11-07T05:31:56Z",
"userType": "visitor"
}{
"status": "error",
"code": 400100,
"message": "User is banned from the system."
}{
"status": "error",
"code": 400312,
"message": "User is global banned."
}{
"status": "error",
"code": 500000,
"message": "Parameters error.",
"data": {
"detail": [
"The 'data.text' field length must be less than or equal to 20000 characters long."
]
}
}{
"status": "error",
"code": 500000,
"message": "Unexpected error"
}Body
Information about visitor user and devices that they use to connect. Visitor users have read-only access and cannot perform write operations.
If deviceId haven't been used before, a new visitor user will be created.
accessToken expires in 30 days by default.
Authentication signature for visitor user (required for secure visitor sessions only)
The signature must be created using HMAC-SHA256 and returned as hexadecimal:
HMAC-SHA256(payload, applicationSecret)
Steps to generate:
-
Create HMAC-SHA256 hash using payload as message and applicationSecret as key.
Payload format: deviceId=deviceId&authSignatureExpiresAt=authSignatureExpiresAt
Device id and authSignatureExpiresAt must match the values sent in the request. -
Convert the resulting hash to hexadecimal string (64 characters)
The applicationSecret can be found in the console at Feature settings > User section when enabling secure visitor sessions.
64Response
Session Information with access token and user data