Skip to main content
POST
/
api
/
v3
/
user-event
/
room
Store watching time analytic for room
curl --request POST \
  --url https://apix.us.amity.co/api/v3/user-event/room \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "signature": "<string>",
  "nonceStr": "<string>",
  "timestamp": "2021-03-10T03:07:16.127Z",
  "rooms": [
    {
      "roomId": "<string>",
      "startTime": "2021-03-10T03:07:16.127Z",
      "endTime": "2021-03-10T03:07:16.127Z",
      "watchSeconds": 120,
      "sessionId": "<string>"
    }
  ]
}
'
import requests

url = "https://apix.us.amity.co/api/v3/user-event/room"

payload = {
"signature": "<string>",
"nonceStr": "<string>",
"timestamp": "2021-03-10T03:07:16.127Z",
"rooms": [
{
"roomId": "<string>",
"startTime": "2021-03-10T03:07:16.127Z",
"endTime": "2021-03-10T03:07:16.127Z",
"watchSeconds": 120,
"sessionId": "<string>"
}
]
}
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({
signature: '<string>',
nonceStr: '<string>',
timestamp: '2021-03-10T03:07:16.127Z',
rooms: [
{
roomId: '<string>',
startTime: '2021-03-10T03:07:16.127Z',
endTime: '2021-03-10T03:07:16.127Z',
watchSeconds: 120,
sessionId: '<string>'
}
]
})
};

fetch('https://apix.us.amity.co/api/v3/user-event/room', 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/user-event/room",
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([
'signature' => '<string>',
'nonceStr' => '<string>',
'timestamp' => '2021-03-10T03:07:16.127Z',
'rooms' => [
[
'roomId' => '<string>',
'startTime' => '2021-03-10T03:07:16.127Z',
'endTime' => '2021-03-10T03:07:16.127Z',
'watchSeconds' => 120,
'sessionId' => '<string>'
]
]
]),
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://apix.us.amity.co/api/v3/user-event/room"

payload := strings.NewReader("{\n \"signature\": \"<string>\",\n \"nonceStr\": \"<string>\",\n \"timestamp\": \"2021-03-10T03:07:16.127Z\",\n \"rooms\": [\n {\n \"roomId\": \"<string>\",\n \"startTime\": \"2021-03-10T03:07:16.127Z\",\n \"endTime\": \"2021-03-10T03:07:16.127Z\",\n \"watchSeconds\": 120,\n \"sessionId\": \"<string>\"\n }\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("https://apix.us.amity.co/api/v3/user-event/room")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"signature\": \"<string>\",\n \"nonceStr\": \"<string>\",\n \"timestamp\": \"2021-03-10T03:07:16.127Z\",\n \"rooms\": [\n {\n \"roomId\": \"<string>\",\n \"startTime\": \"2021-03-10T03:07:16.127Z\",\n \"endTime\": \"2021-03-10T03:07:16.127Z\",\n \"watchSeconds\": 120,\n \"sessionId\": \"<string>\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://apix.us.amity.co/api/v3/user-event/room")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"signature\": \"<string>\",\n \"nonceStr\": \"<string>\",\n \"timestamp\": \"2021-03-10T03:07:16.127Z\",\n \"rooms\": [\n {\n \"roomId\": \"<string>\",\n \"startTime\": \"2021-03-10T03:07:16.127Z\",\n \"endTime\": \"2021-03-10T03:07:16.127Z\",\n \"watchSeconds\": 120,\n \"sessionId\": \"<string>\"\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "ok": true
}
{
"code": "500000,",
"message": "Information mismatch",
"status": "error"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

A group of user activity on startTime, endTime and watchSeconds.

signature
string
required

RSA-SHA256 signature for request validation. Generated by:

  1. Sort data object keys alphabetically for each room
  2. Create key=value pairs (use ISO 8601 format for timestamps)
  3. Join pairs with '&' within each room
  4. Join multiple rooms with ';'
  5. Create signing string: nonceStr={nonceStr}&timestamp={timestamp}&data={dataStr}==
  6. Sign with SHA256 using your RSA private key
  7. Base64 encode the signature

Example data string: endTime=2021-03-10T03:08:16.127Z&roomId=room123&sessionId=session1&startTime=2021-03-10T03:07:16.127Z&watchSeconds=60

nonceStr
string
required

unique string for each request, max length 50

timestamp
string
required

timestamp string in UTC format

Example:

"2021-03-10T03:07:16.127Z"

rooms
object[]
required

Response

event is processed successfully

ok
boolean
Example:

true