curl --request POST \
--url https://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tokens": 1500,
"cost": 0.42,
"source": "crm-sync",
"reason": "<string>"
}
'import requests
url = "https://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage"
payload = {
"tokens": 1500,
"cost": 0.42,
"source": "crm-sync",
"reason": "<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({tokens: 1500, cost: 0.42, source: 'crm-sync', reason: '<string>'})
};
fetch('https://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-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.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage",
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([
'tokens' => 1500,
'cost' => 0.42,
'source' => 'crm-sync',
'reason' => '<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://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage"
payload := strings.NewReader("{\n \"tokens\": 1500,\n \"cost\": 0.42,\n \"source\": \"crm-sync\",\n \"reason\": \"<string>\"\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://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"tokens\": 1500,\n \"cost\": 0.42,\n \"source\": \"crm-sync\",\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage")
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 \"tokens\": 1500,\n \"cost\": 0.42,\n \"source\": \"crm-sync\",\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"tenantId": "<string>",
"subtenantId": "<string>",
"source": "<string>",
"applied": {
"tokens": 123,
"cost": 123,
"countedTowardLimits": true
},
"usage": [
{}
]
}Add usage to a subtenant
Admin action (full API keys only — devic-ui restricted keys are blocked at the gateway). Adds usage your own product measured outside Devic. It consumes the tenant’s quota exactly like a call Devic measured, including blocking the tenant with 429 TENANT_LIMIT_EXCEEDED once a window is spent, and is tagged as injected so it can be told apart from measured usage. It only adds: negative amounts are rejected — use the reset endpoint to clear counters. Subtenant rules are consumed on top of the tenant’s own.
curl --request POST \
--url https://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tokens": 1500,
"cost": 0.42,
"source": "crm-sync",
"reason": "<string>"
}
'import requests
url = "https://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage"
payload = {
"tokens": 1500,
"cost": 0.42,
"source": "crm-sync",
"reason": "<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({tokens: 1500, cost: 0.42, source: 'crm-sync', reason: '<string>'})
};
fetch('https://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-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.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage",
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([
'tokens' => 1500,
'cost' => 0.42,
'source' => 'crm-sync',
'reason' => '<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://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage"
payload := strings.NewReader("{\n \"tokens\": 1500,\n \"cost\": 0.42,\n \"source\": \"crm-sync\",\n \"reason\": \"<string>\"\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://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"tokens\": 1500,\n \"cost\": 0.42,\n \"source\": \"crm-sync\",\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devic.ai/v1/tenant-admin/{tenantId}/subtenants/{subtenantId}/add-usage")
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 \"tokens\": 1500,\n \"cost\": 0.42,\n \"source\": \"crm-sync\",\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"tenantId": "<string>",
"subtenantId": "<string>",
"source": "<string>",
"applied": {
"tokens": 123,
"cost": 123,
"countedTowardLimits": true
},
"usage": [
{}
]
}Authorizations
An API key from your Devic console, sent as Authorization: Bearer <key>. An embedded front end sends a tenant-session token instead, so no API key reaches the browser, and an OAuth integration sends its access token. Missing, invalid or expired credentials get a 401. See Authentication.
Body
At least one of tokens or cost must be greater than 0.
Tokens to add. Rounded to an integer.
x >= 01500
Cost to add, in the same unit as the tenant's cost limits.
x >= 00.42
Tag this injection is filed under, so usage can be broken down by origin.
^[a-z0-9_-]{1,40}$"crm-sync"
Free-text note for your own auditing. Not stored on the counters.
Response
Usage added