Skip to content

Get Contact

Retrieve a single contact by phone number, chat ID, or LID.

Usage

You can use the Contact facade to get a contact.

php
use NjoguAmos\Waha\Facades\Contact;

$contact = Contact::get(contactId: '11231231231');
php
use NjoguAmos\Waha\Facades\Contact;

$contact = Contact::get(contactId: '[email protected]');
php
use NjoguAmos\Waha\Facades\Contact;

$contact = Contact::get(contactId: '123456@lid');
php
use NjoguAmos\Waha\Facades\Contact;

$contact = Contact::get(contactId: '11231231231', session: 'my-session');

Parameters

ParameterTypeRequiredDescription
contactIdstringYesPhone number, chat ID ([email protected]), or LID (123@lid)
sessionstringNoSession name (defaults to waha.session config)

Response

The response returned by the get method is an instance of Saloon\Http\Response. You may use the json method to retrieve the response as an array or the dtoOrFail method to retrieve a ContactData DTO:

php
/** @var \Saloon\Http\Response $response */

$response->status(); // 200
$response->json();   // ["id" => "[email protected]", "number" => "11231231231", ...]
php
use NjoguAmos\Waha\Facades\Contact;

/** @var \NjoguAmos\Waha\Dto\ContactData $contact */
$contact = Contact::get(contactId: '11231231231')->dtoOrFail();

$contact->id;          // "[email protected]"
$contact->number;      // "11231231231"
$contact->name;        // "Contact Name"
$contact->pushname;    // "Pushname"
$contact->shortName;   // "Shortname"
$contact->isMe;        // false
$contact->isGroup;     // false
$contact->isWAContact; // true
$contact->isMyContact; // true
$contact->isBlocked;   // false

Engines

WEBJSWPPNOWEBGOWS

References

Released under the MIT License.