> ## Documentation Index
> Fetch the complete documentation index at: https://docs.adrelay.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Billing Portal

> Create a Stripe billing portal session for managing subscriptions and payment methods.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.adrelay.dev/v1/billing/portal" \
    -H "X-API-Key: $ADRELAY_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.adrelay.dev/v1/billing/portal", {
    method: "POST",
    headers: { "X-API-Key": process.env.ADRELAY_API_KEY },
  });

  const data = await response.json();
  // Redirect user to data.portal_url
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.adrelay.dev/v1/billing/portal",
      headers={"X-API-Key": "your-api-key-here"},
  )

  data = response.json()
  # Redirect user to data["portal_url"]
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "portal_url": "https://billing.stripe.com/p/session/..."
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Invalid or missing API key.",
    "code": "UNAUTHORIZED",
    "timestamp": 1711036800,
    "request_id": "req_abc123"
  }
  ```
</ResponseExample>

The billing portal allows users to update payment methods, view invoices, and manage their subscription. Redirect the user to the returned `portal_url`.
