gohighlevel-php-sdk

Contact Resource

Contact

The Contact class is the central resource for managing contacts within GoHighLevel. It offers a wide range of methods to perform CRUD operations on contacts and provides access to related sub-resources like appointments, tags, notes, and workflows.


get(string $contactId): string|array

Retrieves a single contact by their ID. This method corresponds to the GoHighLevel API’s GET /contacts/{contactId} endpoint.


update(string $contactId, array $params): string|array

Updates an existing contact’s details. This method corresponds to the PUT /contacts/{contactId} endpoint.


delete(string $contactId): array|string

Deletes a contact from the platform. This method corresponds to the DELETE /contacts/{contactId} endpoint.


upsert(array $params): array|string

Creates a new contact or updates an existing one if a matching contact is found. This method corresponds to the POST /contacts/upsert endpoint.


byBusiness(string $businessId): string|array

Retrieves a list of contacts belonging to a specific business. Note that this method’s implementation seems to be using locationId as the parameter name, which should be aligned with the GoHighLevel API documentation.


create(array $params): array|string

Creates a new contact. This method corresponds to the POST /contacts/ endpoint.


list(string $locationId): string|array

Retrieves a list of all contacts within a specific location. This method corresponds to the GET /contacts/ endpoint.


tasks(): TaskContract

Returns a resource object for managing contact-specific tasks.


appointments(): AppointmentContract

Returns a resource object for managing contact appointments.


tags(): TagContract

Returns a resource object for managing contact tags.


notes(): NoteContract

Returns a resource object for managing contact notes.


campaign(): CampaignContract

Returns a resource object for managing contact campaigns.


workflow(): WorkflowContract

Returns a resource object for managing contact workflows.


bulk(string $locationId, array $ids, string $businessId): array|string

A helper method to bulk-add or remove contacts from a business. This method internally uses the Bulk resource.


search(): SearchContract

Returns a resource object for searching contacts and managing duplicates.


followers(): FollowerContract

Returns a resource object for managing contact followers.


Appointment

The Appointment class provides methods to retrieve a list of appointments associated with a specific contact. This is a sub-resource of the Contact class.


contacts(string $contactId): string|array

Retrieves a list of all appointments for a given contact. This method corresponds to the GET /contacts/{contactId}/appointments endpoint.


Bulk

The Bulk class contains methods for performing bulk operations on contacts, specifically for adding or removing them from a business. This is a sub-resource of the Contact class.


addOrRemove(string $locationId, array $ids, string $businessId): array|string

Adds a list of contacts to a business or removes them if they are already associated. This method corresponds to the POST /contacts/bulk/business endpoint.


Campaign

The Campaign class provides methods for managing a contact’s enrollment in marketing campaigns. This is a sub-resource of the Contact class.


create(string $contactId, string $campaignId): string|array

Adds a contact to a specific campaign. Note: This method is an alias for the add method. It corresponds to the POST /contacts/{contactId}/campaigns endpoint.


add(string $contactId, string $campaignId): string|array

Adds a contact to a specific campaign. This is the primary method for this operation. It corresponds to the POST /contacts/{contactId}/campaigns endpoint.


removeContact(string $contactId, string $campaignId): string|array

Removes a contact from a specific campaign. This method corresponds to the DELETE /contacts/{contactId}/campaigns/{campaignId} endpoint.


removeContactFromAll(string $contactId): string|array

Removes a contact from all campaigns they are currently enrolled in. This method corresponds to the DELETE /contacts/{contactId}/campaigns/removeAll endpoint.


Follower

The Follower class is a sub-resource of Contact that manages the users following a specific contact.


add(string $contactId, array $followers): string|array

Adds one or more users as followers to a contact. This method corresponds to the POST /contacts/{contactId}/followers endpoint.


create(string $contactId, array $followers): string|array

This method is an alias for add, performing the same action of adding followers to a contact.


delete(string $contactId): string|array

Removes all followers from a contact. This method corresponds to the DELETE /contacts/{contactId}/followers endpoint.


Note

The Note class provides methods for managing notes associated with a specific contact. This is a sub-resource of the Contact class.


list(string $contactId): string|array

Retrieves all notes for a given contact. This method corresponds to the GET /contacts/{contactId}/notes endpoint.


create(string $contactId, string $userId, string $body): string|array

Creates a new note for a contact. This method corresponds to the POST /contacts/{contactId}/notes endpoint.


get(string $contactId, string $id): string|array

Retrieves a specific note by its ID for a given contact. This method corresponds to the GET /contacts/{contactId}/notes/{id} endpoint.


update(string $contactId, string $id, string $userId, string $body): string|array

Updates an existing note. This method corresponds to the PUT /contacts/{contactId}/notes/{id} endpoint. Note: The provided method implementation doesn’t include the $userId and $body in the payload, which is required by the API.


delete(string $contactId, string $id): array|string

Deletes a specific note. This method corresponds to the DELETE /contacts/{contactId}/notes/{id} endpoint.


The Search class, a sub-resource of Contact, provides methods for searching for contacts and finding duplicates.


query(array $params): array|string

Performs a search for contacts based on various criteria. This method corresponds to the POST /contacts/search/ endpoint.


getDuplicate(string $locationId, $parameters = []): array|string

Finds and retrieves duplicate contacts within a specified location. This method corresponds to the GET /contacts/search/duplicate endpoint.


Tag

The Tag class, a sub-resource of Contact, provides methods for managing a contact’s tags.


create(string $contactId, array|string $tags): string|array

Adds one or more tags to a contact. This method corresponds to the POST /contacts/{contactId}/tags endpoint.


remove(string $contactId): array|string

Removes all tags from a contact. This method corresponds to the DELETE /contacts/{contactId}/tags endpoint.


delete(string $id): array|string

This method is an alias for remove, with the $id parameter representing the contact ID.


Task

The Task class, a sub-resource of Contact, provides methods for managing tasks associated with a contact.


list(string $contactId): string|array

Retrieves a list of all tasks for a given contact. This method corresponds to the GET /contacts/{contactId}/tasks endpoint.


create(string $contactId, array $params): string|array

Creates a new task for a contact. This method corresponds to the POST /contacts/{contactId}/tasks endpoint.


get(string $contactId, string $taskId): string|array

Retrieves a specific task for a contact by its ID. This method corresponds to the GET /contacts/{contactId}/tasks/{taskId} endpoint.


update(string $contactId, string $taskId, array $params): string|array

Updates an existing task for a contact. This method corresponds to the PUT /contacts/{contactId}/tasks/{taskId} endpoint.


delete(string $contactId, string $taskId): string|array

Deletes a task for a contact. This method corresponds to the DELETE /contacts/{contactId}/tasks/{taskId} endpoint.


completed(string $contactId, string $taskId, bool $completed): string|array

Marks a task as completed or uncompleted. This method corresponds to the PUT /contacts/{contactId}/tasks/{taskId}/completed endpoint.


Workflow

The Workflow class, a sub-resource of Contact, provides methods for managing a contact’s enrollment in workflows.


create(string $contactId, string $workflowId, string $eventStartTime): string|array

Adds a contact to a specific workflow. This method is an alias for add. It corresponds to the POST /contacts/{contactId}/workflow/{workflowId} endpoint.


add(string $contactId, string $workflowId, string $eventStartTime): string|array

Adds a contact to a specific workflow. This is the primary method for this operation. It corresponds to the POST /contacts/{contactId}/workflow/{workflowId} endpoint.


delete(string $contactId, string $workflowId): string|array

Removes a contact from a specific workflow. This method corresponds to the DELETE /contacts/{contactId}/workflow/{workflowId} endpoint.