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

API

Set billing info via the xAI Management API

Write the billing name, address, email, and tax fields for a team over HTTP when provisioning, legal entity changes, or invoice prep need the same customer block Console shows under Billing without clicking through Payment screens. Official Billing Management documents POST /v1/billing/teams/{team_id}/billing-info on https://management-api.x.ai, authorized with a management key. The request body wraps a billingInfo object with name, nested address (line1, line2, city, country, postalCode, state), email, taxIdType, and taxNumber. The documented success response is an empty JSON object. 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 finance-approved values for every field you send—especially country as a two-letter ISO 3166-1 alpha-2 code and any tax identifiers that must appear on invoices. Official Manage Billing warns that billing address and tax text print on invoices and that xAI cannot regenerate invoices after they issue, so treat the POST as a careful write. Neighboring jobs include Get billing info via the xAI Management API, Update billing address in the xAI Console, and List payment methods via the xAI Management API. More API jobs live on the API hub.

Post 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. Optionally GET the current block first so you know what you are replacing:
curl "https://management-api.x.ai/v1/billing/teams/${XAI_TEAM_ID}/billing-info" \
  -H "Authorization: Bearer ${XAI_MANAGEMENT_KEY}"
  1. POST the full billingInfo object you want on file. The example below mirrors the official request sample:
curl "https://management-api.x.ai/v1/billing/teams/${XAI_TEAM_ID}/billing-info" \
  -X POST \
  -H "Authorization: Bearer ${XAI_MANAGEMENT_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "billingInfo": {
      "name": "Acme Inc.",
      "address": {
        "line1": "123 Main St.",
        "line2": "",
        "city": "New York",
        "country": "US",
        "postalCode": "12345",
        "state": "New York"
      },
      "email": "foo@example.com",
      "taxIdType": "us_ein",
      "taxNumber": "12-3456789"
    }
  }'
  1. Expect {} on success per the docs example, then GET again and confirm every field matches what finance approved. Keep the same team selected conceptually as Console: billing changes affect all users on that team.

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

Coordinate with Console and charges

When operators prefer the UI, use Update billing address in the xAI Console under Billing → Payment for the same address and optional tax fields, then re-GET via Management to prove API and Console agree. Run the set endpoint before the next prepaid top-up or monthly invoice cycle so new invoices pick up the corrected customer block. Pair with Preview a postpaid invoice via the xAI Management API when you need the open-cycle draft amounts after the address change lands.

Pitfalls

Posting while the wrong team id is in the path updates another team's invoice identity. Sending a partial mental model of fields without reading the current GET first can blank tax ids you meant to keep. Assuming a successful POST rewrites already-issued invoice PDFs conflicts with Console policy that those invoices stay as originally printed. Mixing consumer payment screens on grok.com with these team Management fields confuses which product will show the new address.