> ## 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.

# Create Checkout Session

> Create a Stripe checkout session to subscribe to or upgrade your plan.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.adrelay.dev/v1/billing/create-checkout-session" \
    -H "X-API-Key: $ADRELAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"plan": "pro"}'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    "https://api.adrelay.dev/v1/billing/create-checkout-session",
    {
      method: "POST",
      headers: {
        "X-API-Key": process.env.ADRELAY_API_KEY,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ plan: "pro" }),
    }
  );

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

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

  response = requests.post(
      "https://api.adrelay.dev/v1/billing/create-checkout-session",
      headers={
          "X-API-Key": "your-api-key-here",
          "Content-Type": "application/json",
      },
      json={"plan": "pro"},
  )

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "checkout_url": "https://checkout.stripe.com/c/pay/cs_live_...",
    "session_id": "cs_live_abc123"
  }
  ```

  ```json 400 theme={null}
  {
    "error": "Invalid plan. Must be one of: starter, pro, enterprise.",
    "code": "VALIDATION_ERROR",
    "timestamp": 1711036800,
    "request_id": "req_abc123"
  }
  ```
</ResponseExample>

Redirect the user to the returned `checkout_url` to complete payment. After successful payment, the plan upgrade takes effect immediately.
