Register a session
curl --request POST \
--url https://apix.us.amity.co/api/v5/sessions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"userId": "<string>",
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"displayName": "<string>",
"profileHandle": "<string>",
"authToken": "<string>"
}
'import requests
url = "https://apix.us.amity.co/api/v5/sessions"
payload = {
"userId": "<string>",
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"displayName": "<string>",
"profileHandle": "<string>",
"authToken": "<string>"
}
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({
userId: '<string>',
deviceId: '<string>',
deviceInfo: {model: '<string>', sdkVersion: '<string>'},
displayName: '<string>',
profileHandle: '<string>',
authToken: '<string>'
})
};
fetch('https://apix.us.amity.co/api/v5/sessions', 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",
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([
'userId' => '<string>',
'deviceId' => '<string>',
'deviceInfo' => [
'model' => '<string>',
'sdkVersion' => '<string>'
],
'displayName' => '<string>',
'profileHandle' => '<string>',
'authToken' => '<string>'
]),
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"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"displayName\": \"<string>\",\n \"profileHandle\": \"<string>\",\n \"authToken\": \"<string>\"\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")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"<string>\",\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"displayName\": \"<string>\",\n \"profileHandle\": \"<string>\",\n \"authToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v5/sessions")
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 \"userId\": \"<string>\",\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"displayName\": \"<string>\",\n \"profileHandle\": \"<string>\",\n \"authToken\": \"<string>\"\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": [
{
"roleId": "<string>",
"updatedAt": "2023-11-07T05:31:56Z",
"permissions": [
"<string>"
],
"isDeleted": false,
"displayName": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
],
"files": [
{
"fileId": "<string>",
"fileUrl": "<string>",
"type": "image",
"accessType": "public",
"altText": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"attributes": {
"name": "<string>",
"extension": "<string>",
"size": 123,
"mimeType": "<string>",
"metadata": {
"exif": {},
"gps": {},
"height": 123,
"width": 123,
"isFull": true
}
}
}
],
"lastCachePurge": "2023-11-07T05:31:56Z",
"userType": "signed-in"
}{
"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"
}Session
Register a session
Register a session in order to receive access token to perform SDK operations. This is the latest version with enhanced session management capabilities.
POST
/
api
/
v5
/
sessions
Register a session
curl --request POST \
--url https://apix.us.amity.co/api/v5/sessions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"userId": "<string>",
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"displayName": "<string>",
"profileHandle": "<string>",
"authToken": "<string>"
}
'import requests
url = "https://apix.us.amity.co/api/v5/sessions"
payload = {
"userId": "<string>",
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"displayName": "<string>",
"profileHandle": "<string>",
"authToken": "<string>"
}
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({
userId: '<string>',
deviceId: '<string>',
deviceInfo: {model: '<string>', sdkVersion: '<string>'},
displayName: '<string>',
profileHandle: '<string>',
authToken: '<string>'
})
};
fetch('https://apix.us.amity.co/api/v5/sessions', 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",
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([
'userId' => '<string>',
'deviceId' => '<string>',
'deviceInfo' => [
'model' => '<string>',
'sdkVersion' => '<string>'
],
'displayName' => '<string>',
'profileHandle' => '<string>',
'authToken' => '<string>'
]),
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"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"displayName\": \"<string>\",\n \"profileHandle\": \"<string>\",\n \"authToken\": \"<string>\"\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")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"<string>\",\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"displayName\": \"<string>\",\n \"profileHandle\": \"<string>\",\n \"authToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v5/sessions")
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 \"userId\": \"<string>\",\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"displayName\": \"<string>\",\n \"profileHandle\": \"<string>\",\n \"authToken\": \"<string>\"\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": [
{
"roleId": "<string>",
"updatedAt": "2023-11-07T05:31:56Z",
"permissions": [
"<string>"
],
"isDeleted": false,
"displayName": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
],
"files": [
{
"fileId": "<string>",
"fileUrl": "<string>",
"type": "image",
"accessType": "public",
"altText": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"attributes": {
"name": "<string>",
"extension": "<string>",
"size": 123,
"mimeType": "<string>",
"metadata": {
"exif": {},
"gps": {},
"height": 123,
"width": 123,
"isFull": true
}
}
}
],
"lastCachePurge": "2023-11-07T05:31:56Z",
"userType": "signed-in"
}{
"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
application/json
Information about user and devices that they use to connect. If displayName is provided, the user's display name is updated as well.
If userId doesn't exist, a new user will be created.
authToken needs to be passed when network option is set to secure.
accessToken expires in 30 days by default.
Response
Session Information with access token and user data