Set current usage
curl --request PUT \
--url https://commet.co/api/v1/usage \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"customerId": "<string>",
"feature": "<string>",
"value": 1073741823
}
'const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>', feature: '<string>', value: 1073741823})
};
fetch('https://commet.co/api/v1/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://commet.co/api/v1/usage"
payload = {
"customerId": "<string>",
"feature": "<string>",
"value": 1073741823
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://commet.co/api/v1/usage"
payload := strings.NewReader("{\n \"customerId\": \"<string>\",\n \"feature\": \"<string>\",\n \"value\": 1073741823\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.put("https://commet.co/api/v1/usage")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\",\n \"feature\": \"<string>\",\n \"value\": 1073741823\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://commet.co/api/v1/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => '<string>',
'feature' => '<string>',
'value' => 1073741823
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"success": true,
"data": {
"id": "<string>",
"feature": "<string>",
"value": 1073741823,
"previousValue": 4503599627370495,
"adjustment": 0,
"customerId": "<string>",
"idempotencyKey": "<string>",
"reason": "<string>",
"ts": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"object": "usage_event",
"livemode": true
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}Usage
Set current usage
Set a metered feature’s usage to an exact value for the current period. Commet records the difference as an auditable adjustment event.
PUT
/
usage
Set current usage
curl --request PUT \
--url https://commet.co/api/v1/usage \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"customerId": "<string>",
"feature": "<string>",
"value": 1073741823
}
'const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({customerId: '<string>', feature: '<string>', value: 1073741823})
};
fetch('https://commet.co/api/v1/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://commet.co/api/v1/usage"
payload = {
"customerId": "<string>",
"feature": "<string>",
"value": 1073741823
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://commet.co/api/v1/usage"
payload := strings.NewReader("{\n \"customerId\": \"<string>\",\n \"feature\": \"<string>\",\n \"value\": 1073741823\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.put("https://commet.co/api/v1/usage")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"customerId\": \"<string>\",\n \"feature\": \"<string>\",\n \"value\": 1073741823\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://commet.co/api/v1/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => '<string>',
'feature' => '<string>',
'value' => 1073741823
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"success": true,
"data": {
"id": "<string>",
"feature": "<string>",
"value": 1073741823,
"previousValue": 4503599627370495,
"adjustment": 0,
"customerId": "<string>",
"idempotencyKey": "<string>",
"reason": "<string>",
"ts": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z",
"object": "usage_event",
"livemode": true
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}This reference describes API version
2026-05-25. Send Commet-Version: 2026-05-25 with your request.Encabezados
Cuerpo
application/json
¿Esta página le ayudó?