---
title: "Utilities"
description: "Use message builders, pagination helpers, errors, and the low-level typed API client."
---

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

# Utilities

## Message builders

```ts
import {
  audioMessage,
  buttonsMessage,
  documentMessage,
  imageMessage,
  listMessage,
  locationMessage,
  templateMessage,
  textMessage,
  videoMessage,
} from "@wazapin/sdk";
```

Builders return typed `SendMessageInput` objects for `wazapin.messages.send()`.

## Pagination helpers

Resources with `listPaginated()` yield items one at a time.

```ts
for await (const channel of wazapin.channels.listPaginated({ limit: 50 })) {
  console.log(channel.id);
}
```

Available today on:

- `channels`
- `contacts`
- `templates`

## Error handling

Methods return `{ data, error }` and do not throw on API errors. Check `error` in production code — the quickstart examples skip this to stay short.

```ts
const { data, error } = await wazapin.messages.send(input);

if (error) {
  // error.status, error.code, error.message
  return;
}

console.log(data.id);
```

## Idempotency

Pass an idempotency key when sending messages you may retry.

```ts
await wazapin.messages.send(input, {
  idempotencyKey: "order-123-confirmation",
});
```

## Low-level typed API client

Use `client.api` for advanced OpenAPI-typed endpoints that are not wrapped by a resource yet.

```ts
const { data: version } = await wazapin.api.GET("/v1/version");

console.log(version.data.version);
```

Source: https://docs.wazapin.id/sdk/utilities/index.mdx
