Learn how to request expanded responses with additional information about related objects.
Many objects allow you to request additional information as an expanded response by using the expand query parameter. This parameter is available on all API requests, and applies to the response of that request only. You can expand responses in two ways.
In many cases, an object contains the ID of a related object in its response properties. For example, a Checkout Session might have an associated Customer ID.
You can expand these objects in line with the expand request parameter, in this specific example expand_customer=true
would be the query parameter used. The expandable label in this documentation indicates ID fields that you can expand into objects.
Some available fields aren’t included in the responses by default. You can request these fields as an expanded response by using the expand request parameter.
You can use the expand parameter on any endpoint that returns expandable fields.
You can expand multiple objects at the same time by identifying multiple query params.
This can be helpful for scenarios where I’d like to fetch multiple details of objects. For example, if I have a payment intent ID and want to:
I can do all of the above by adding the following query params to the list checkout session request
And we get back the checkout session object with the customer object expanded:
I could have also expanded the payment intent, invoice, or subscription, by following the pattern expand_<object_type>=true
.
Learn how to request expanded responses with additional information about related objects.
Many objects allow you to request additional information as an expanded response by using the expand query parameter. This parameter is available on all API requests, and applies to the response of that request only. You can expand responses in two ways.
In many cases, an object contains the ID of a related object in its response properties. For example, a Checkout Session might have an associated Customer ID.
You can expand these objects in line with the expand request parameter, in this specific example expand_customer=true
would be the query parameter used. The expandable label in this documentation indicates ID fields that you can expand into objects.
Some available fields aren’t included in the responses by default. You can request these fields as an expanded response by using the expand request parameter.
You can use the expand parameter on any endpoint that returns expandable fields.
You can expand multiple objects at the same time by identifying multiple query params.
This can be helpful for scenarios where I’d like to fetch multiple details of objects. For example, if I have a payment intent ID and want to:
I can do all of the above by adding the following query params to the list checkout session request
And we get back the checkout session object with the customer object expanded:
I could have also expanded the payment intent, invoice, or subscription, by following the pattern expand_<object_type>=true
.