> ## 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 Java SDK

Use `client.instances()` and `client.auth()` for account authentication, instance lifecycle, and billing.

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

Pass `InstanceRequestOptions` with `instanceToken` on instance-scoped routes.

## Auth

### `client.auth().getAccessToken()`

```java theme={null}
String token = client.auth().getAccessToken();
System.out.println(token.substring(0, Math.min(16, token.length())));
```

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

## Instances and billing

### `client.instances().create(request)`

```java theme={null}
JsonNode created = client.instances().create(
    InstanceCreateRequest.builder()
        .name("Support")
        .webhook("https://example.com/webhooks/vzaps")
        .eventsSubscribe(List.of("Message", "Connected", "Disconnected"))
        .build());
```

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

### `client.instances().list(request)`

```java theme={null}
JsonNode instances = client.instances().list(
    InstanceListRequest.builder().page(1).pageSize(20).search("support").build());
```

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

### `client.instances().get(instanceId)`

```java theme={null}
JsonNode instance = client.instances().get("VZ...");
```

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

### `client.instances().update(instanceId, body, options)`

```java theme={null}
client.instances().update(
    "VZ...",
    Map.of("name", "Commercial Support"),
    InstanceRequestOptions.builder().instanceToken("instance-token").build());
```

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

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

```java theme={null}
client.instances().restart(
    "VZ...",
    InstanceRequestOptions.builder().instanceToken("instance-token").build());
```

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

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

```java theme={null}
client.instances().delete(
    "VZ...",
    InstanceRequestOptions.builder().instanceToken("instance-token").build());
```

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

### `client.instances().subscribe(instanceId, body, options)`

```java theme={null}
JsonNode checkout = client.instances().subscribe(
    "VZ...",
    Map.of(),
    InstanceRequestOptions.builder().instanceToken("instance-token").build());
```

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

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

```java theme={null}
client.instances().resumeSubscription(
    "VZ...",
    InstanceRequestOptions.builder().instanceToken("instance-token").build());
```

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

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

```java theme={null}
client.instances().cancel(
    "VZ...",
    InstanceRequestOptions.builder().instanceToken("instance-token").build());
```

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

## Advanced calls

For stricter typing, use `client.request(..., MyDto.class)` or published DTOs such as `SessionStatusResponse`.

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