Get per-end-user widget usage
curl --request GET \
--url https://api.corebasehq.com/api/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.corebasehq.com/api/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.corebasehq.com/api/v1/usage', 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.corebasehq.com/api/v1/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
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.corebasehq.com/api/v1/usage"
req, _ := http.NewRequest("GET", 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.get("https://api.corebasehq.com/api/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.corebasehq.com/api/v1/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"period_days": 123,
"quota_enforced": true,
"users": [
{
"external_id": "<string>",
"messages": 123,
"chats": 123,
"last_active": "<string>",
"quota": {
"daily_used": 123,
"monthly_used": 123,
"per_minute_used": 123
}
}
]
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"detail": "<string>"
}Endpoints
Get widget usage
Returns live usage for your embedded widget, one row per end-user, keyed by
the sub you sign into each widget JWT (external_id). You set the per-user
limits in the JWT, so only the live used counts are returned; compute
remaining as your_limit - used. Join external_id against your own user
table to attach names or emails.
GET
/
api
/
v1
/
usage
Get per-end-user widget usage
curl --request GET \
--url https://api.corebasehq.com/api/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.corebasehq.com/api/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.corebasehq.com/api/v1/usage', 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.corebasehq.com/api/v1/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
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.corebasehq.com/api/v1/usage"
req, _ := http.NewRequest("GET", 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.get("https://api.corebasehq.com/api/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.corebasehq.com/api/v1/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"period_days": 123,
"quota_enforced": true,
"users": [
{
"external_id": "<string>",
"messages": 123,
"chats": 123,
"last_active": "<string>",
"quota": {
"daily_used": 123,
"monthly_used": 123,
"per_minute_used": 123
}
}
]
}{
"detail": "<string>"
}{
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"detail": "<string>"
}Per-end-user usage for your embedded widget over a time window — messages,
distinct chats, last activity, and live quota counters for the limits you sign
into each visitor’s widget JWT. Build partner dashboards or your own billing on
top of it.
The
external_id of each row is the sub you signed into that visitor’s
widget token — see the widget guide for how sessions are
issued.Authorizations
A cb_live_ API token, created in the panel under API Tokens.
Query Parameters
Number of days to include in the usage window.
Maximum number of end-users to return.
Response
Successful Response
Per-end-user widget usage for the requested window.