### Install DeskPRO PHP SDK via Composer Source: https://github.com/deskpro/deskpro-api-php/blob/master/README.md Install the DeskPRO PHP SDK using Composer by running the require command. This is the recommended method for managing dependencies. ```bash $ php composer.phar require deskpro/deskpro-api-php dev-master ``` -------------------------------- ### Get Notes for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves all notes associated with a person. ```php $result = $api->people->getNotes($personId); ``` -------------------------------- ### Get Labels for an Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve all labels currently applied to an organization. ```php $result = $api->organization->getLabels($organizationId); ``` -------------------------------- ### Get Available Groups Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of all available user groups. ```APIDOC ## Get Available Groups ### Description Gets a list of available user groups. ### Method GET ### Endpoint `/groups` (assumed) ### Response #### Success Response (200 OK) - **groups** (array) - A list of available group definitions. #### Response Example ```json { "groups": [ { "id": "group_xyz", "name": "Team Alpha" }, { "id": "group_abc", "name": "Support Team" } ] } ``` ``` -------------------------------- ### Get Groups for an Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve a list of all groups to which the organization belongs. ```php $result = $api->organization->getGroupsByOrganization($organizationId); ``` -------------------------------- ### Get Available User Groups Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Fetches a list of all available user groups within the system. ```php $result = $api->people->getGroups(); ``` -------------------------------- ### Get available user groups Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves a list of all available user groups. ```APIDOC ## Get Available User Groups ### Description Gets a list of available user groups. ### Method `getGroups` ### Request Example ```php $result = $api->organization->getGroups(); ``` ### Response Returns a list of available user groups. ``` -------------------------------- ### Get Person Labels Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves all labels associated with a person. ```APIDOC ## Get Person Labels ### Description Gets all labels associated with a person. ### Method GET ### Endpoint `/people/{personId}/labels` (assumed) ### Parameters #### Path Parameters - **personId** (string) - Required - The ID of the person. ### Response #### Success Response (200 OK) - **labels** (array) - A list of labels associated with the person. #### Response Example ```json { "labels": [ "VIP", "Customer" ] } ``` ``` -------------------------------- ### Gets notes for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves all notes associated with a specific person. ```APIDOC ## Get Person Notes ### Description Retrieves notes associated with a person. ### Method ``` $result = $api->people->getNotes($personId); ``` ``` -------------------------------- ### Include DeskPRO API PHP File Source: https://github.com/deskpro/deskpro-api-php/blob/master/README.md Include the main SDK file in your project to start using the API. ```php require 'deskpro-api.php'; ``` -------------------------------- ### Get Available User Groups Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Fetch a list of all user groups that can be assigned to organizations or users. ```php $result = $api->organization->getGroups(); ``` -------------------------------- ### Get Contact Details for Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves all contact details for a given person. ```APIDOC ## Get Contact Details for Person ### Description Gets all contact details for a person. ### Method GET ### Endpoint `/people/{personId}/contacts` (assumed) ### Parameters #### Path Parameters - **personId** (string) - Required - The ID of the person whose contact details to retrieve. ### Response #### Success Response (200 OK) - **contacts** (array) - A list of contact details. #### Response Example ```json { "contacts": [ { "type": "email", "value": "test@example.com" }, { "type": "phone", "value": "123-456-7890" } ] } ``` ``` -------------------------------- ### Get Automatically Applied SLAs for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of all SLAs that are automatically applied to a specific person. ```php $result = $api->people->getSlas($personId); ``` -------------------------------- ### Get all news categories Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve a list of all available news categories. ```APIDOC ## Get Categories ### Description Retrieves a list of all news categories configured in the system. ### Method `getCategories` ### Request Example ```php $result = $api->news->getCategories(); ``` ``` -------------------------------- ### Get labels for an organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves all labels associated with an organization. ```APIDOC ## Get Organization Labels ### Description Gets all labels associated with an organization. ### Method `getLabels` ### Parameters - **organizationId** (int): The unique identifier of the organization. ### Request Example ```php $result = $api->organization->getLabels($organizationId); ``` ### Response Returns a list of labels associated with the organization. ``` -------------------------------- ### Get SLAs for an Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve a list of all Service Level Agreements (SLAs) associated with a specific organization. ```php $result = $api->organization->getSlas($organizationId); ``` -------------------------------- ### Get Custom Organization Fields Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve a list of all available custom fields that can be applied to organizations. ```php $result = $api->organization->getFields(); ``` -------------------------------- ### Get Organization Activity Stream Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves the activity stream for a given organization. Supports pagination. ```php $page = 2; // Page number of the result set $result = $api->organization->getOrganizationActivityStream($organizationId, $page); ``` -------------------------------- ### Get All Emails for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of all email addresses associated with a person. ```php $result = $api->people->getEmails($personId); ``` -------------------------------- ### Get Person Groups Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves the list of groups a person belongs to. ```APIDOC ## Get Person Groups ### Description Gets the list of groups that the person belongs to. ### Method GET ### Endpoint `/people/{personId}/groups` (assumed) ### Parameters #### Path Parameters - **personId** (string) - Required - The ID of the person. ### Response #### Success Response (200 OK) - **groups** (array) - A list of groups the person belongs to. #### Response Example ```json { "groups": [ { "id": "group_xyz", "name": "Team Alpha" } ] } ``` ``` -------------------------------- ### Get Organization by ID Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve detailed information about a specific organization using its unique identifier. ```php $result = $api->organization->findById($organizationId); ``` -------------------------------- ### Get Contact Details for an Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve all contact details associated with a given organization. ```php $result = $api->organization->getContactDetails($organizationId); ``` -------------------------------- ### Get Person by ID Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves information about a specific person using their unique ID. ```php $result = $api->people->findById(16); ``` -------------------------------- ### Get Organization Billing Charges Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves billing charges for a specific organization. Supports pagination. ```php $page = 2; // Page number of the result set $result = $api->organization->getOrganizationBillingCharges($organizationId, $page); ``` -------------------------------- ### Get SLAs for an organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves all Service Level Agreements (SLAs) associated with an organization. ```APIDOC ## Get Organization SLAs ### Description Gets all SLAs for an organization. ### Method `getSlas` ### Parameters - **organizationId** (int): The unique identifier of the organization. ### Request Example ```php $result = $api->organization->getSlas($organizationId); ``` ### Response Returns a list of SLAs associated with the organization. ``` -------------------------------- ### Gets all emails for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of all email addresses associated with a person. ```APIDOC ## Get Person Emails ### Description Retrieves all email addresses associated with a person. ### Method ``` $result = $api->people->getEmails($personId); ``` ``` -------------------------------- ### Get groups for an organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves the list of groups that an organization belongs to. ```APIDOC ## Get Organization Groups ### Description Gets the list of groups that the organization belongs to. ### Method `getGroupsByOrganization` ### Parameters - **organizationId** (int): The unique identifier of the organization. ### Request Example ```php $result = $api->organization->getGroupsByOrganization($organizationId); ``` ### Response Returns a list of groups the organization is a member of. ``` -------------------------------- ### Get Activity Stream for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves the activity stream entries for a person. You can specify the page number. ```php $page = 2; // Page number of the result set $result = $api->people->getActivityStream($personId, $page = 1); ``` -------------------------------- ### Gets a list of automatically applied SLAs for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves all Service Level Agreements (SLAs) that are automatically applied to a specific person. ```APIDOC ## Get Person SLAs ### Description Retrieves a list of automatically applied SLAs for a person. ### Method ``` $result = $api->people->getSlas($personId); ``` ``` -------------------------------- ### Get Person Labels Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves all labels currently associated with a person. Requires the person ID. ```php $result = $api->people->getPersonLabels($personId); ``` -------------------------------- ### Add Skype Account to Organization using ContactData Builder Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/ContactData.md This example shows how to add a Skype username to an organization's contact details. Ensure the organization editor and ContactData object are set up. ```php $organizationBuilder = $api->organization->createOrganizationEditor(); $contactData = new DeskPRO\Builder\ContactData(); $skypeUsername = 'deskpro'; $comment = 'Added by API'; $contactData->addSkype($skypeUsername, $comment); $organizationBuilder->setId($organizationId)->addContactData($contactData); $result = $api->organization->save($organizationBuilder); ``` -------------------------------- ### Get Billing Charges for Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves the billing charges associated with a specific person. ```APIDOC ## Get Billing Charges for Person ### Description Gets billing charges for a person. ### Method GET ### Endpoint `/people/{personId}/billing-charges` (assumed) ### Parameters #### Path Parameters - **personId** (string) - Required - The ID of the person whose billing charges to retrieve. #### Query Parameters - **page** (integer) - Optional - The page number of the result set. ### Response #### Success Response (200 OK) - **charges** (array) - A list of billing charges. - **pagination** (object) - Pagination details for the results. #### Response Example ```json { "charges": [ { "id": "charge_abc", "amount": 100.50, "date": "2023-10-27" } ], "pagination": { "currentPage": 2, "totalPages": 5 } } ``` ``` -------------------------------- ### Get List of News Categories (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Fetch all available news categories. This is useful for understanding the category structure or for populating dropdowns. ```php $result = $api->news->getCategories(); ``` -------------------------------- ### Get validating comments Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve a list of comments that are awaiting validation. ```APIDOC ## Get Validating Comments ### Description Retrieves a list of all comments that are currently awaiting moderation or validation. ### Method `getValidatingComments` ### Request Example ```php $result = $api->news->getValidatingComments(); ``` ``` -------------------------------- ### Get Custom People Fields Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of custom fields available for people. ```APIDOC ## Get Custom People Fields ### Description Gets a list of custom people fields. ### Method GET ### Endpoint `/people/fields` (assumed) ### Response #### Success Response (200 OK) - **fields** (array) - A list of custom field definitions. #### Response Example ```json { "fields": [ { "id": "custom_field_1", "name": "Preferred Contact Method", "type": "dropdown" } ] } ``` ``` -------------------------------- ### Get tickets for an organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves a paginated list of tickets associated with an organization. ```APIDOC ## Get Organization Tickets ### Description Gets tickets for an organization with pagination. ### Method `getTickets` ### Parameters - **organizationId** (int): The unique identifier of the organization. - **page** (int, optional): The page number of the results to retrieve. Defaults to 1. ### Request Example ```php $page = 2; $result = $api->organization->getTickets($organizationId, $page); ``` ### Response Returns a paginated list of tickets associated with the organization. ``` -------------------------------- ### Get contact details for an organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves all contact details associated with an organization. ```APIDOC ## Get Organization Contact Details ### Description Gets all contact details for an organization. ### Method `getContactDetails` ### Parameters - **organizationId** (int): The unique identifier of the organization. ### Request Example ```php $result = $api->organization->getContactDetails($organizationId); ``` ### Response Returns a list of contact details for the organization. ``` -------------------------------- ### Get custom organization fields Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves a list of available custom fields for organizations. ```APIDOC ## Get Custom Organization Fields ### Description Gets a list of custom organization fields. ### Method `getFields` ### Request Example ```php $result = $api->organization->getFields(); ``` ### Response Returns a list of available custom fields. ``` -------------------------------- ### Get Contact Details for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Fetches all contact details for a given person. This includes various communication methods. ```php $result = $api->people->getContactDetails($personId); ``` -------------------------------- ### Get a news item category Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve details of a specific news category. ```APIDOC ## Get Category ### Description Retrieves information about a specific news category by its ID. ### Method `getCategory` ### Parameters #### Path Parameters - **categoryId** (int) - Required - The ID of the category. ### Request Example ```php $categoryId = 1; $result = $api->news->getCategory($categoryId); ``` ``` -------------------------------- ### Get Specific Contact Detail for Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a specific contact detail for a person. ```APIDOC ## Get Specific Contact Detail for Person ### Description Determines if a particular contact ID exists for a person. ### Method GET ### Endpoint `/people/{personId}/contacts/{contactId}` (assumed) ### Parameters #### Path Parameters - **personId** (string) - Required - The ID of the person. - **contactId** (string) - Required - The ID of the contact detail. ### Response #### Success Response (200 OK) - **contactDetail** (object) - The specific contact detail. #### Response Example ```json { "contactDetail": { "type": "email", "value": "test@example.com" } } ``` ``` -------------------------------- ### Get Login Token for Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Generates a login token for a person, which can be used in web requests to log them in. ```APIDOC ## Get Login Token for Person ### Description Gets a login token that can be used in a web request to log a user in. ### Method POST (assumed) ### Endpoint `/people/{personId}/login-token` (assumed) ### Parameters #### Path Parameters - **personId** (string) - Required - The ID of the person for whom to generate the token. ### Response #### Success Response (200 OK) - **token** (string) - The generated login token. #### Response Example ```json { "token": "a_very_secure_login_token_string" } ``` ``` -------------------------------- ### Get Validating Comments (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve a list of all comments that are currently awaiting validation. ```php $result = $api->news->getValidatingComments(); ``` -------------------------------- ### Get Organization Billing Charges Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves billing charges for a specific organization. Supports pagination. ```APIDOC ## Get Organization Billing Charges ### Description Gets billing charges for an organization. ### Method GET (assumed) ### Endpoint /organizations/{organizationId}/billing-charges ### Parameters #### Path Parameters - **organizationId** (string) - Required - The ID of the organization. #### Query Parameters - **page** (integer) - Optional - The page number of the result set. ``` -------------------------------- ### Get organization by ID Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves detailed information about a specific organization using its ID. ```APIDOC ## Get Organization By ID ### Description Retrieves information about a specific organization. ### Method `findById` ### Parameters - **organizationId** (int): The unique identifier of the organization. ### Request Example ```php $result = $api->organization->findById($organizationId); ``` ### Response Returns the organization object with the specified ID. ``` -------------------------------- ### Get news in a category Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve all news articles belonging to a specific category. ```APIDOC ## Get Category Articles ### Description Retrieves a list of news articles that belong to a specific category. ### Method `getCategoryArticles` ### Parameters #### Path Parameters - **categoryId** (int) - Required - The ID of the category. - **page** (int) - Optional - The page number for pagination. ### Request Example ```php $categoryId = 1; $page = 1; $result = $api->news->getCategoryArticles($categoryId, $page); ``` ``` -------------------------------- ### Get All Labels for a News Item (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve a list of all labels associated with a particular news item, identified by its news ID. ```php $newsId = 4; $result = $api->news->getArticleLabels($newsId); ``` -------------------------------- ### Get a link to a person's profile picture Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a URL to a person's profile picture. ```APIDOC ## Get Person Picture ### Description Retrieves the URL for a person's profile picture. ### Method ``` $result = $api->people->getPersonPicture(16); ``` ``` -------------------------------- ### Get Tickets for an Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve a list of tickets associated with a specific organization. Pagination is supported. ```php $page = 2; // Page number of the result set ``` -------------------------------- ### Get news item by ID Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve detailed information about a specific news item. ```APIDOC ## Get News Item by ID ### Description Retrieves information for a specific news item using its unique ID. ### Method `findById` ### Parameters #### Path Parameters - **id** (int) - Required - The unique identifier of the news item. ### Request Example ```php $result = $api->news->findById(3); ``` ``` -------------------------------- ### Get Organization Activity Stream Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves the activity stream for a specific organization. Supports pagination. ```APIDOC ## Get Organization Activity Stream ### Description Gets activity stream for an organization. ### Method GET (assumed) ### Endpoint /organizations/{organizationId}/activity-stream ### Parameters #### Path Parameters - **organizationId** (string) - Required - The ID of the organization. #### Query Parameters - **page** (integer) - Optional - The page number of the result set. ``` -------------------------------- ### Get Login Token for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Generates a login token for a specific person, which can be used in web requests for authentication. ```php $result = $api->people->getLoginToken($personId); ``` -------------------------------- ### Get Groups Accessing a News Item Category (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Fetch all groups that have access permissions for a specific news item category. Requires the category ID. ```php $categoryId = 1; $result = $api->news->getCategoryGroups($categoryId); ``` -------------------------------- ### Gets activity stream for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves the activity stream entries for a specific person, with pagination support. ```APIDOC ## Get Person Activity Stream ### Description Retrieves the activity stream for a person. ### Method ``` $page = 2; // Page number of the result set $result = $api->people->getActivityStream($personId, $page = 1); ``` ``` -------------------------------- ### Get groups with access to a category Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md List all groups that have access permissions for a news category. ```APIDOC ## Get Category Groups ### Description Retrieves a list of all groups that have access to a specific news category. ### Method `getCategoryGroups` ### Parameters #### Path Parameters - **categoryId** (int) - Required - The ID of the news category. ### Request Example ```php $categoryId = 1; $result = $api->news->getCategoryGroups($categoryId); ``` ``` -------------------------------- ### Get organization profile picture link Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves a link to an organization's profile picture. ```APIDOC ## Get Organization Picture ### Description Gets a link to an organization's profile picture. ### Method `getPicture` ### Parameters - **organizationId** (int): The unique identifier of the organization. ### Request Example ```php $result = $api->organization->getPicture($organizationId); ``` ### Response Returns the URL of the organization's profile picture. ``` -------------------------------- ### Get Link to Person's Profile Picture Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a URL to a person's profile picture. ```php $result = $api->people->getPersonPicture(16); ``` -------------------------------- ### Get all labels associated with a news item Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve all labels applied to a specific news article. ```APIDOC ## Get Article Labels ### Description Retrieves all labels associated with a particular news article. ### Method `getArticleLabels` ### Parameters #### Path Parameters - **newsId** (int) - Required - The ID of the news article. ### Request Example ```php $newsId = 4; $result = $api->news->getArticleLabels($newsId); ``` ``` -------------------------------- ### Instantiate DeskPRO API Class Source: https://github.com/deskpro/deskpro-api-php/blob/master/README.md Create a new instance of the DeskPRO API class, providing your DeskPRO URL and API key. This is the entry point for making API requests. ```php $api = new \DeskPRO\Api('http://example.com/deskpro', '123:XYZ'); ``` -------------------------------- ### Get all comments on a news item Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve all comments associated with a specific news article. ```APIDOC ## Get Article Comments ### Description Retrieves all comments made on a specific news article. ### Method `getArticleComments` ### Parameters #### Path Parameters - **newsId** (int) - Required - The ID of the news article. ### Request Example ```php $result = $api->news->getArticleComments(4); ``` ``` -------------------------------- ### Get Organization Tickets Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves tickets associated with a specific organization. Supports pagination and caching. ```php $order = 'ticket.date_created:asc'; //Defaults to ticket.date_created:desc. $cacheId = '13579'; // the ID of the cache set to use to retrieve cached results $result = $api->organization->getOrganizationTickets($organizationId, $page, $order, $cacheId); ``` -------------------------------- ### Get Billing Charges for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves billing charges associated with a specific person. You can paginate the results by specifying the page number. ```php $page = 2; // page number of the result set $result = $api->people->getBillingCharges($personId, $page); ``` -------------------------------- ### Create a New Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md This snippet demonstrates how to create a new person record. You can set their name, email, organization, and password. The organization must be set using its ID. ```php $newUser = $api->people->createPersonEditor(); $newUser->setName("User5 with a Password") ->setEmail("anotheruser6@test.com") ->setOrganizationById($id) ->setPassword('password'); $result = $api->people->save($newUser); ``` -------------------------------- ### Get Organization Email Domains Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves email domains associated with an organization. Supports pagination. ```php $page = 2; // Page number of the result set $result = $api->organization->getOrganizationEmailDomains($organizationId); ``` -------------------------------- ### Get Organization Profile Picture Link Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve the URL for an organization's profile picture using its ID. ```php $result = $api->organization->getPicture($organizationId); ``` -------------------------------- ### Create a New Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Instantiate an organization editor to define the properties of a new organization, including its name, custom fields, group, and summary, before saving it. ```php $newUser = $api->organization->createOrganizationEditor(); $newUser->setName('DeskPRO Ltd') ->addCustomField('custom field key', 'custom field value') ->addToGroup($groupId) ->setSummary('Summary text goes here'); $result = $api->organization->save($newUser); ``` -------------------------------- ### Get Organization Chats Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves chat conversations for a specific organization. Supports pagination and custom ordering. ```php $page = 2; // Page number of the result set $order = 'chat_conversations.id:asc'; //Defaults to chat_conversations.id:desc. $cacheId = '13579'; // the ID of the cache set to use to retrieve cached results $result = $api->organization->getOrganizationChats($organizationId, $page, $order, $cacheId); ``` -------------------------------- ### Get information about a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves detailed information about a specific person using their unique ID. ```APIDOC ## Get Person By ID ### Description Retrieves information for a specific person. ### Method ``` $result = $api->people->findById(16); ``` ``` -------------------------------- ### Get Custom People Fields Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of all available custom fields that can be applied to people records. ```php $result = $api->people->getPeopleFields(); ``` -------------------------------- ### Get Members of an Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieve a paginated list of members associated with a specific organization. Supports custom ordering and caching. ```php $page = 2; // Page number of the result set $order = 'person.name:desc'; //Defaults to person.name:asc. $cacheId = '13579'; // the ID of the cache set to use to retrieve cached results $result = $api->organization->getMembers($organizationId, $page, $order, $cacheId); ``` -------------------------------- ### Create a Note for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Adds a new note to a person's record. The note content is provided as a string. ```php $note = 'Note Text'; ``` -------------------------------- ### Create a new organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Creates a new organization with the specified details. ```APIDOC ## Create Organization ### Description Creates a new organization. ### Method `save` (with a new editor) ### Parameters #### Organization Editor Object - `setName(name: string)`: Sets the name of the organization. - `addCustomField(key: string, value: string)`: Adds a custom field. - `addToGroup(groupId: string)`: Assigns the organization to a group. - `setSummary(summary: string)`: Sets a summary for the organization. ### Request Example ```php $newUser = $api->organization->createOrganizationEditor(); $newUser->setName('DeskPRO Ltd') ->addCustomField('custom field key', 'custom field value') ->addToGroup($groupId) ->setSummary('Summary text goes here'); $result = $api->organization->save($newUser); ``` ### Response Returns the newly created organization object. ``` -------------------------------- ### Get Person's Groups Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of all groups that a particular person belongs to. Requires the person ID. ```php $result = $api->people->getPersonGroups($personId); ``` -------------------------------- ### Create New News Item (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md This snippet demonstrates how to create a new news item. You need to use the `createNewsEditor` to build the article content, including title, body, labels, and categories, before saving. ```php $builder = $api->news->createNewsEditor(); $builder->setTitle("This is the title") ->setContent("News Content goes here") ->addLabel("API") ->addCategory(1); $result = $api->news->save($builder); ``` -------------------------------- ### Get members of an organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves a paginated list of members belonging to an organization, with options for ordering and caching. ```APIDOC ## Get Organization Members ### Description Gets members of an organization with pagination and ordering options. ### Method `getMembers` ### Parameters - **organizationId** (int): The unique identifier of the organization. - **page** (int, optional): The page number of the results to retrieve. Defaults to 1. - **order** (string, optional): The ordering of the results. Defaults to 'person.name:asc'. - **cacheId** (string, optional): The ID of the cache set to use for retrieving results. ### Request Example ```php $page = 2; $order = 'person.name:desc'; $cacheId = '13579'; $result = $api->organization->getMembers($organizationId, $page, $order, $cacheId); ``` ### Response Returns a paginated list of members belonging to the organization. ``` -------------------------------- ### Create a new news item Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Construct and save a new news article. ```APIDOC ## Create News Item ### Description Creates a new news item with specified title, content, labels, and categories. ### Method `save` (with editor) ### Parameters #### News Editor - `setTitle(title)`: Sets the title of the news item. - `setContent(content)`: Sets the main content of the news item. - `addLabel(labelText)`: Adds a label to the news item. - `addCategory(categoryId)`: Assigns the news item to a category. ### Request Example ```php $builder = $api->news->createNewsEditor(); $builder->setTitle("This is the title") ->setContent("News Content goes here") ->addLabel("API") ->addCategory(1); $result = $api->news->save($builder); ``` ``` -------------------------------- ### Get News Items in a Category (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve a list of news items belonging to a specific category. Requires the category ID and the page number for pagination. ```php $categoryId = 1; $page = 1; $result = $api->news->getCategoryArticles($categoryId, $page); ``` -------------------------------- ### Add Label to an Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Apply a new label to an organization. ```php $result = $api->organization->addLabel($organizationId, $label); ``` -------------------------------- ### Get News Item by ID (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve a specific news item by its unique identifier. This is a straightforward method for fetching a single article's details. ```php $result = $api->news->findById(3); ``` -------------------------------- ### Get All Comments for a News Item (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Fetch all comments associated with a specific news item, identified by its news ID. ```php $result = $api->news->getArticleComments(4); ``` -------------------------------- ### Get Organization Email Domains Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves email domains associated with a specific organization. Supports pagination. ```APIDOC ## Get Organization Email Domains ### Description Gets email domains for an organization. ### Method GET (assumed) ### Endpoint /organizations/{organizationId}/email-domains ### Parameters #### Path Parameters - **organizationId** (string) - Required - The ID of the organization. #### Query Parameters - **page** (integer) - Optional - The page number of the result set. ``` -------------------------------- ### Gets tickets for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of tickets associated with a specific person, with options for pagination, ordering, and caching. ```APIDOC ## Get Person Tickets ### Description Retrieves tickets associated with a person. ### Method ``` $page = 2; // Page number of the result set $order = 'ticket.date_created:asc'; //Defaults to ticket.date_created:desc. $cacheId = '13579'; // the ID of the cache set to use to retrieve cached results $result = $api->people->getTickets($personId, $page, $order, $cacheId); ``` ``` -------------------------------- ### Add an SLA for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Assigns a specific SLA to a person. ```php $result = $api->people->addSla($personId, $slaId); ``` -------------------------------- ### Create a new person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Creates a new person record in the system. Requires details like name, email, organization, and password. ```APIDOC ## Create Person ### Description Creates a new person with the provided details. ### Method ``` $newUser = $api->people->createPersonEditor(); $newUser->setName("User5 with a Password") ->setEmail("anotheruser6@test.com") ->setOrganizationById($id) ->setPassword('password'); $result = $api->people->save($newUser); ``` ``` -------------------------------- ### Get Organization Tickets Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves a list of tickets associated with a specific organization. Supports pagination and custom sorting. ```APIDOC ## Get Organization Tickets ### Description Gets tickets for an organization. ### Method GET (assumed) ### Endpoint /organizations/{organizationId}/tickets ### Parameters #### Path Parameters - **organizationId** (string) - Required - The ID of the organization. #### Query Parameters - **page** (integer) - Optional - The page number of the result set. - **order** (string) - Optional - The order of the results. Defaults to 'ticket.date_created:desc'. - **cacheId** (string) - Optional - The ID of the cache set to use. ``` -------------------------------- ### Get Specific News Item Category (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve details of a specific news category using its category ID. ```php $categoryId = 1; $result = $api->news->getCategory($categoryId); ``` -------------------------------- ### Get Information About a Specific Email ID for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves details for a specific email address associated with a person, identified by its record ID. ```php $result = $api->people->getEmail($personId, $emailId); ``` -------------------------------- ### Get Organization Chats Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Retrieves a list of chats associated with a specific organization. Supports pagination and custom sorting. ```APIDOC ## Get Organization Chats ### Description Gets chats for an organization. ### Method GET (assumed) ### Endpoint /organizations/{organizationId}/chats ### Parameters #### Path Parameters - **organizationId** (string) - Required - The ID of the organization. #### Query Parameters - **page** (integer) - Optional - The page number of the result set. - **order** (string) - Optional - The order of the results. Defaults to 'chat_conversations.id:desc'. - **cacheId** (string) - Optional - The ID of the cache set to use. ``` -------------------------------- ### Get Chats for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of chat conversations associated with a person. You can specify the page number, order, and a cache ID. ```php $page = 2; // Page number of the result set $order = 'chat_conversations.id:desc'; //Defaults to chat_conversations.id:desc. $cacheId = '13579'; // the ID of the cache set to use to retrieve cached results $result = $api->people->getChats($personId, $page, $order, $cacheId); ``` -------------------------------- ### Get Tickets for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of tickets associated with a person. You can specify the page number, order, and a cache ID for retrieval. ```php $page = 2; // Page number of the result set $order = 'ticket.date_created:asc'; //Defaults to ticket.date_created:desc. $cacheId = '13579'; // the ID of the cache set to use to retrieve cached results $result = $api->people->getTickets($personId, $page, $order, $cacheId); ``` -------------------------------- ### Gets chats for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves a list of chat conversations associated with a specific person, with options for pagination, ordering, and caching. ```APIDOC ## Get Person Chats ### Description Retrieves chat conversations associated with a person. ### Method ``` $page = 2; // Page number of the result set $order = 'chat_conversations.id:desc'; //Defaults to chat_conversations.id:desc. $cacheId = '13579'; // the ID of the cache set to use to retrieve cached results $result = $api->people->getChats($personId, $page, $order, $cacheId); ``` ``` -------------------------------- ### Gets information about a particular email ID for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Retrieves details for a specific email address associated with a person, identified by its record ID. ```APIDOC ## Get Person Email By ID ### Description Retrieves information about a specific email record for a person. ### Method ``` $result = $api->people->getEmail($personId, $emailId); ``` ``` -------------------------------- ### Search News by Criteria (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Use this to find news articles that match specific criteria such as category, date, label, and status. Ensure you have created a criteria object and added the desired filters. ```php $criteria = $api->news->createCriteria(); $criteria->addCategory(1) ->createdBefore($unixTimestamp) ->addLabel('label text') ->addStatus($status); $result = $api->news->find($criteria); ``` -------------------------------- ### Add SLA to an Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Associate an existing SLA with a particular organization by providing both IDs. ```php $result = $api->organization->addSla($organizationId, $slaId); ``` -------------------------------- ### Get a specific comment on a news item Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Retrieve a single comment from a news article. ```APIDOC ## Get Article Comment ### Description Retrieves a specific comment from a news article using both article and comment IDs. ### Method `getArticleComment` ### Parameters #### Path Parameters - **newsId** (int) - Required - The ID of the news article. - **commentId** (int) - Required - The ID of the comment. ### Request Example ```php $newsId = 4; $commentId = 2; $result = $api->news->getArticleComment($newsId, $commentId); ``` ``` -------------------------------- ### Check if Organization has Label Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Verify if a specific label is associated with an organization. ```php $result = $api->organization->getLabel($organizationId, $label); ``` -------------------------------- ### Create Note for a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Use this method to add a new note to a person's record. Requires the person ID and the note content. ```php $result = $api->people->createNote($personId, $note); ``` -------------------------------- ### Adds an SLA for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Assigns a specific Service Level Agreement (SLA) to a person. ```APIDOC ## Add Person SLA ### Description Adds a specific SLA to a person. ### Method ``` $result = $api->people->addSla($personId, $slaId); ``` ``` -------------------------------- ### Creates a note for a person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Adds a new note to a person's record. ```APIDOC ## Create Person Note ### Description Creates a new note for a person. ### Method ``` $note = 'Note Text'; // Assuming $personId is defined $result = $api->people->createNote($personId, $note); ``` ``` -------------------------------- ### Add Address to Organization using ContactData Builder Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/ContactData.md This code demonstrates adding an address to an organization's contact information. It requires an Organization editor and a populated ContactData object. ```php $organizationBuilder = $api->organization->createOrganizationEditor(); $contactData = new DeskPRO\Builder\ContactData(); $address = 'Address line 1'; $city = 'Kolkata'; $state = 'West Bengal'; $country = 'India'; $comment = 'Added by API'; $contactData->addAddress($address, $city, $state, $country, $comment); $organizationBuilder->setId($organizationId)->addContactData($contactData); $result = $api->organization->save($organizationBuilder); ``` -------------------------------- ### Reset Organization Password Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Set a new password for an organization and optionally send an email notification. This requires creating an editor, setting the ID, new password, and the sendMail flag. ```php $edituser = $api->organization->createPersonEditor() ->setId($organizationId) ->setPassword("newpassword") ->sendMail(); $result = $api->organization->save($edituser); ``` -------------------------------- ### Add Label to a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Applies a label to a person. Requires the person ID and the label name. ```php $result = $api->people->addPersonLabel($personId, $label); ``` -------------------------------- ### Search People by Criteria Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Use this to find people matching specific criteria such as name, agent team, or email domain. The `agentsOnly()` method can be used to filter for agents. ```php $criteria = $api->people->createCriteria(); $criteria->addName('abhinav') ->addAgentTeam(1) ->addEmailDomain('abhinavkumar.in') ->agentsOnly(); $result = $api->people->find($criteria); ``` -------------------------------- ### Add Organization Email Domain (Singular) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Adds a single email domain for an organization. Requires organization ID and domain name. ```php $page = 2; // Page number of the result set $result = $api->organization->addOrganizationEmailDomain($organizationId, $domain); ``` -------------------------------- ### Create a news item category Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Create a new category for news articles. ```APIDOC ## Create Category ### Description Creates a new category for news articles. ### Method `createCategory` ### Parameters #### Request Body - **title** (string) - Required - The name of the new category. - **parentId** (int) - Optional - The ID of the parent category, if creating a subcategory. ### Request Example ```php $title = 'Article Title'; $parentId = 1; $result = $api->news->createCategory($title, $parentId); ``` ``` -------------------------------- ### Create News Item Category (PHP) Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/news/News.md Create a new category for news items. Requires a title for the category and the parent category ID. ```php $title = 'Article Title'; $parentId = 1; $result = $api->news->createCategory($title, $parentId); ``` -------------------------------- ### Updates a person's profile picture Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Sets or updates a person's profile picture from a given file path. ```APIDOC ## Set Person Picture ### Description Updates a person's profile picture. ### Method ``` $result = $api->people->setPersonPicture(16, '/path/to/image.jpg'); ``` ``` -------------------------------- ### Search Organizations by Criteria Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Use this to find organizations that match specific name, address, or custom field criteria. Ensure the criteria object is properly constructed before calling the find method. ```php $criteria = $api->organization->createCriteria(); $criteria->addName('deskpro ltd') ->addAddress('address goes here') ->addCustomField('custom field key', 'custom field value'); $result = $api->organization->find($criteria); ``` -------------------------------- ### Check if Contact Detail Exists for Organization Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Verify if a specific contact detail, identified by its ID, is linked to an organization. ```php $result = $api->organization->getContactDetail($organizationId, $contactId); ``` -------------------------------- ### Update Organization Profile Picture Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Set or update an organization's profile picture by providing the organization ID and the path to the new image file. ```php $result = $api->organization->setPicture($organizationId, '/path/to/image.jpg'); ``` -------------------------------- ### Check if Person has a Specific Label Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Determines if a person has a particular label assigned. Requires the person ID and the label name. ```php $result = $api->people->getPersonLabel($personId, $label); ``` -------------------------------- ### Add Organization to a Group Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/organization/Organization.md Assign an organization to a specific group by providing both their respective IDs. ```php $result = $api->organization->addGroup($organizationId, $groupId); ``` -------------------------------- ### Update a Person Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Updates an existing person's details. This includes setting their name, email, and password. Ensure the person's ID is correctly set before saving. ```php $edituser = $api->people->createPersonEditor() ->setId(16) ->setName("User5 with a Password") ->setEmail("anotheruser6@test.com") ->setPassword('password'); $result = $api->people->save($edituser); ``` -------------------------------- ### Search for people matching criteria Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/People.md Allows searching for people based on specified criteria such as name, agent team, and email domain. Can also filter for agents only. ```APIDOC ## Search People ### Description Searches for people matching the provided criteria. ### Method ``` $criteria = $api->people->createCriteria(); $criteria->addName('abhinav') ->addAgentTeam(1) ->addEmailDomain('abhinavkumar.in') ->agentsOnly(); $result = $api->people->find($criteria); ``` ``` -------------------------------- ### Add Facebook Account to Organization using ContactData Builder Source: https://github.com/deskpro/deskpro-api-php/blob/master/examples/people/ContactData.md Add a Facebook profile URL to an organization's contact data. This requires initializing the organization editor and the ContactData builder. ```php $organizationBuilder = $api->organization->createOrganizationEditor(); $contactData = new DeskPRO\Builder\ContactData(); $facebookProfileUrl = 'https://www.facebook.com/deskpro'; $comment = 'Added by API'; $contactData->addFacebook($facebookProfileUrl, $comment); $organizationBuilder->setId($organizationId)->addContactData($contactData); $result = $api->organization->save($organizationBuilder); ```