Increment Entity Views
curl --request PATCH \
--url https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views"
headers = {"Authorization": "Bearer <token>"}
response = requests.patch(url, headers=headers)
print(response.text)const options = {method: 'PATCH', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views', 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://api.sublay.io/v7/:projectId/entities/:entityId/increment-views",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views"
req, _ := http.NewRequest("PATCH", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"views": 123
}Entity Endpoints
Increment Entity Views
Add to an entity’s view count
Increment Entity Views
curl --request PATCH \
--url https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views"
headers = {"Authorization": "Bearer <token>"}
response = requests.patch(url, headers=headers)
print(response.text)const options = {method: 'PATCH', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views', 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://api.sublay.io/v7/:projectId/entities/:entityId/increment-views",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views"
req, _ := http.NewRequest("PATCH", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sublay.io/v7/:projectId/entities/:entityId/increment-views")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<string>",
"views": 123
}Increments an entity’s
views counter and returns the updated entity.
This endpoint requires a service or master key and cannot be called with an end-user token. Count views from your own backend rather than from the client, so a browser cannot inflate the number.
Path Parameters
string
required
UUID of the entity.
Query Parameters
number
How much to add to the counter. Defaults to
1. Must be a positive integer — pass a batch total to record views your backend has buffered rather than calling the endpoint once per view.Response
Returns the full updated Entity, withviews reflecting the increment.
string
UUID of the entity.
number
The view count after the increment.
Error Responses
Invalid Parameters — 400
Invalid Parameters — 400
{ "error": "Invalid path parameters.", "code": "entity/invalid-params" }
Invalid Count — 400
Invalid Count — 400
Returned when
count is not a positive integer.{ "error": "Count must be a positive integer", "code": "entity/invalid-query" }
Elevated Auth Required — 403
Elevated Auth Required — 403
{
"error": "Service or master key required.",
"code": "auth/elevated-auth-required"
}
Entity Not Found — 404
Entity Not Found — 404
{ "error": "Entity not found.", "code": "entity/not-found" }
Server Error — 500
Server Error — 500
{
"error": "An error occurred while updating entity views.",
"code": "entity/server-error"
}

