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

Common fields on instance calls:

| Field           | Type     | Required | Description                                 |
| --------------- | -------- | -------- | ------------------------------------------- |
| `InstanceID`    | `string` | Yes      | Instance ID (path or struct field).         |
| `InstanceToken` | `string` | Yes      | Instance token (`X-Instance-Token` header). |

All resource methods accept a `context.Context` as the first argument.

## Auth

### `Auth.GetAccessToken(ctx)`

Gets a JWT with `ClientToken` and `ClientSecret`. In most flows, resources do this automatically.

```go theme={null}
token, err := client.Auth.GetAccessToken(ctx)
fmt.Println(token[:16])
```

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

## Instances and billing

### `Instances.Create(ctx, req)`

```go theme={null}
created, err := client.Instances.Create(ctx, vzaps.InstanceCreateRequest{
	Name:            "Support",
	Webhook:         "https://example.com/webhooks/vzaps",
	EventsSubscribe: []string{"Message", "Connected", "Disconnected"},
})
```

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

### `Instances.List(ctx, req)`

```go theme={null}
instances, err := client.Instances.List(ctx, vzaps.InstanceListRequest{
	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(ctx, instanceID)`

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

```go theme={null}
instance, err := client.Instances.Get(ctx, "VZ...")
```

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

### `Instances.Update(ctx, instanceID, body, options)`

```go theme={null}
_, err := client.Instances.Update(ctx, "VZ...", map[string]any{
	"name": "Commercial Support",
}, vzaps.InstanceOptions{
	InstanceToken: "instance-token",
})
```

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

### `Instances.Restart(ctx, instanceID, options)`

```go theme={null}
_, err := client.Instances.Restart(ctx, "VZ...", vzaps.InstanceOptions{
	InstanceToken: "instance-token",
})
```

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

### `Instances.Delete(ctx, instanceID, options)`

```go theme={null}
_, err := client.Instances.Delete(ctx, "VZ...", vzaps.InstanceOptions{
	InstanceToken: "instance-token",
})
```

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

### `Instances.Subscribe(ctx, instanceID, body, options)`

```go theme={null}
checkout, err := client.Instances.Subscribe(ctx, "VZ...", nil, vzaps.InstanceOptions{
	InstanceToken: "instance-token",
})
```

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

### `Instances.ResumeSubscription(ctx, instanceID, options)`

```go theme={null}
_, err := client.Instances.ResumeSubscription(ctx, "VZ...", vzaps.InstanceOptions{
	InstanceToken: "instance-token",
})
```

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

### `Instances.Cancel(ctx, instanceID, options)`

```go theme={null}
_, err := client.Instances.Cancel(ctx, "VZ...", vzaps.InstanceOptions{
	InstanceToken: "instance-token",
})
```

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

## Advanced calls

Use `client.Request()` when you need an operation not yet wrapped by a resource:

```go theme={null}
err := client.Request(ctx, method, path, vzaps.RequestOptions{}, &out)
```

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