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

# Billing

> Subscription, usage, and Stripe delegated billing actions

Use the `billing` resource for plan retrieval and billing lifecycle actions.

**Direct actions** (handled locally): `all`, `get`, `create`, `update`, `delete`, `calls`, `phones`

**Stripe-delegated actions** (proxied to `stripe-handler`): `checkout`, `billing-portal`, `update-subscription`, `sync`, `check-status`, `purchase-calls`, `cancel-calls`, `add-phone-number`, `remove-phone-number`

> [!NOTE]
>
> The previously documented `plan`, `usage`, and `invoices` action names do not exist — use `get` and `all` to retrieve billing data.

***

## Get phone billing

Returns the caller's phone-number subscription records and the numbers Help Genie bought for their genies, each with its billing status.

**resource** `string` *required*

Must be `"billing"`

**action** `string` *required*

Must be `"phones"`

**adminMode** `boolean` (default: false)

Admin only. When `true`, allows viewing another user's phone billing with `userId`. Query parameter only.

**userId** `string`

Admin only, requires `adminMode=true`. Return phone billing for this user ID. Query parameter only.

### Response

**success** `boolean`

**data** `object`

**properties**

**phoneSubscriptions** `object[]`

Phone subscription records, newest first. Each record includes `agents: { name }` — the name of the genie the number belongs to.

**numbers** `object[]`

Numbers Help Genie bought for the user's genies, newest first. Transfer, escalation and ported numbers are not included.

**properties**

**id** `number`

**phone\_number\_id** `string`

Provider ID of the number.

**phone\_number** `string`

**friendly\_name** `string | null`

**status** `string`

**date\_created** `string`

**agent\_id** `string`

ID of the genie the number is assigned to.

**agent\_name** `string | null`

**user\_id** `string`

**billing** `string`

One of:

* `"billed"` — the number has a live phone subscription.
* `"no_charge_admin"` — internal admin account; not charged.
* `"no_charge_trial"` — account has no paid plan (for example, still on a trial); not charged.
* `"unbilled"` — a paying, non-admin account with no phone subscription for this number, usually because it was added during a trial.

```typescript Example request theme={null}
const response = await ApiService.invoke<{
  phoneSubscriptions: PhoneSubscription[];
  numbers: GeniePhoneNumber[];
}>({
  resource: "billing",
  action: "phones",
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/billing \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "phones"
  }'
```

***

## Update subscription (admin)

Updates a user's subscription record. Admin only.

On a subscription billed through Stripe (one with a `stripe_id`), only `extra_quantity` is written — status, quantity and dates stay exactly as Stripe set them, and any other field you send is ignored. On any other subscription the update is a full replace: an omitted `quantity`, `stripe_id`, `trial_ends_at` or `ends_at` is set to `null` and an omitted `extra_quantity` to `0`, so always send the current values. Updating a subscription never activates or deactivates the user's genies.

**resource** `string` *required*

Must be `"billing"`

**action** `string` *required*

Must be `"update"`

**data** `object` *required*

**properties**

**userId** `string` *required*

ID of the user whose subscription to update.

**subscriptionId** `string | number` *required*

ID of the subscription record. Must belong to `userId`.

**extra\_quantity** `number`

Extra genie seats granted on top of the plan quantity. Must be a whole number of `0` or more. The only field written on a Stripe-billed subscription.

**status** `string`

Subscription status. Ignored on a Stripe-billed subscription.

**quantity** `number`

Plan seat quantity. Ignored on a Stripe-billed subscription.

**stripe\_id** `string | null`

Stripe subscription ID. Ignored on a Stripe-billed subscription.

**trial\_ends\_at** `string | null`

ISO 8601 timestamp the trial ends. Ignored on a Stripe-billed subscription.

**ends\_at** `string | null`

ISO 8601 timestamp the subscription ends. Ignored on a Stripe-billed subscription.

### Response

**success** `boolean`

**data** `object`

**properties**

**success** `boolean`

**message** `string`

`"Subscription updated successfully"`

```typescript Example request theme={null}
await ApiService.invoke({
  resource: "billing",
  action: "update",
  data: {
    userId: "user-uuid",
    subscriptionId: 123,
    extra_quantity: 2,
  },
});
```

```bash cURL theme={null}
curl -X POST https://api.helpgenie.ai/v1/billing \
  -H "Authorization: Bearer hg_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "update",
    "data": {
      "userId": "user-uuid",
      "subscriptionId": 123,
      "extra_quantity": 2
    }
  }'
```

### Errors

| Status | Code | Description |
| - | - | - |
| 400 | `VALIDATION_ERROR` | `userId` or `subscriptionId` missing, `extra_quantity` is not a whole number of `0` or more, or `"Subscription not found"` (no subscription with that ID for that user) |
| 401 | `UNAUTHORIZED` | Caller is not an admin |
| 500 | `INTERNAL_ERROR` | Database operation failed |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.