# Set channel as primary

> Set a channel as the primary channel for its type.

`POST https://api.zavu.dev/v1/contacts/{contactId}/channels/{channelId}/primary`

Set a channel as the primary channel for its type.

## Parameters

- `contactId` (path, string, required)
- `channelId` (path, string, required): Channel ID.

## Responses

### 200

Channel set as primary.

- `channel` (object, required): A communication channel for a 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>)

### 401

Unauthorized.

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

### 404

Contact or channel not found.

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

## Example

```bash
curl -X POST "https://api.zavu.dev/v1/contacts/contact_abc123/channels/channel_abc123/primary" \
  -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.channels.setPrimary("channel_abc123", {
  contactId: "contact_abc123",
});

console.log(result);
```
