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

# Instances and billing

> Create, list, update instances and billing flows with the SDK

Use these resources for account authentication, instance lifecycle, and billing.

For WhatsApp session flows, see [Session](/en/sdk/php/session). For chats, see [Chats](/en/sdk/php/chats). For message sending, see [Messages](/en/sdk/php/messages).

Common fields on instance calls:

| Field           | Type     | Required | Description     |
| --------------- | -------- | -------- | --------------- |
| `instanceId`    | `string` | Yes      | Instance ID.    |
| `instanceToken` | `string` | Yes      | Instance token. |

## Auth

### `auth()->getAccessToken()`

Gets a JWT with `clientToken` and `clientSecret`. In most flows, resources do this automatically.

```php theme={null}
$token = $vzaps->auth()->getAccessToken();
echo substr($token, 0, 16) . PHP_EOL;
```

**Return:** `string` JWT access token (`accessToken` from `POST /token`).

## Instances and billing

### `instances()->create($data)`

```php theme={null}
$created = $vzaps->instances()->create([
    'name' => 'Support',
    'webhook' => 'https://example.com/webhooks/vzaps',
    'eventsSubscribe' => ['Message', 'Connected', 'Disconnected'],
]);
```

**Return:** `InstancePublicCreateResponse` — `id`, `name`, `token`, `url`, `webhook`, `events_subscribe`, `status`, `created_at`, `updated_at`.

### `instances()->list($data = null)`

```php theme={null}
$instances = $vzaps->instances()->list([
    'page' => 1,
    'pageSize' => 20,
    'search' => 'support',
]);
```

**Return:** page `{ page, size, total, total_pages, content[], summary }`. Each `content` item uses the public instance summary shape.

### `instances()->get($instanceId)`

Returns one instance in the same public summary format as each row from `instances()->list()`.

```php theme={null}
$instance = $vzaps->instances()->get('VZ...');
```

**Return:** same summary shape as one `instances.list()` item (`id`, `name`, `token`, `url`, `webhook`, `status`, etc.).

### `instances()->update($instanceId, $data, $instanceToken = null)`

```php theme={null}
$vzaps->instances()->update('VZ...', [
    'name' => 'Commercial Support',
], 'instance-token');
```

**Return:** updated instance in the same summary shape as `instances.get()`.

### `instances()->restart($instanceId, $instanceToken = null)`

```php theme={null}
$vzaps->instances()->restart('VZ...', 'instance-token');
```

**Return:** `InstanceActionResponse` — `instance_id`, `status`, `details`.

### `instances()->delete($instanceId, $instanceToken = null)`

```php theme={null}
$vzaps->instances()->delete('VZ...', 'instance-token');
```

**Return:** empty body on success (`204`) or the standard error envelope.

### `instances()->subscribe($instanceId, $data = [], $instanceToken = null)`

```php theme={null}
$checkout = $vzaps->instances()->subscribe('VZ...', [], 'instance-token');
```

**Return:** `BillingHostedSession` — `url`, `session_id`, `mode` (`direct` or checkout), `subscription_id`.

### `instances()->resumeSubscription($instanceId, $instanceToken = null)`

```php theme={null}
$vzaps->instances()->resumeSubscription('VZ...', 'instance-token');
```

**Return:** `{ status: "ok" }`.

### `instances()->cancel($instanceId, $instanceToken = null)`

```php theme={null}
$vzaps->instances()->cancel('VZ...', 'instance-token');
```

**Return:** `{ message }` confirming cancellation or scheduled cancel.

## Advanced calls

Use `$vzaps->request()` when you need an operation not yet wrapped by a resource:

```php theme={null}
$response = $vzaps->request('POST', '/instances/get', ['id' => 'VZ...']);
```

For the full HTTP contract, use the [API](/en/api-reference/introduction) tab.
