Get sub-account spending
Get spending information for a sub-account. Returns the parent team’s balance, the sub-account’s total spending, and its credit limit (spending cap). Requires a parent project API key; sub-account API keys receive HTTP 403.
curl --request GET \
--url https://api.zavu.dev/v1/sub-accounts/{id}/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.zavu.dev/v1/sub-accounts/{id}/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.zavu.dev/v1/sub-accounts/{id}/balance', 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.zavu.dev/v1/sub-accounts/{id}/balance",
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.zavu.dev/v1/sub-accounts/{id}/balance"
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.zavu.dev/v1/sub-accounts/{id}/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v1/sub-accounts/{id}/balance")
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{
"balance": 123,
"currency": "usd",
"payAsYouGo": true,
"spendCap": 123,
"spentThisMonth": 123,
"appMessages": {
"used": 123,
"included": 123,
"paused": "allowance"
},
"heldInbound": {
"count": 123,
"max": 123,
"nextExpiresAt": "2023-11-07T05:31:56Z"
},
"creditLimit": 123,
"totalSpent": 123,
"isSubAccount": true
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Sub-account ID.
Response
Sub-account balance.
The team's balance, and what stops or charges it this month. Every field past isSubAccount is team-level, the same for every project and sub-account of the team. An integration that only replies to message.inbound never sends while incoming messages are held, so it never sees the 429 that reports them: poll this instead.
Team balance in cents. All charges are billed to the parent team.
"usd"
Whether the team is on Free and has added funds, so app messages past the allowance are billed in blocks from the balance instead of stopping.
The monthly usage spend cap in cents, set in the dashboard's Billing. Null means no cap. The first deposit on Free sets $50 when none was chosen.
Usage taken from the balance this calendar month (UTC), in cents: what the spend cap is measured against. Renewals are not counted.
This month's WhatsApp, Telegram, Instagram and Messenger messages, sent and received.
Show child attributes
Show child attributes
Incoming messages held at the allowance, or null when none are. Counts and a date only, never content or senders. They are delivered once the team pays; see POST /v1/messages.
Show child attributes
Show child attributes
Spending cap in cents (only for sub-accounts).
Total amount spent by this sub-account in cents (only for sub-accounts).
Whether this API key belongs to a sub-account.
curl --request GET \
--url https://api.zavu.dev/v1/sub-accounts/{id}/balance \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.zavu.dev/v1/sub-accounts/{id}/balance"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.zavu.dev/v1/sub-accounts/{id}/balance', 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.zavu.dev/v1/sub-accounts/{id}/balance",
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.zavu.dev/v1/sub-accounts/{id}/balance"
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.zavu.dev/v1/sub-accounts/{id}/balance")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zavu.dev/v1/sub-accounts/{id}/balance")
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{
"balance": 123,
"currency": "usd",
"payAsYouGo": true,
"spendCap": 123,
"spentThisMonth": 123,
"appMessages": {
"used": 123,
"included": 123,
"paused": "allowance"
},
"heldInbound": {
"count": 123,
"max": 123,
"nextExpiresAt": "2023-11-07T05:31:56Z"
},
"creditLimit": 123,
"totalSpent": 123,
"isSubAccount": true
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}{
"code": "invalid_request",
"message": "Phone number is invalid",
"details": {}
}