RESTful API Guide
DiamanteDesk REST APIs enable interaction between the application and other software products, such as websites, CRMs, content management systems and other applications. Using the DiamanteDesk REST APIs you can read, modify, add and delete the data directly in the helpdesk.
To ensure secure access it is recommended to use HTTPS protocol for API requests.
API Endpoints
API endpoints define the connection point to your service, giving the external application access to DiamanteDesk data. API endpoints are prefixed with your domain name:
Authentication
DiamanteDesk uses WSSE authentication to ensure secure access to the third party applications via REST APIs. WSSE authentication in DiamanteDesk application, which is based on Symfony, is implemented by using this bundle.
WSSE authentication is based on:
- a username;
- a nonce (created to avoid replay attacks);
- a timestamp;
- the password digest (In DiamanteDesk the password digest is represented as API Key. To learn how to generate API key, please check the API Credentials article in the Integration section of DiamanteDesk documentation).
Format
All the data in DiamanteDesk APIs is transmitted either in JSON or XML format with JSON being a default format. The format can be specified either:
- in the request header (Content-Type, Accept). Note: The MIME type shall be specified in header (application/json, application/xml).
- or specified in the URL.
Pagination, Sorting, Filtering
Pagination
When a user performs a request to get a collection of entities or a certain entity, the data requested is returned in the response body. Depending on the requested items, objects or products, the list of results can contain thousands of results that should be paged through. The number of items per each page can be specified using page parameters. Paginated queries start at page 1 by default.
For example, if you set the page limit to 10 items and you need to retrieve items from 21 to 30 your request should contain such parameters: limit=10 and page=3.
When a user requests a list of certain entities, the server returns the results along with additional metadata, such as:
- the general amount of entities, shown at the X-Total HTTP header;
- the links to the connected pages in the Link HTTP header. There are 4 types of such links:
Name | Description |
---|---|
next | The URL to the following results page. |
last | The URL to the last results page. |
first | The URL to the first results page. |
prev | The URL to the previous results page. |
Take a look at the example, containing such headers:
Sorting
The results can be sorted according to the sort and order GET parameters, included in the URL. The sort parameter performs the sorting according to the property name of an entity, order parameter may be set either to asc (ascending) or desc (descending).
Filtering
Filtering can be performed according to any parameter of the corresponding entity. For example, to filter the branch by its key, add “key=PO” parameter to the URL.
If the value is specified for string property, the search is performed for any occurrence, meaning the result will return PO, DPO, DPOD, etc. If the value is specified for numeric property the search is performed for equal value.
To filter the results by the time when a certain entity or entities were created or updated, the following parameters should be used:
- createdBefore
- createdAfter
- updatedBefore
- updatedAfter
Error Handling
When the fault occurs within the application or on a server side, the server returns the corresponding status code followed by the message, indicating the root cause in the response body.
Here are the status codes of the errors that may occur when working with DiamanteDesk application.
Status Code | Description |
---|---|
400 | Validation failed and the request provided by the client was incorrect or distorted and the server could not understand it. |
401 | Such error occurs when a user attempts to access a page or resource that requires authentication. To resolve this issue, correct log in details shall be provided. |
403 | Authorization issue, meaning that a user has not been granted permission to access specific page or method. |
404 | This error means that the server could not process client request with the reason for that described in the error message. |
500 | Internal server error. This status code indicates that this is not a client-side issue, meaning that the problem occurred on the server side rather than in DiamanteDesk application. |
Take a look at the example of a 404 error below:
Resources
REST APIs are necessary when DiamanteDesk is integrated into another application and when interactions with the DiamanteDesk server shall be scripted.
Note: Here are the values of the variables API methods:
Variable | Requirements |
---|---|
{version} | latest, v1 |
{_format} | xml, json |
Branches
GET: Retrieve the list of all branches
Response
Status Code: 200 (OK)
Response body:
GET: Retrieve a branch by ID
Response
Status Code: 200 (OK)
Response body:
Status Code: 404 (Not Found)
Response body:
POST: Create a new branch
Parameters
Name | Type | Description | Note |
---|---|---|---|
name | string | Required. Specify the name of a new branch. | Minimum length is 2 letters. |
description | string | Enter the description of a new branch, if necessary. | |
tags | arrey of strings | Optional Specify the tags appropriate for the new branch. To learn more about tagging in DiamanteDesk, please check the Tagging section in the User Guide section. | |
key | string | Enter the key of a new branch. This key should be unique accross the whole system. | The branch key must contain only letters. Minimum length is 2 letters. |
Request example:
Response
Status Code: 201 (Created)
Response body:
PUT, PATCH: Update properties of a certain branch by its ID
Request example:
Response
Status Code: 200 (OK)
Response body:
DELETE: Delete a branch by ID
Response
Status Code: 204 (No Content)
Response body: null
Tickets
GET: Retrieve list of all tickets
Response
Status Code: 200 (OK)
Response body:
GET: Retrieve the ticket by the given ticket ID
Response
Status Code: 200 (OK)
Response body:
Status Code: 404 (OK)
Response body:
POST: Create a new ticket
Parameters
Name | Type | Description | Note |
---|---|---|---|
branch | integer | Required. Specify a branch name where the ticket should be created. | |
subject | string | Required. Enter a short description of a new ticket. | |
description | string | Required. Enter the detailed description of a new ticket. | |
status | string | Required. The available statuses are: New, Open, Pending, In progress, Closed and On Hold. | |
priority | string | Required. Specify the priority of a new ticket. The available options are Low, Medium or High. | |
source | string | Required. Every service user has 4 available options to contact the Help Desk team: by creating a request through a Web form or through the embedded form on a website (optional), as an Email notification, via a Phone call. Specify the corresponding source of a ticket. | |
reporter | string | Required. The reporter is an administrator who can create a ticket for any customer. | The name of a reporter must contain only letters. |
assignee | integer | Optional. Select a person responsible for ticket handling. | Only OroCRM user can be selected. |
tags | array of strings | Optional. Specify the tags appropriate for the new branch. To learn more about tagging in DiamanteDesk, please check the Tagging section in the User Guide section. |
Request example:
Response
Status Code: 201 (Created)
Response body:
PUT, PATCH: Update certain properties of the ticket by ID
Request example:
Response
Status Code: 200 (OK)
Response body:
DELETE: Delete the ticket by ID
Response
Status Code: 204 (No Content)
Response body: null
GET: Retrieve a ticket by the given ticket key
Response
Status Code: 200 (OK)
Response body:
Status Code: 404 (Not Found)
Response body:
PUT, PATCH: Update certain properties of a ticket by the ticket key
Request example:
Response
Status Code: 200 (OK)
Response body:
DELETE: Delete the ticket by the ticket key
Response
Status Code: 204 (No Content)
Response body: null
GET: Retrieve the list of ticket attachments by ticket ID
Response
Status Code: 200 (OK)
Response body:
GET: Retrieve ticket attachments by attachment ID
Response
Status Code: 200 (OK)
Response body:
Status Code: 404 (Not Found)
Response body:
POST: Add attachment to the ticket
Request example:
Response
Status Code: 201 (Created)
Response body:
DELETE: Remove Attachment from the ticket
Response
Status Code: 204 (No Content)
Response body: null
GET: Retrieve personal data based on the provided ticket ID
Response
Status Code: 200 (OK)
Response body:
Comments
GET: Retrieve the list of all comments
Response
Status Code: 200 (OK)
Response body:
GET: Retrieve the comment by the given comment ID
Response
Status Code: 200 (OK)
Response body:
Status Code: 404 (OK)
Response body:
POST: Add a new comment to the ticket.
Parameters
Name | Type | Description | Note |
---|---|---|---|
content | string | Required. Add your comment into this section. | |
ticket | integer | Required. Provide the ID of a ticket where the comment is added. | |
author | string | Required. Specify the name of a user who adds the comment to the ticket. | The name of an author must contain only letters. |
ticketStatus | string | Required. Specify the status of a ticket after the new comment is added to it. The available statuses are: New, Open, Pending, In progress, Closed and On Hold. |
Request example:
Response
Status Code: 201 (Created)
Response body:
PUT, PATCH: Update certain properties of the comment be the comment ID
Response
Status Code: 200 (OK)
Request example:
Response body:
DELETE: Delete a ticket comment by the comment ID
Response
Status Code: 204 (No Content)
Response body: null
GET: Retrieve the information about the comment author based on the provided comment ID
Response
Status Code: 200 (OK)
Response body:
GET: Retrieve all comment attachments
Response
Status Code: 200 (OK)
Response body:
Retrieve comment attachments by the attachment ID
Response
Status Code: 200 (OK)
Response body:
Status Code: 404 (OK)
Response body:
POST: Add attachment to the comment
Request example:
Response
Status Code: 201 (Created)
Response body:
DELETE: Remove the attachment from the comment by the attachment ID
Response
Status Code: 204 (No Content)
Response body: null
Users
GET: Retrieve the list of all users
Response
Status Code: 200 (OK)
Response body:
POST: Create a new user
Parameters
Name | Type | Description |
---|---|---|
firstName | string | Required. Provide the first name of a new user. |
lastName | string | Required. Provide the last name of a new user. |
string | Required. Add an email of a new user. This email is going to be used for email notifications and password recovery. |
Request example:
Response
Status Code: 201 (Created)
Response body:
GET: Retrieve user data
Response
Status Code: 200 (OK)
Response body:
Status Code: 404 (Not Found) Response body:
PUT, PATCH: Update properties of a certain user by its ID
Request example:
Response
Status Code: 200 (OK)
Response body:
DELETE: Delete the user by id
Response
Status Code: 204 (No Content)
Response body: null