Record Playtime Session
curl --request POST \
--url https://sdk-api.playcamp.io/v1/server/playtime/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sessionId": "<string>",
"userId": "<string>",
"durationSeconds": 2,
"startedAt": "2023-11-07T05:31:56Z",
"endedAt": "2023-11-07T05:31:56Z",
"campaignId": "<string>",
"creatorKey": "<string>",
"metadata": {},
"callbackId": "<string>",
"isTest": false
}
'import requests
url = "https://sdk-api.playcamp.io/v1/server/playtime/sessions"
payload = {
"sessionId": "<string>",
"userId": "<string>",
"durationSeconds": 2,
"startedAt": "2023-11-07T05:31:56Z",
"endedAt": "2023-11-07T05:31:56Z",
"campaignId": "<string>",
"creatorKey": "<string>",
"metadata": {},
"callbackId": "<string>",
"isTest": False
}
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({
sessionId: '<string>',
userId: '<string>',
durationSeconds: 2,
startedAt: '2023-11-07T05:31:56Z',
endedAt: '2023-11-07T05:31:56Z',
campaignId: '<string>',
creatorKey: '<string>',
metadata: {},
callbackId: '<string>',
isTest: false
})
};
fetch('https://sdk-api.playcamp.io/v1/server/playtime/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://sdk-api.playcamp.io/v1/server/playtime/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([
'sessionId' => '<string>',
'userId' => '<string>',
'durationSeconds' => 2,
'startedAt' => '2023-11-07T05:31:56Z',
'endedAt' => '2023-11-07T05:31:56Z',
'campaignId' => '<string>',
'creatorKey' => '<string>',
'metadata' => [
],
'callbackId' => '<string>',
'isTest' => false
]),
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://sdk-api.playcamp.io/v1/server/playtime/sessions"
payload := strings.NewReader("{\n \"sessionId\": \"<string>\",\n \"userId\": \"<string>\",\n \"durationSeconds\": 2,\n \"startedAt\": \"2023-11-07T05:31:56Z\",\n \"endedAt\": \"2023-11-07T05:31:56Z\",\n \"campaignId\": \"<string>\",\n \"creatorKey\": \"<string>\",\n \"metadata\": {},\n \"callbackId\": \"<string>\",\n \"isTest\": false\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://sdk-api.playcamp.io/v1/server/playtime/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sessionId\": \"<string>\",\n \"userId\": \"<string>\",\n \"durationSeconds\": 2,\n \"startedAt\": \"2023-11-07T05:31:56Z\",\n \"endedAt\": \"2023-11-07T05:31:56Z\",\n \"campaignId\": \"<string>\",\n \"creatorKey\": \"<string>\",\n \"metadata\": {},\n \"callbackId\": \"<string>\",\n \"isTest\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sdk-api.playcamp.io/v1/server/playtime/sessions")
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 \"sessionId\": \"<string>\",\n \"userId\": \"<string>\",\n \"durationSeconds\": 2,\n \"startedAt\": \"2023-11-07T05:31:56Z\",\n \"endedAt\": \"2023-11-07T05:31:56Z\",\n \"campaignId\": \"<string>\",\n \"creatorKey\": \"<string>\",\n \"metadata\": {},\n \"callbackId\": \"<string>\",\n \"isTest\": false\n}"
response = http.request(request)
puts response.read_body{
"data": {
"sessionId": "<string>",
"userId": "<string>",
"durationSeconds": 123,
"recorded": true,
"createdAt": "2023-11-07T05:31:56Z"
}
}{
"status": 400,
"error": "Bad Request",
"message": "Validation failed",
"code": "VALIDATION_ERROR",
"details": [
{
"path": "userId",
"message": "Required"
},
{
"path": "amount",
"message": "Expected number, received string"
}
]
}{
"status": 401,
"error": "Unauthorized",
"message": "Invalid API key",
"code": "UNAUTHORIZED"
}{
"status": 403,
"error": "Forbidden",
"message": "Access denied",
"code": "FORBIDDEN"
}{
"status": 400,
"error": "Bad Request",
"message": "Validation failed",
"code": "VALIDATION_ERROR",
"details": [
{
"path": "userId",
"message": "Required"
},
{
"path": "amount",
"message": "Expected number, received string"
}
]
}{
"status": 429,
"error": "Too Many Requests",
"message": "Rate limit exceeded",
"code": "RATE_LIMITED"
}Playtime
Record Playtime Session
Records a single playtime session.
Auto attribution:
- If
campaignIdis not specified, automatically attributed to the project’s active campaign sponsor
Idempotency:
- The unique key is
projectId+sessionId - A duplicate
sessionIdis NOT an error: the existing row is kept and the response returnsrecorded: false
POST
/
v1
/
server
/
playtime
/
sessions
Record Playtime Session
curl --request POST \
--url https://sdk-api.playcamp.io/v1/server/playtime/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sessionId": "<string>",
"userId": "<string>",
"durationSeconds": 2,
"startedAt": "2023-11-07T05:31:56Z",
"endedAt": "2023-11-07T05:31:56Z",
"campaignId": "<string>",
"creatorKey": "<string>",
"metadata": {},
"callbackId": "<string>",
"isTest": false
}
'import requests
url = "https://sdk-api.playcamp.io/v1/server/playtime/sessions"
payload = {
"sessionId": "<string>",
"userId": "<string>",
"durationSeconds": 2,
"startedAt": "2023-11-07T05:31:56Z",
"endedAt": "2023-11-07T05:31:56Z",
"campaignId": "<string>",
"creatorKey": "<string>",
"metadata": {},
"callbackId": "<string>",
"isTest": False
}
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({
sessionId: '<string>',
userId: '<string>',
durationSeconds: 2,
startedAt: '2023-11-07T05:31:56Z',
endedAt: '2023-11-07T05:31:56Z',
campaignId: '<string>',
creatorKey: '<string>',
metadata: {},
callbackId: '<string>',
isTest: false
})
};
fetch('https://sdk-api.playcamp.io/v1/server/playtime/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://sdk-api.playcamp.io/v1/server/playtime/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([
'sessionId' => '<string>',
'userId' => '<string>',
'durationSeconds' => 2,
'startedAt' => '2023-11-07T05:31:56Z',
'endedAt' => '2023-11-07T05:31:56Z',
'campaignId' => '<string>',
'creatorKey' => '<string>',
'metadata' => [
],
'callbackId' => '<string>',
'isTest' => false
]),
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://sdk-api.playcamp.io/v1/server/playtime/sessions"
payload := strings.NewReader("{\n \"sessionId\": \"<string>\",\n \"userId\": \"<string>\",\n \"durationSeconds\": 2,\n \"startedAt\": \"2023-11-07T05:31:56Z\",\n \"endedAt\": \"2023-11-07T05:31:56Z\",\n \"campaignId\": \"<string>\",\n \"creatorKey\": \"<string>\",\n \"metadata\": {},\n \"callbackId\": \"<string>\",\n \"isTest\": false\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://sdk-api.playcamp.io/v1/server/playtime/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sessionId\": \"<string>\",\n \"userId\": \"<string>\",\n \"durationSeconds\": 2,\n \"startedAt\": \"2023-11-07T05:31:56Z\",\n \"endedAt\": \"2023-11-07T05:31:56Z\",\n \"campaignId\": \"<string>\",\n \"creatorKey\": \"<string>\",\n \"metadata\": {},\n \"callbackId\": \"<string>\",\n \"isTest\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sdk-api.playcamp.io/v1/server/playtime/sessions")
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 \"sessionId\": \"<string>\",\n \"userId\": \"<string>\",\n \"durationSeconds\": 2,\n \"startedAt\": \"2023-11-07T05:31:56Z\",\n \"endedAt\": \"2023-11-07T05:31:56Z\",\n \"campaignId\": \"<string>\",\n \"creatorKey\": \"<string>\",\n \"metadata\": {},\n \"callbackId\": \"<string>\",\n \"isTest\": false\n}"
response = http.request(request)
puts response.read_body{
"data": {
"sessionId": "<string>",
"userId": "<string>",
"durationSeconds": 123,
"recorded": true,
"createdAt": "2023-11-07T05:31:56Z"
}
}{
"status": 400,
"error": "Bad Request",
"message": "Validation failed",
"code": "VALIDATION_ERROR",
"details": [
{
"path": "userId",
"message": "Required"
},
{
"path": "amount",
"message": "Expected number, received string"
}
]
}{
"status": 401,
"error": "Unauthorized",
"message": "Invalid API key",
"code": "UNAUTHORIZED"
}{
"status": 403,
"error": "Forbidden",
"message": "Access denied",
"code": "FORBIDDEN"
}{
"status": 400,
"error": "Bad Request",
"message": "Validation failed",
"code": "VALIDATION_ERROR",
"details": [
{
"path": "userId",
"message": "Required"
},
{
"path": "amount",
"message": "Expected number, received string"
}
]
}{
"status": 429,
"error": "Too Many Requests",
"message": "Rate limit exceeded",
"code": "RATE_LIMITED"
}Authorizations
Server API Key (format: {keyId}:{secret})
Body
application/json
Client-generated unique session ID
User ID
Session duration in seconds
Required range:
x >= 1Session start time (ISO 8601 UTC format)
- Format:
YYYY-MM-DDTHH:mm:ss.sssZ - Example:
2024-01-15T10:30:00.000Z
Session end time (ISO 8601 UTC format, must be greater than or equal to startedAt)
- Format:
YYYY-MM-DDTHH:mm:ss.sssZ - Example:
2024-01-15T11:00:00.000Z
Campaign ID (optional). If omitted, automatically attributed to the project's active campaign sponsor
Creator key (optional, exactly 5 uppercase alphanumeric characters)
Pattern:
^[A-Z0-9]{5}$Playtime platform (optional, server defaults to Other)
Available options:
iOS, Android, Web, Roblox, Other Arbitrary key/value metadata
Webhook tracking ID (included in webhook events triggered by this request)
Test mode (does not create actual data)
Response
Success
Recorded playtime session
Show child attributes
Show child attributes
⌘I