Developer
Python
requests, three calls.
python
import os, uuid, requests
BASE = "https://api.trabalance.com/api/v1"
H = {"Authorization": f"Bearer {os.environ['TRABALANCE_API_KEY']}"}
def tb(method, path, body=None):
headers = dict(H)
if method != "GET":
headers["Idempotency-Key"] = str(uuid.uuid4())
r = requests.request(method, BASE + path, headers=headers, json=body, timeout=30)
data = r.json()
if not r.ok:
raise RuntimeError(f"{data['error']}: {data['error_description']}")
return data["data"]
customers = tb("GET", "/customers?page_size=10")["items"]
customer = tb("POST", "/customers", {"name": "Acme Corp", "email": "[email protected]"})
invoice = tb("POST", "/invoices", {
"receiver": customer["id"], "date": "2026-08-26",
"items": [{"id": "<item id>", "qty": 2, "rate": 150}],
})