Get Contact
Copy
Ask AI
$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
Copy
Ask AI
$result = $client->contacts->getByPhone([
'phoneNumber' => '+14155551234',
]);
echo $result->id . "\n";
echo implode(', ', $result->availableChannels) . "\n"; // ["sms", "whatsapp"]
Create Contact
Copy
Ask AI
$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
Copy
Ask AI
$result = $client->contacts->update([
'contactId' => 'con_abc123',
'defaultChannel' => 'whatsapp',
'metadata' => [
'name' => 'John Doe',
'tier' => 'premium',
],
]);
List Contacts
Copy
Ask AI
$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
Copy
Ask AI
$result = $client->contacts->addChannel([
'contactId' => 'con_abc123',
'channel' => 'email',
'identifier' => 'john.work@company.com',
'label' => 'work',
]);
echo $result->channel->id . "\n";
Update Channel
Copy
Ask AI
$result = $client->contacts->updateChannel([
'contactId' => 'con_abc123',
'channelId' => 'ch_xyz789',
'label' => 'personal',
'verified' => true,
]);
Set Channel as Primary
Copy
Ask AI
$result = $client->contacts->setPrimaryChannel([
'contactId' => 'con_abc123',
'channelId' => 'ch_xyz789',
]);
Remove Channel
Copy
Ask AI
$client->contacts->removeChannel([
'contactId' => 'con_abc123',
'channelId' => 'ch_xyz789',
]);
You cannot remove the last channel from a contact.
Merge Contacts
Copy
Ask AI
$result = $client->contacts->merge([
'contactId' => 'con_abc123',
'sourceContactId' => 'con_xyz789',
]);
echo $result->id . "\n"; // merged contact
Dismiss Merge Suggestion
Copy
Ask AI
$client->contacts->dismissMergeSuggestion([
'contactId' => 'con_abc123',
]);
Phone Introspection
Validate a phone number and check available channels:Copy
Ask AI
$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"
