# Contacts

> Create, list, retrieve and update contacts via the Zavu TypeScript SDK. Manage profile metadata, channels and merge suggestions from your code.

Contacts are automatically created when you send messages. You can retrieve and update contact information.

## Get Contact

```typescript
const result = await client.contacts.retrieve({
  contactId: "con_abc123",
});

console.log(result.id);
console.log(result.phoneNumber);
console.log(result.countryCode);
console.log(result.availableChannels);
console.log(result.defaultChannel);
```

## Get Contact by Phone

```typescript
const result = await client.contacts.retrieveByPhone({
  phoneNumber: "+14155551234",
});

console.log(result.id);
console.log(result.availableChannels); // ["sms", "whatsapp"]
```

## Update Contact

```typescript
const result = await client.contacts.update({
  contactId: "con_abc123",
  defaultChannel: "whatsapp",
  metadata: {
    name: "John Doe",
    tier: "premium",
  },
});
```

## List Contacts

```typescript
const result = await client.contacts.list({
  limit: 50,
});

for (const contact of result.items) {
  console.log(contact.id, contact.phoneNumber);
}

// Filter by phone number
const result = await client.contacts.list({
  phoneNumber: "+1415",
});

// Pagination
let cursor: string | undefined;
do {
  const result = await client.contacts.list({ cursor, limit: 50 });
  for (const contact of result.items) {
    console.log(contact.id);
  }
  cursor = result.nextCursor ?? undefined;
} while (cursor);
```

## Phone Introspection

Validate a phone number and check available channels:

```typescript
const result = await client.introspect.validatePhone({
  phoneNumber: "+14155551234",
});

console.log(result.validNumber); // true
console.log(result.countryCode); // "US"
console.log(result.nationalFormat); // "(415) 555-1234"
console.log(result.lineType); // "mobile"
console.log(result.availableChannels); // ["sms", "whatsapp"]
console.log(result.carrier?.name); // "Verizon Wireless"
```
