Branch #09 docs/api/09-account-billing.md

11. Account, Billing, Entitlement, Usage

Branch #09 — Quản trị hạn mức, chi phí, trạng thái truy cập và analytics sử dụng.

Endpoints

GET
https://bizgpt.vn/wp-json/bizcity/v1/account/entitlement

Tier + quota + khóa tính năng

Auth: Bearer/Cookie

GET
https://bizgpt.vn/wp-json/bizcity/v1/account/usage/today

Sử dụng trong ngày

Auth: Bearer/Cookie

GET
https://bizgpt.vn/wp-json/bizcity/v1/billing/balance

Số dư credits

Auth: Bearer/Cookie

GET
https://bizgpt.vn/wp-json/bizcity/v1/billing/transactions

Lịch sử giao dịch

Auth: Bearer/Cookie

Method Path Auth Mô tả
GET https://bizgpt.vn/wp-json/bizcity/v1/account/entitlement Bearer/Cookie Tier + quota + khóa tính năng
GET https://bizgpt.vn/wp-json/bizcity/v1/account/usage/today Bearer/Cookie Sử dụng trong ngày
GET https://bizgpt.vn/wp-json/bizcity/v1/billing/balance Bearer/Cookie Số dư credits
GET https://bizgpt.vn/wp-json/bizcity/v1/billing/transactions Bearer/Cookie Lịch sử giao dịch

Query Examples

GET Tier + quota + khóa tính năng
curl -X GET "https://bizgpt.vn/wp-json/bizcity/v1/account/entitlement" -H "Authorization: Bearer biz-YOUR_KEY"
const res = await fetch('https://bizgpt.vn/wp-json/bizcity/v1/account/entitlement', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
  },
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity/v1/account/entitlement"
headers = {'Authorization': 'Bearer biz-YOUR_KEY'}
res = requests.get(url, headers=headers)
print(res.json())
GET Sử dụng trong ngày
curl -X GET "https://bizgpt.vn/wp-json/bizcity/v1/account/usage/today" -H "Authorization: Bearer biz-YOUR_KEY"
const res = await fetch('https://bizgpt.vn/wp-json/bizcity/v1/account/usage/today', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
  },
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity/v1/account/usage/today"
headers = {'Authorization': 'Bearer biz-YOUR_KEY'}
res = requests.get(url, headers=headers)
print(res.json())
GET Số dư credits
curl -X GET "https://bizgpt.vn/wp-json/bizcity/v1/billing/balance" -H "Authorization: Bearer biz-YOUR_KEY"
const res = await fetch('https://bizgpt.vn/wp-json/bizcity/v1/billing/balance', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
  },
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity/v1/billing/balance"
headers = {'Authorization': 'Bearer biz-YOUR_KEY'}
res = requests.get(url, headers=headers)
print(res.json())
GET Lịch sử giao dịch
curl -X GET "https://bizgpt.vn/wp-json/bizcity/v1/billing/transactions" -H "Authorization: Bearer biz-YOUR_KEY"
const res = await fetch('https://bizgpt.vn/wp-json/bizcity/v1/billing/transactions', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer biz-YOUR_KEY',
  },
});
const data = await res.json();
console.log(data);
import requests
url = "https://bizgpt.vn/wp-json/bizcity/v1/billing/transactions"
headers = {'Authorization': 'Bearer biz-YOUR_KEY'}
res = requests.get(url, headers=headers)
print(res.json())

Use Cases

  • Khóa tính năng theo gói để tránh vượt ngân sách.
  • Hiển thị dashboard usage theo user/team/campaign.
  • Cảnh báo sớm khi sắp cạn hạn mức.

Implementation Steps

  1. Check entitlement trước khi gọi endpoint nặng.
  2. Lưu thống kê theo ngày cho báo cáo vận hành.
  3. Map error code rõ ràng cho UI để tránh generic error.

Quick Start cURL

bash
curl -X GET https://bizgpt.vn/wp-json/bizcity/v1/account/entitlement -H "Authorization: Bearer biz-YOUR_KEY"
Canonical Spec

docs/api/09-account-billing.md