Expanding Resources
Several objects support the retrieval of additional information through an expanded response by utilizing the expand
request parameter. This parameter is applicable to most API requests and influences the response of the corresponding request.
In numerous scenarios, an object includes the ID of a correlated object within its response properties. For instance, a Booking has an associated Booker ID. You have the option to expand the Booker object using the expand
request parameter. The expandable
label in this documentation specifies ID fields that can be expanded into objects.
Example for GET /private/bookings/{id}
In Booking
response you can always see booker_id
. However, when you need more details about the Booker
you can just expand by adding expand[]=booker
to request query string.
Example for GET /private/bookings/{id}?expand[]=booker
We never expand relations by default. Also one/many-to-many relations don't have arrays of foreign keys (ID's) in the default response. You have to explicitly expand then when it's needed. Example Locations
in Booking
resource.
Recursive expansion is achieved by specifying nested fields after a dot (.) in the request. For instance, if you request invoices.payments
on a Booking
, it expands the Booking
property with invoices lists and payments for those invoices.
You can use the expand parameter on any endpoint that returns expandable fields, including list, fetch single, create and update endpoints. Performing deep expansions on numerous list requests might result in slower processing times. Expansions have a maximum depth of three levels. You can expand multiple objects at the same time.
Last updated