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

# Billing

> Manage plans, credits, and subscription via the API

# Billing

The billing API exposes your account's plan, credit balance, and subscription management. Most billing actions can also be performed from the [Usage & Billing](https://build.withgiga.ai/billing) page in the dashboard.

***

## Get billing info

Returns your current plan, credit balance, and usage for the current period.

`GET /api/billing`

**Response (200)**

```json theme={null}
{
  "success": true,
  "data": {
    "billing": {
      "plan": "starter-pro",
      "planCreditsRemaining": 74.50,
      "prepaidBalance": 50.00,
      "totalBalance": 124.50,
      "currentPeriodStart": "2024-03-01T00:00:00.000Z",
      "currentPeriodEnd": "2024-04-01T00:00:00.000Z"
    }
  }
}
```

***

## List plans

Returns all available subscription plans with pricing and limits.

`GET /api/billing/plans`

**Response (200)**

```json theme={null}
{
  "success": true,
  "data": {
    "plans": [
      {
        "id": "free",
        "name": "Free",
        "monthlyCredits": 10,
        "concurrentAgents": 1,
        "maxDurationHours": 1,
        "price": 0
      },
      {
        "id": "starter-pro",
        "name": "Starter Pro",
        "monthlyCredits": 100,
        "concurrentAgents": 5,
        "maxDurationHours": 8,
        "price": 29
      },
      {
        "id": "max",
        "name": "Max",
        "monthlyCredits": "custom",
        "concurrentAgents": "unlimited",
        "maxDurationHours": 24,
        "price": "custom"
      }
    ]
  }
}
```

***

## Subscribe to a plan

Initiates a Stripe checkout session to upgrade or downgrade your subscription. Returns a `checkoutUrl` to redirect your user to.

`POST /api/billing/subscribe`

**Body**

```json theme={null}
{
  "planId": "starter-pro"
}
```

**Response (200)**

```json theme={null}
{
  "success": true,
  "data": {
    "checkoutUrl": "https://checkout.stripe.com/..."
  }
}
```

***

## Add credits

Initiates a Stripe checkout to top up your prepaid credit balance.

`POST /api/billing/recharge`

**Body**

```json theme={null}
{
  "amount": 50
}
```

| Field    | Type   | Description                          |
| -------- | ------ | ------------------------------------ |
| `amount` | number | USD amount to add to prepaid balance |

**Response (200)**

```json theme={null}
{
  "success": true,
  "data": {
    "checkoutUrl": "https://checkout.stripe.com/..."
  }
}
```
