curl --request GET \
--url https://api.example.com/usage \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.example.com/usage"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.example.com/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.example.com/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
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.example.com/usage")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"plan": "starter",
"cfdiIncluded": 500,
"cfdiUsedThisMonth": 128,
"cfdiRemaining": 372,
"periodResetsAt": "2026-09-01T06:00:00.000Z",
"usagePct": 70.5,
"projectedCostMxn": 25,
"cfdiByChannelThisMonth": {
"web": 3,
"api": 0,
"sdk": 1,
"cli": 0,
"mcp": 12,
"unknown": 0
}
}Get CFDI Usage
Authenticate with either a Supabase session (send the X-Organization-Id header) or an API key (external integrations, requires the read:invoices scope). Returns how many CFDI the organization has stamped this calendar month (Mexico City time) against its plan’s included quota. cfdiIncluded/cfdiRemaining are null for the enterprise plan (unlimited).
curl --request GET \
--url https://api.example.com/usage \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.example.com/usage"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.example.com/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.example.com/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/usage"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
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.example.com/usage")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"plan": "starter",
"cfdiIncluded": 500,
"cfdiUsedThisMonth": 128,
"cfdiRemaining": 372,
"periodResetsAt": "2026-09-01T06:00:00.000Z",
"usagePct": 70.5,
"projectedCostMxn": 25,
"cfdiByChannelThisMonth": {
"web": 3,
"api": 0,
"sdk": 1,
"cli": 0,
"mcp": 12,
"unknown": 0
}
}This endpoint takes noorganizationIdin the URL. Authenticate with either a Supabase Bearer session (send theX-Organization-Id: <org-id>header — the user must be a member of that organization) or an API key (the organization resolves automatically from the key; anyX-Organization-Idheader sent alongside an API key is ignored).
Authentication
Accepts either:- A Supabase Bearer session (
Authorization: Bearer <token>) with theX-Organization-Id: <org-id>header — the authenticated user must be a member of that organization. - An API key (
X-API-Key: sk_...) with theread:invoicesscope — the organization is resolved from the key itself.
Example Request
curl -X GET https://api.timbrix.mx/usage \
-H "Authorization: Bearer <your_token>" \
-H "X-Organization-Id: 550e8400-e29b-41d4-a716-446655440000"
const usage = await timbrix.invoices.usage(
"550e8400-e29b-41d4-a716-446655440000"
)
console.log(usage.cfdiUsedThisMonth, usage.cfdiIncluded)
X-Organization-Id header (and the SDK’s organizationId argument) entirely — it’s resolved from the key:
const usage = await timbrix.invoices.usage()
console.log(usage.cfdiUsedThisMonth, usage.cfdiIncluded)
Example Response
{
"plan": "pro",
"cfdiIncluded": 500,
"cfdiUsedThisMonth": 460,
"cfdiRemaining": 40,
"periodResetsAt": "2026-09-01T06:00:00.000Z",
"usagePct": 92,
"projectedCostMxn": 0,
"cfdiByChannelThisMonth": {
"web": 3,
"api": 0,
"sdk": 1,
"cli": 0,
"mcp": 12,
"unknown": 0
}
}
| Field | Type | Description |
|---|---|---|
plan | "starter" | "pro" | "business" | "enterprise" | The organization’s current subscription plan |
cfdiIncluded | integer | null | CFDI included in the plan this month — null on the enterprise plan (unlimited) |
cfdiUsedThisMonth | integer | CFDI stamped so far this calendar month |
cfdiRemaining | integer | null | cfdiIncluded - cfdiUsedThisMonth — null on the enterprise plan (unlimited) |
periodResetsAt | string | ISO 8601 timestamp of the next monthly reset |
usagePct | number | cfdiUsedThisMonth / cfdiIncluded * 100 — 0 on the enterprise plan |
projectedCostMxn | number | null | Estimated overage cost this month in MXN — null on the enterprise plan |
web, api, sdk, cli, mcp y
unknown (CFDI sin canal registrado). A diferencia de cfdiUsedThisMonth,
que solo cuenta producción, este desglose no afecta tu cuota.Common Errors
400 Bad Request
MissingX-Organization-Id header on a session-authenticated request.
401 Unauthorized
Missing or invalid Bearer token / API key.403 Forbidden
The authenticated user is not a member of the organization sent inX-Organization-Id, or the API key does not have the read:invoices scope.Authorizations
API Key for authentication (format: sk_...)
Headers
Required for Supabase session auth. Ignored when authenticating with an API key (the organization resolves from the key).
Response
starter, pro, business, enterprise null = ilimitado (plan enterprise)
500
128
null = ilimitado (plan enterprise)
372
"2026-09-01T06:00:00.000Z"
70.5
Costo estimado del excedente este mes en MXN — null en el plan enterprise
25
CFDI emitidos este mes (America/Mexico_City) por canal de origen, sumando sandbox y producción. unknown = CFDI sin canal registrado.
{
"web": 3,
"api": 0,
"sdk": 1,
"cli": 0,
"mcp": 12,
"unknown": 0
}