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

Get Contact

$result = $client->contacts->get([
    'contactId' => 'con_abc123',
]);

echo $result->id . "\n";
echo $result->phoneNumber . "\n";
echo $result->countryCode . "\n";
echo implode(', ', $result->availableChannels) . "\n";
echo $result->defaultChannel . "\n";

Get Contact by Phone

$result = $client->contacts->getByPhone([
    'phoneNumber' => '+14155551234',
]);

echo $result->id . "\n";
echo implode(', ', $result->availableChannels) . "\n"; // ["sms", "whatsapp"]

Create Contact

$result = $client->contacts->create([
    'displayName' => 'John Doe',
    'channels' => [
        [
            'channel' => 'sms',
            'identifier' => '+14155551234',
            'isPrimary' => true,
        ],
        [
            'channel' => 'whatsapp',
            'identifier' => '+14155551234',
            'isPrimary' => true,
        ],
        [
            'channel' => 'email',
            'identifier' => 'john@example.com',
            'isPrimary' => true,
        ],
    ],
    'metadata' => [
        'source' => 'import',
    ],
]);

echo $result->id . "\n";
echo $result->displayName . "\n";

Update Contact

$result = $client->contacts->update([
    'contactId' => 'con_abc123',
    'defaultChannel' => 'whatsapp',
    'metadata' => [
        'name' => 'John Doe',
        'tier' => 'premium',
    ],
]);

List Contacts

$result = $client->contacts->list([
    'limit' => 50,
]);

foreach ($result->items as $contact) {
    echo $contact->id . " " . $contact->phoneNumber . "\n";
}

// Filter by phone number
$result = $client->contacts->list([
    'phoneNumber' => '+1415',
]);

// Pagination
$cursor = null;
do {
    $result = $client->contacts->list(['cursor' => $cursor, 'limit' => 50]);
    foreach ($result->items as $contact) {
        echo $contact->id . "\n";
    }
    $cursor = $result->nextCursor;
} while ($cursor !== null);

Add Channel to Contact

$result = $client->contacts->addChannel([
    'contactId' => 'con_abc123',
    'channel' => 'email',
    'identifier' => 'john.work@company.com',
    'label' => 'work',
]);

echo $result->channel->id . "\n";

Update Channel

$result = $client->contacts->updateChannel([
    'contactId' => 'con_abc123',
    'channelId' => 'ch_xyz789',
    'label' => 'personal',
    'verified' => true,
]);

Set Channel as Primary

$result = $client->contacts->setPrimaryChannel([
    'contactId' => 'con_abc123',
    'channelId' => 'ch_xyz789',
]);

Remove Channel

$client->contacts->removeChannel([
    'contactId' => 'con_abc123',
    'channelId' => 'ch_xyz789',
]);
You cannot remove the last channel from a contact.

Merge Contacts

$result = $client->contacts->merge([
    'contactId' => 'con_abc123',
    'sourceContactId' => 'con_xyz789',
]);

echo $result->id . "\n"; // merged contact

Dismiss Merge Suggestion

$client->contacts->dismissMergeSuggestion([
    'contactId' => 'con_abc123',
]);

Phone Introspection

Validate a phone number and check available channels:
$result = $client->introspect->phone([
    'phoneNumber' => '+14155551234',
]);

echo $result->validNumber . "\n"; // true
echo $result->countryCode . "\n"; // "US"
echo $result->nationalFormat . "\n"; // "(415) 555-1234"
echo $result->lineType . "\n"; // "mobile"
echo implode(', ', $result->availableChannels) . "\n"; // ["sms", "whatsapp"]
echo $result->carrier?->name . "\n"; // "Verizon Wireless"