Register a session
curl --request POST \
--url https://apix.us.amity.co/api/v3/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>",
"authToken": "<string>"
}
'import requests
url = "https://apix.us.amity.co/api/v3/sessions"
payload = {
"userId": "<string>",
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"displayName": "<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>',
authToken: '<string>'
})
};
fetch('https://apix.us.amity.co/api/v3/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/v3/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>',
'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/v3/sessions"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"displayName\": \"<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/v3/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 \"authToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v3/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 \"authToken\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"refreshToken": "<string>",
"issuedAt": "<string>",
"expiresAt": "<string>",
"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": [],
"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>",
"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": "<string>"
}{
"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": "Unexpected error"
}Session
Register a session
deprecated
Register a session in order to receive access token to perform sdk operations.
POST
/
api
/
v3
/
sessions
Register a session
curl --request POST \
--url https://apix.us.amity.co/api/v3/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>",
"authToken": "<string>"
}
'import requests
url = "https://apix.us.amity.co/api/v3/sessions"
payload = {
"userId": "<string>",
"deviceId": "<string>",
"deviceInfo": {
"model": "<string>",
"sdkVersion": "<string>"
},
"displayName": "<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>',
authToken: '<string>'
})
};
fetch('https://apix.us.amity.co/api/v3/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/v3/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>',
'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/v3/sessions"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"deviceId\": \"<string>\",\n \"deviceInfo\": {\n \"model\": \"<string>\",\n \"sdkVersion\": \"<string>\"\n },\n \"displayName\": \"<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/v3/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 \"authToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apix.us.amity.co/api/v3/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 \"authToken\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"accessToken": "<string>",
"refreshToken": "<string>",
"issuedAt": "<string>",
"expiresAt": "<string>",
"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": [],
"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>",
"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": "<string>"
}{
"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": "Unexpected error"
}Headers
Body
application/json
Information about user and devices that he/she use to connect to. If displayName is provide, that user display is updated as well.
If userId doesn't exists, new user will be created.
authToken need to pass when network option is set to secure
⌘I