Movidesk API - Services
20 min
Created by Rafael Frigotto on 8/18/2017 4:47 PM
Updated by Karine Moreira on 9/24/2024 4:31 PM
Important: Our APIs have a limit of 10 requests per minute to ensure healthy usage. If you have a specific scenario that requires increased usage, contact our support team for feasibility analysis. Learn more about API hours and limits
https://api.movidesk.com/public/v1

Services

  URL:    /services
  Methods: GET / POST / PATCH / DELETE

Layout

service

Property Type Size Required Description
id int     Unique identifier field for the service (read-only).
name string      128 ✓  Service name field.
description string     Description field.
parentServiceId int     Field id representing the parent service.
serviceForTicketType int   Available for ticket types. Public = 0, Internal = 1, Public and Internal = 2.
isVisible int   Visible to: Agent = 1, Customer = 2, Agent and Customer = 3.
allowSelection int   Allow selection for: Agent = 1, Customer = 2, Agent and Customer = 3.
allowFinishTicket bool   Unchecking this parameter means the ticket cannot be completed if this item is selected. The agent needs to choose a new item before completing the ticket.
isActive bool   Disabled services will not be visible for selection within tickets. Uncheck this option if you no longer want the service to be available in the system.
automationMacro string 64   Name of the macro that should be automatically executed when selecting the service.
defaultCategory string 128   Name of the category that should appear as default when selecting the service in the ticket.
defaultUrgency string 128   Name of the urgency that should appear as default when selecting the service in the ticket.
allowAllCategories bool   Allows selection of all categories.
categories array 128 * List of the service's category names. Must be provided when the allowAllCategories field is false.

 

 

Working with Data

To access the data, you must first generate an API key.

To generate an API key (token), go to Movidesk, navigate to Settings / Account / Parameters and on the environment tab click the "Generate new key" button if you don't have one created yet.
You can repeat this process whenever you want to generate a new access key, but remember that generating a new key will make all programs using the old key stop working.

All data flows (Viewing/Inserting/Modifying) must be in JSON format as shown in the example below:

{
"id": 5778,
"name": "Demonstration",
"description": "Test service",
"parentServiceId": 5707,
"serviceForTicketType": 1,
"isVisible": 3,
"allowSelection": 3,
"allowFinishTicket": true,
"isActive": true,
"automationMacro": "Apply attachment",
"defaultCategory": "Internal options only",
"defaultUrgency": "Low",
"allowAllCategories": false,
"categories": [
"Internal options only",
"Problem",
"Suggestion"
]
}

Retrieving Data

Method GET

Retrieving a single service

GET: /services
Parameters: id, token

Example:

Retrieving the service with id 5712

GET: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa&id=5712

Response:

{
"id": 5712,
"name": "TI",
"description": null,
"parentServiceId": null,
"serviceForTicketType": 2,
"isVisible": 3,
"allowSelection": 3,
"allowFinishTicket": true,
"isActive": true,
"automationMacro": null,
"defaultCategory": "Problem",
"defaultUrgency": "Medium",
"allowAllCategories": true,
"categories": []
}

Retrieving a List of Services

GET: /services
Parameters: token

Example:

Retrieving a list of services

GET: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa

Response:

[
{
"id": 5711,
"name": "SAC",
"description": null,
"parentServiceId": null,
"serviceForTicketType": 2,
"isVisible": 3,
"allowSelection": 1,
"allowFinishTicket": true,
"isActive": true,
"automationMacro": null,
"defaultCategory": null,
"defaultUrgency": null,
"allowAllCategories": true,
"categories": []
},
{
"id": 5712,
"name": "TI",
"description": null,
"parentServiceId": null,
"serviceForTicketType": 2,
"isVisible": 3,
"allowSelection": 3,
"allowFinishTicket": true,
"isActive": true,
"automationMacro": null,
"defaultCategory": "Problem",
"defaultUrgency": "Medium",
"allowAllCategories": true,
"categories": []
}
... Other items in the list
]

 

Retrieving Services with Filters

GET: /services
Parameters: token

To allow and simplify queries with filters, the API uses the open protocol OData. Possible filters include:
• $filter: the expression specified with this filter is evaluated for each item in the query result, and only items where the expression evaluates to true will be included in the final result;
• $orderby: allows the items in the query result to be ordered in ascending (asc) or descending (desc) order. If asc or desc is not specified, the default is asc;
• $top: allows specifying the number of items to include in the query result;
• $skip: allows specifying the number of items to skip and not include in the query result;
• $select: allows specifying specific properties of the items to be included in the query result;
• $expand: allows expanding the child collections of the queried items.

Examples:

Retrieving a list of services with a specific id:

GET: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa&$filter=id eq 5779

Response:
[
{
"id": 5779,
"name": "5779",
"description": null,
"parentServiceId": 5778,
"serviceForTicketType": 0,
"isVisible": 0,
"allowSelection": 0,
"allowFinishTicket": false,
"isActive": true,
"automationMacro": null,
"defaultCategory": null,
"defaultUrgency": null,
"allowAllCategories": false,
"categories": []
}
]


Retrieving a list of services that are not active, ordered in descending order by id:

GET: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa&$filter=isActive eq false&$orderby=id desc

Response:
[
{
"id": 5788,
"name": "test 1",
"description": null,
"parentServiceId": 5785,
"serviceForTicketType": 0,
"isVisible": 0,
"allowSelection": 0,
"allowFinishTicket": false,
"isActive": false,
"automationMacro": null,
"defaultCategory": null,
"defaultUrgency": null,
"allowAllCategories": false,
"categories": []
},
{
"id": 5787,
"name": "test 1",
"description": null,
"parentServiceId": 5785,
"serviceForTicketType": 0,
"isVisible": 0,
"allowSelection": 0,
"allowFinishTicket": false,
"isActive": false,
"automationMacro": null,
"defaultCategory": null,
"defaultUrgency": null,
"allowAllCategories": false,
"categories": []
}
]

 

Retrieving a list of services that are not active and ordered in descending order by id, and filtering the result to get only 10 services while skipping the first 10 (used for pagination of the result, in this case to get the second page):

GET: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa&$filter=isActive eq false&$orderby=id desc&$top=100&$skip=10

Response:
[
{
{
"id": 102,
"name": "test 1",
"description": null,
"parentServiceId": 5785,
"serviceForTicketType": 0,
"isVisible": 0,
"allowSelection": 0,
"allowFinishTicket": false,
"isActive": false,
"automationMacro": null,
"defaultCategory": null,
"defaultUrgency": null,
"allowAllCategories": false,
"categories": []
},
{
"id": 101,
"name": "test 1",
"description": null,
"parentServiceId": 5785,
"serviceForTicketType": 0,
"isVisible": 0,
"allowSelection": 0,
"allowFinishTicket": false,
"isActive": false,
"automationMacro": null,
"defaultCategory": null,
"defaultUrgency": null,
"allowAllCategories": false,
"categories": []
}, ... Other 8 items in the list ordered in descending order by id and that are not active. ]


Retrieving id and name of services that are not active, ordered in descending order by id and filtering the result to get only 10 services while skipping the first 10 (used for pagination of the result, in this case to get the second page):

GET: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa&$filter=isActive eq false&$select=name,id&$orderby=id desc&$top=10&$skip=10

Response:
[
  {
"id": 102,
"name": "Demonstration"
},
{
"id": 101,
"name": "Thirteenth"
} ... Other 8 items in the list ordered in descending order by id and that are not active.
]

  

Inserting Data

Method POST

POST: /services
Parameters: token, returnAllProperties (default value is false)
Headers: Content-Type: application/json
RequestBody: {JSON object}

Example:
POST: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa&returnAllProperties=false
Headers: Content-Type: application/json
RequestBody:
 {
"id": 5707,
"name": "Test 01",
"description": "Service test",
"parentServiceId": 5707,
"serviceForTicketType": 1,
"isVisible": 3,
"allowSelection": 3,
"allowFinishTicket": true,
"isActive": true,
"automationMacro": "Apply attachment",
"defaultCategory": "Problem",
"defaultUrgency": "Medium",
"allowAllCategories": false,
"categories": [
"Problem",
"Suggestion",
"Does not add attachment",
"Service request"
]
}

Response: Status 200 and the id of the inserted service in the body.


Updating Data

Method PATCH

Unlike data insertion (POST), updating is done partially. Therefore, only the data that you want to change should be sent to the server.

However, modifying lists (child objects) always overwrites all items in the list.

PATCH: /services
Parameters: token, id
Headers: Content-Type: application/json
RequestBody: {JSON object}

Examples:

Changing the name of the service with id 1

PATCH: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa&id=1
Headers: Content-Type: application/json
RequestBody:
{
  "name": "test"
}

Response: Status 200

In the above example, only the Name field is changed, and the other fields remain unchanged

 

 

Deleting Services

Method DELETE


DELETE: /services
Parameters: token, id
Headers: Content-Type: application/json
RequestBody: {JSON object}

Examples:

Deleting the service with id 1

DELETE: https://api.movidesk.com/public/v1/services?token=4242a18d-3e12-498c-937c-930bef3de3fa&id=1
Headers: Content-Type: application/json

Response: Status 200

 


Source code example in C# for calling the API

Method POST

try
{
var service = new
{
isActive = true
};
var json = JsonConvert.SerializeObject(service);

var response = await SendAsync("https://api.movidesk.com/public/v1/services?token=YOURTOKEN",
json, "POST", "application/json");
}
catch (WebException ex)
{
var response = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
}

public static async Task<string> SendAsync(string uri, string content, string method, string contentType)
{
var req = WebRequest.Create(uri);
req.ContentType = contentType;
req.Method = method;

using (var stream = await req.GetRequestStreamAsync())
using (var streamWriter = new StreamWriter(stream))
{
await streamWriter.WriteAsync(content);
}

var httpResponse = (HttpWebResponse)await req.GetResponseAsync();
using (var stream = httpResponse.GetResponseStream())
{
if (stream == null)
return null;

using (var streamReader = new StreamReader(stream))
{
return await streamReader.ReadToEndAsync();
}
}
}

 

In the above example, the service insertion will not be performed as there are several errors in the request body. The errors are detailed in the response variable and should be corrected according to this documentation.

Was this article useful?
Recently viewed