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

# Contact Management

> Methods for retrieving and managing WhatsApp contacts in your application

## Overview

The Contact Management module provides functionality to retrieve, view, and manage WhatsApp contacts within your application. These methods allow you to access contact information, view profile pictures, and maintain an up-to-date contact list for your messaging needs.

## Available Methods

### Retrieve All Contacts

Get a complete list of all WhatsApp contacts available in your channel.

<Tabs>
  <Tab title="Basic Usage">
    ```php theme={null}
    use CrunchzApp\CrunchzApp;

    CrunchzApp::channel()
      ->allContact();
    ```
  </Tab>

  <Tab title="With Pagination">
    ```php theme={null}
    use CrunchzApp\CrunchzApp;

    CrunchzApp::channel()
      ->allContact(
        limit: 20,
        offset: 40
      );
    ```
  </Tab>
</Tabs>

<Note>
  The `allContact` method supports pagination to efficiently handle large contact lists. If not specified, default values are used (limit: 100, offset: 0).
</Note>

### Get Contact Details

Retrieve detailed information about a specific contact.

<Tabs>
  <Tab title="Basic Usage">
    ```php theme={null}
    use CrunchzApp\CrunchzApp;

    CrunchzApp::channel()
      ->contact(
        contactId: 'xxx@c.us'
      )
      ->detail();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                                                         |
    | --------- | ------ | -------- | ------------------------------------------------------------------- |
    | contactId | string | Yes      | The WhatsApp contact ID in the format '[xxx@c.us](mailto:xxx@c.us)' |
  </Tab>
</Tabs>

<Warning>
  Contact details may vary depending on privacy settings and whether the contact is in your address book.
</Warning>

### Get Contact Profile Picture

Retrieve the profile picture of a specific contact.

<Tabs>
  <Tab title="Basic Usage">
    ```php theme={null}
    use CrunchzApp\CrunchzApp;

    CrunchzApp::channel()
      ->contact(
        contactId: 'xxx@c.us'
      )
      ->picture();
    ```
  </Tab>

  <Tab title="Parameters">
    | Parameter | Type   | Required | Description                                                         |
    | --------- | ------ | -------- | ------------------------------------------------------------------- |
    | contactId | string | Yes      | The WhatsApp contact ID in the format '[xxx@c.us](mailto:xxx@c.us)' |
  </Tab>
</Tabs>

<Note>
  If a contact doesn't have a profile picture set, a default placeholder image URL may be returned.
</Note>

## Common Use Cases

<AccordionGroup>
  <Accordion title="Building a Contact Directory">
    Use the `allContact` method to create a searchable directory of all your WhatsApp contacts, complete with profile pictures and contact details.
  </Accordion>

  <Accordion title="Contact Verification">
    Before sending messages, use the `detail` method to verify that a contact exists and is available on WhatsApp.
  </Accordion>

  <Accordion title="Personalized Messaging">
    Retrieve contact details to personalize your messages with the recipient's name or other information.
  </Accordion>

  <Accordion title="Profile Picture Display">
    Enhance your chat interface by displaying contact profile pictures alongside messages.
  </Accordion>
</AccordionGroup>

## Error Handling

<Tabs>
  <Tab title="Contact Not Found">
    ```json theme={null}
    {
      "success": false,
      "message": "Contact not found",
      "error_code": "CONTACT_NOT_FOUND"
    }
    ```
  </Tab>

  <Tab title="Invalid Contact ID">
    ```json theme={null}
    {
      "success": false,
      "message": "Invalid contact ID format",
      "error_code": "INVALID_CONTACT_ID"
    }
    ```
  </Tab>

  <Tab title="No Profile Picture">
    ```json theme={null}
    {
      "success": false,
      "message": "Contact has no profile picture",
      "error_code": "NO_PROFILE_PICTURE"
    }
    ```
  </Tab>
</Tabs>
