Inclusion of Related Resources#
The include parameter allows you to retrieve related resources in a single request.
This is also known as side-loading and reduces the need for multiple API calls by returning related objects alongside the primary resource.
Included resources are returned in the top-level included array. The relationships object of each resource links to them by type and id.
Note
Using include reduces the number of requests needed to fetch related data and improves performance when working with linked resources.
Include a single related resource#
You can include a single related resource by specifying it in the include parameter.
In this example, each DID record includes its associated voice_in_trunk resource.
This allows you to retrieve additional details about related resources without sending a separate request:
http
1GET /v3/dids?include=voice_in_trunk HTTP/1.1
2Host: api.didww.com
3Accept: application/vnd.api+json
curl
1curl -i -X GET 'https://api.didww.com/v3/dids?include=voice_in_trunk' -H "Accept: application/vnd.api+json"
Include multiple related resources#
You can include multiple related resources by separating them with commas.
In this example, the request includes the DID’s voice_in_trunk and voice_in_trunk_group resources in a single request.
http
1GET /v3/dids?include=voice_in_trunk%2Cvoice_in_trunk_group HTTP/1.1
2Host: api.didww.com
3Accept: application/vnd.api+json
curl
1curl -i -X GET 'https://api.didww.com/v3/dids?include=voice_in_trunk%2Cvoice_in_trunk_group' -H "Accept: application/vnd.api+json"
Include nested related resources#
You can also include relationships of already-included objects.
In this example, the request includes voice_in_trunk and its related voice_in_trunk_group:
http
1GET /v3/dids?include=voice_in_trunk.voice_in_trunk_group HTTP/1.1
2Host: api.didww.com
3Accept: application/vnd.api+json
curl
1curl -i -X GET 'https://api.didww.com/v3/dids?include=voice_in_trunk.voice_in_trunk_group' -H "Accept: application/vnd.api+json"