API / get-billing-info-via-management-api

API

Get billing info via the xAI Management API

Read the billing name, address, email, and tax fields on file for a team over HTTP when finance ops, invoice QA, or provisioning runbooks need the same customer block Console prints on invoices without opening Billing by hand. Official Billing Management documents GET /v1/billing/teams/{team_id}/billing-info on https://management-api.x.ai, authorized with a management key. The response wraps a billingInfo object with name, nested address lines (line1, line2, city, country, postalCode, state), email, taxIdType, and taxNumber. Create the management key first with Create a management key in the xAI Console if you do not already have one.

What you need

A management key that can call billing routes for the team, the team id in the path, and a clear map of which legal entity should appear on invoices before you treat an empty tax field as a defect. Country on the address is a two-letter ISO 3166-1 alpha-2 code in the docs example (US). Neighboring billing jobs include Set billing info via the xAI Management API, Update billing address in the xAI Console, and List invoices via the xAI Management API. More API jobs live on the API hub.

Fetch the billing block

  1. Export the management key and team id outside of source control:
export XAI_MANAGEMENT_KEY="your_management_key"
export XAI_TEAM_ID="your_team_id"
  1. Get billing information for the team:
curl "https://management-api.x.ai/v1/billing/teams/${XAI_TEAM_ID}/billing-info" \
  -H "Authorization: Bearer ${XAI_MANAGEMENT_KEY}"
  1. Read billingInfo.name, billingInfo.email, and each address field you need for ops tickets. Confirm country is the expected two-letter code and that postalCode / state match the legal address finance already approved. Capture taxIdType and taxNumber when tax identifiers must print on invoices; leave them unset in your notes when the response omits values you never stored.

  2. Compare the Management response against a recent invoice row from List invoices via the xAI Management API or against Console Billing → Invoices so the customer block you automate matches what already printed. Official Console billing docs warn that invoice text cannot be regenerated after issue, so a GET that disagrees with an old PDF is a forward-looking correction, not a rewrite of history.

Keep every call on https://management-api.x.ai. An inference API key against https://api.x.ai will not answer billing routes.

Use the block before you charge

Run the GET in the same runbook that sets billing info or updates Console address so you fail fast when the on-file name or tax id is blank before a prepaid top-up or monthly invoice cycle. After a team switch in Console, re-GET with the new team id rather than assuming Personal Team and production share one customer record. Pair with List payment methods via the xAI Management API when payment-method objects also embed a billingInfo snapshot you want to reconcile against the team-level block.

Pitfalls

Calling the wrong team id returns another entity's address and quietly poisons invoice QA. Treating a successful empty-looking object as “no billing record” without checking each field leads to posts that overwrite good Console data later. Mixing SuperGrok consumer billing screens on grok.com with these team Management fields invents a ledger that never matches Console API invoices. Expecting Management GET to rewrite already-issued invoice PDFs conflicts with Console policy that those invoices stay as originally printed.