# List contacts

> List contacts with their communication channels.

`GET https://api.zavu.dev/v1/contacts`

List contacts with their communication channels.

## Parameters

- `phoneNumber` (query, string): Exact match on the contact's primary phone number, in E.164.
- `search` (query, string): Free-text match over the contact's name (`displayName` and the WhatsApp profile name), phone numbers and email addresses. Case- and accent-insensitive. A phone number matches on a trailing fragment too, so `5551234` finds `+14155551234`. Contacts created automatically from an inbound message have no `displayName` — they are matched by their identifier until you set one with `PATCH /v1/contacts/{contactId}`. Results come back in relevance order rather than newest-first. `cursor` is opaque in both modes; pass back exactly what the previous response returned, and start a new pagination run when the search term changes.
- `bsuid` (query, string): Exact WhatsApp business-scoped user ID (e.g. `CO.13491208655302741918`). Returns the contact that holds it, or an empty list. Combines with `phoneNumber` and `tag` as a filter, and cannot be combined with `search` (400). A value that is not shaped like a BSUID returns 400.
- `tag` (query, string[]): Tag name. Repeatable: `?tag=vip&tag=chile` returns contacts carrying **every** tag given, not any of them — the same rule the dashboard filter applies. Tags are matched by name, case-insensitively. An unknown tag returns 400 rather than being ignored, because a typo that silently matched every contact would be a worse answer than an error.
- `limit` (query, integer)
- `cursor` (query, string): Opaque cursor from a previous response's `nextCursor`. Do not construct it.

## Responses

### 200

List of contacts.

- `items` (object[], required)
  - `id` (string, required)
  - `displayName` (string): Display name for the contact.
  - `phoneNumber` (string): DEPRECATED: Use primaryPhone instead. Primary phone number in E.164 format.
  - `primaryPhone` (string): Primary phone number in E.164 format.
  - `primaryEmail` (string<email>): Primary email address.
  - `countryCode` (string)
  - `profileName` (string, nullable): Contact's WhatsApp profile name. Only available for WhatsApp contacts.
  - `whatsapp` (object): WhatsApp identity. Present when Zavu has a business-scoped user ID (BSUID) for the contact, and absent otherwise. A contact with a username can be reached under its BSUID, its phone number, or both; they are the same contact. Look one up by BSUID with the `bsuid` query parameter of the list endpoint.
    - `bsuid` (string, required): Business-scoped user ID. Can be used as `to` when sending.
    - `username` (string): The WhatsApp username, when Meta reported one.
  - `availableChannels` (string[], required): List of available messaging channels for this contact.
  - `defaultChannel` (string): Preferred channel for this contact. One of: `sms`, `whatsapp`, `telegram`, `email`, `instagram`, `messenger`, `voice`.
  - `verified` (boolean, required): Whether this contact has been verified.
  - `channels` (object[]): All communication channels for this contact.
    - `id` (string, required)
    - `channel` (string, required): Channel type. One of: `sms`, `whatsapp`, `email`, `telegram`, `instagram`, `messenger`, `voice`.
    - `identifier` (string, required): Channel identifier (phone number or email address).
    - `countryCode` (string): ISO country code for phone numbers.
    - `label` (string): Optional label for the channel.
    - `isPrimary` (boolean, required): Whether this is the primary channel for its type.
    - `verified` (boolean, required): Whether this channel has been verified.
    - `metrics` (object): Delivery metrics for this channel.
      - `successCount` (integer)
      - `failureCount` (integer)
      - `totalAttempts` (integer)
      - `avgDeliveryTimeMs` (number)
      - `lastSuccessAt` (string<date-time>)
    - `lastInboundAt` (string<date-time>): Last time a message was received on this channel.
    - `metadata` (object)
      - `{key}` (string)
    - `createdAt` (string<date-time>, required)
    - `updatedAt` (string<date-time>)
  - `metadata` (object, required)
    - `{key}` (string)
  - `createdAt` (string<date-time>, required)
  - `updatedAt` (string<date-time>)
- `nextCursor` (string, nullable)

### 400

Invalid query parameters (`invalid_request`): `limit` outside 1-100, a malformed cursor, or a `tag` that names no tag in this project — `details.unknownTags` lists them.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

### 401

Unauthorized.

- `code` (string, required)
- `message` (string, required)
- `details` (object)

## Example

```bash
curl -X GET "https://api.zavu.dev/v1/contacts?search=marta&bsuid=CO.13491208655302741918&tag=vip" \
  -H "Authorization: Bearer $ZAVUDEV_API_KEY"
```

```typescript
import Zavudev from "@zavudev/sdk";

const zavu = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY });

const result = await zavu.contacts.list({
  search: "marta",
  bsuid: "CO.13491208655302741918",
  tag: [
    "vip",
  ],
});

console.log(result);
```
