Create a usage record
curl --request POST \
--url https://api.salesive.com/api/v1/app-billing/subscriptions/{id}/usage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "120 SMS sent",
"amount": 6,
"idempotencyKey": "sms-2026-11-05"
}
'import requests
url = "https://api.salesive.com/api/v1/app-billing/subscriptions/{id}/usage"
payload = {
"description": "120 SMS sent",
"amount": 6,
"idempotencyKey": "sms-2026-11-05"
}
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({description: '120 SMS sent', amount: 6, idempotencyKey: 'sms-2026-11-05'})
};
fetch('https://api.salesive.com/api/v1/app-billing/subscriptions/{id}/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.salesive.com/api/v1/app-billing/subscriptions/{id}/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([
'description' => '120 SMS sent',
'amount' => 6,
'idempotencyKey' => 'sms-2026-11-05'
]),
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.salesive.com/api/v1/app-billing/subscriptions/{id}/usage"
payload := strings.NewReader("{\n \"description\": \"120 SMS sent\",\n \"amount\": 6,\n \"idempotencyKey\": \"sms-2026-11-05\"\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.salesive.com/api/v1/app-billing/subscriptions/{id}/usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"120 SMS sent\",\n \"amount\": 6,\n \"idempotencyKey\": \"sms-2026-11-05\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.salesive.com/api/v1/app-billing/subscriptions/{id}/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 \"description\": \"120 SMS sent\",\n \"amount\": 6,\n \"idempotencyKey\": \"sms-2026-11-05\"\n}"
response = http.request(request)
puts response.read_body{
"status": 123,
"success": true,
"message": "<string>",
"data": {
"id": "<string>",
"subscriptionId": "<string>",
"description": "<string>",
"amount": 123,
"currency": "USD",
"periodStart": "2023-11-07T05:31:56Z",
"billed": true,
"chargeId": "<string>",
"idempotencyKey": "<string>",
"test": true,
"createdAt": "2023-11-07T05:31:56Z",
"usage": {
"cappedAmount": 123,
"terms": "<string>",
"periodStart": "2023-11-07T05:31:56Z",
"balance": 123,
"remaining": 123
}
}
}{
"status": 401,
"success": false,
"message": "Authentication required",
"data": null
}{
"status": 403,
"success": false,
"message": "Insufficient scope",
"data": null
}{
"status": 404,
"success": false,
"message": "Resource not found",
"data": null
}Billing
Create a usage record
Bill usage on a capped subscription, never past the cap the merchant approved. Requires the WRITE_CHARGES scope.
POST
/
app-billing
/
subscriptions
/
{id}
/
usage
Create a usage record
curl --request POST \
--url https://api.salesive.com/api/v1/app-billing/subscriptions/{id}/usage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "120 SMS sent",
"amount": 6,
"idempotencyKey": "sms-2026-11-05"
}
'import requests
url = "https://api.salesive.com/api/v1/app-billing/subscriptions/{id}/usage"
payload = {
"description": "120 SMS sent",
"amount": 6,
"idempotencyKey": "sms-2026-11-05"
}
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({description: '120 SMS sent', amount: 6, idempotencyKey: 'sms-2026-11-05'})
};
fetch('https://api.salesive.com/api/v1/app-billing/subscriptions/{id}/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.salesive.com/api/v1/app-billing/subscriptions/{id}/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([
'description' => '120 SMS sent',
'amount' => 6,
'idempotencyKey' => 'sms-2026-11-05'
]),
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.salesive.com/api/v1/app-billing/subscriptions/{id}/usage"
payload := strings.NewReader("{\n \"description\": \"120 SMS sent\",\n \"amount\": 6,\n \"idempotencyKey\": \"sms-2026-11-05\"\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.salesive.com/api/v1/app-billing/subscriptions/{id}/usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"120 SMS sent\",\n \"amount\": 6,\n \"idempotencyKey\": \"sms-2026-11-05\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.salesive.com/api/v1/app-billing/subscriptions/{id}/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 \"description\": \"120 SMS sent\",\n \"amount\": 6,\n \"idempotencyKey\": \"sms-2026-11-05\"\n}"
response = http.request(request)
puts response.read_body{
"status": 123,
"success": true,
"message": "<string>",
"data": {
"id": "<string>",
"subscriptionId": "<string>",
"description": "<string>",
"amount": 123,
"currency": "USD",
"periodStart": "2023-11-07T05:31:56Z",
"billed": true,
"chargeId": "<string>",
"idempotencyKey": "<string>",
"test": true,
"createdAt": "2023-11-07T05:31:56Z",
"usage": {
"cappedAmount": 123,
"terms": "<string>",
"periodStart": "2023-11-07T05:31:56Z",
"balance": 123,
"remaining": 123
}
}
}{
"status": 401,
"success": false,
"message": "Authentication required",
"data": null
}{
"status": 403,
"success": false,
"message": "Insufficient scope",
"data": null
}{
"status": 404,
"success": false,
"message": "Resource not found",
"data": null
}Records usage against a subscription created with a
cappedAmount. Usage is billed at the end of the period. See Usage-based charges.Authorizations
Installed-app access token (prefix app_), issued by the OAuth install flow. The store is bound to the token server-side, never send a shop id.
Path Parameters
The subscription id.
Body
application/json
Response
A record with this idempotencyKey already exists; it is returned.
Was this page helpful?

