> ## 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/typescript/session). For chats, see [Chats](/en/sdk/typescript/chats). For message sending, see [Messages](/en/sdk/typescript/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.

```ts theme={null}
const token = await vzaps.auth.getAccessToken();
console.log(token.slice(0, 16));
```

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

## Instances and billing

### `instances.create(data)`

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

**Return:** `InstancePublicCreateResponse` — `id`, `name`, `token`, `url`, `webhook`, `eventsSubscribe`, `status`, `createdAt`, `updatedAt`.

### `instances.list(data?)`

```ts theme={null}
const instances = await vzaps.instances.list({
  page: 1,
  pageSize: 20,
  search: 'support',
});
```

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

### `instances.get(instanceId, options?)`

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

```ts theme={null}
const instance = await vzaps.instances.get('VZ...');
```

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

### `instances.update(instanceId, data, options?)`

```ts theme={null}
await vzaps.instances.update('VZ...', {
  name: 'Commercial Support',
}, {
  instanceToken: 'instance-token',
});
```

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

### `instances.restart(instanceId, options?)`

```ts theme={null}
await vzaps.instances.restart('VZ...', {
  instanceToken: 'instance-token',
});
```

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

### `instances.delete(instanceId, options?)`

```ts theme={null}
await vzaps.instances.delete('VZ...', {
  instanceToken: 'instance-token',
});
```

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

### `instances.subscribe(instanceId, data?, options?)`

```ts theme={null}
const checkout = await vzaps.instances.subscribe('VZ...', {}, {
  instanceToken: 'instance-token',
});
```

**Return:** `BillingHostedSession` — `url`, `sessionId`, `mode` (`direct` or checkout), `subscriptionId`.

### `instances.resumeSubscription(instanceId, options?)`

```ts theme={null}
await vzaps.instances.resumeSubscription('VZ...', {
  instanceToken: 'instance-token',
});
```

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

### `instances.cancel(instanceId, options?)`

```ts theme={null}
await vzaps.instances.cancel('VZ...', {
  instanceToken: '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:

```ts theme={null}
await vzaps.request(method, path, options);
```

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