Sideloading
Most objects in Deskpro have other objects that are related to them. For example, a ticket has various users associated with it such as the creator, the assigned agent and any followers or CC'd users.
By default, the API will only return the IDs of these related objects and if you needed more information, you would need to use the API again to fetch the objects you wanted (for example, to get the actual title of the department a ticket was in).
However, this is tedious if you are doing it a lot. For this reason, the DeskPRO API has the idea of side-loading which instructs the API to return related objects of certain types. You do this by specifying the type of object you want to side-load in the request as a query parameter: include=type1,type2,type3.
Examples:
    /tickets/123?include=department
    /tickets/123?include=department,person,category,product,workflow
    /people/456?include=usergroup
When you specify an include parameter, the related objects are returned in the response under the linked object. You'll get properties like linked.TYPENAME.ID.
(Note that the actual data response stays the same. Your own app logic will need to connect the ID from the data to the object returned in the linked section.)
Example ticket response without side loading
1
curl -H "Authorization: key 1:CVRRGQ58QDX8H5B4W4RAJ978Q" \
2
http://example.com/api/v2/tickets/123
Copied!
Example response. Notice how we have IDs for various relationships such as the person, agent or department.
1
{
2
"data": {
3
"id": 123,
4
"ref": "XXXX-0028-IOCC",
5
"department": 20,
6
"person": 59080,
7
"agent": 2,
8
"status": "awaiting_user",
9
"subject": "Example Ticket"
10
},
11
"meta": [],
12
"linked": []
13
}
Copied!
Example WITH sideloading on department and person
1
curl -H "Authorization: key 1:CVRRGQ58QDX8H5B4W4RAJ978Q" \
2
http://example.com/api/v2/tickets/123?include=department,person
Copied!
Example response with sideloaded objects
1
{
2
"data": {
3
"id": 123,
4
"ref": "XXXX-0028-IOCC",
5
"department": 20,
6
"person": 59080,
7
"agent": 2,
8
"status": "awaiting_user",
9
"subject": "Example Ticket"
10
},
11
"meta": [],
12
"linked": {
13
"department": {
14
"20": {
15
"id": 20,
16
"title": "Support"
17
}
18
},
19
"person": {
20
"2": {
21
"id": 2,
22
"name": "John Doe",
23
"primary_email": "[email protected]"
24
},
25
"59080": {
26
"id": 59080,
27
"name": "Fionna Apple",
28
"primary_email": "[email protected]"
29
}
30
}
31
}
32
}
Copied!

Inline Sideloading

Above you saw that sideloading loads related resources into the linked key in the response. That means it's still up to you, the developer, to map an ID from the data to the correct value in linked.
To make this even easier, you can choose to inline the data. This replaces the IDs with the actual object itself, making consuming requests very very easy.
To enable inlining, you specify a query parameter inline_sideloads=1.
Same example above but with inlining enabled:
1
curl -H "Authorization: key 1:CVRRGQ58QDX8H5B4W4RAJ978Q" \
2
http://example.com/api/v2/tickets/123?include=department,person&inline_sideloads=1
Copied!
Example response with sideloaded objects
1
{
2
"data": {
3
"id": 123,
4
"ref": "XXXX-0028-IOCC",
5
"department": {
6
"id": 20,
7
"title": "Support"
8
},
9
"person": {
10
"id": 59080,
11
"name": "Fionna Apple",
12
"primary_email": "[email protected]"
13
},
14
"agent": {
15
"id": 2,
16
"name": "John Doe",
17
"primary_email": "[email protected]"
18
},
19
"status": "awaiting_user",
20
"subject": "Example Ticket"
21
},
22
"meta": [],
23
"linked": {}
24
}
Copied!
Inlining can make your life easier, but it comes at the cost of data duplication. For example, if you loading a list of 100 tickets, then the same agent might be assigned to many different tickets. Inlining would copy the agent data in multiple places which would increase the size of the response considerably.
So it's often beneficial to keep the default behaviour and link IDs to linked objects in your application logic.
Last modified 3yr ago
Copy link