Stripe’s expand parameter can return linked resources, such as a Customer alongside a Checkout Session, in one API response. Learn how expansion works, when it can reduce extra requests, and why checking which fields your integration needs keeps responses useful and focused.

Multiple Choice

What API attribute should be used to retrieve linked objects like the Checkout Session and Customer object in a single call?

To retrieve linked objects such as the Checkout Session and Customer object in a single API call, the correct approach is to use the expand fields attribute. This attribute allows developers to specify which related objects or nested resources they want to include in the response when making a request to the Stripe API. When you apply the expand fields feature, the API will not only return the primary resource you requested but also include the specified related objects. For example, if you expand the Customer object while creating or retrieving a Checkout Session, the response will contain detailed information about that Customer along with the Checkout Session data, reducing the number of API calls required to gather comprehensive information about related resources. This feature streamlines the process for developers, as they can access all necessary data in one response, improving efficiency and performance by minimizing multiple round-trips to the server. The use of expand fields is a powerful tool for building applications that require a rich understanding of how various Stripe resources are interlinked, ultimately leading to a better integration experience.

A Stripe API response often gives you the main object you asked for, plus an ID that points to something related. A Checkout Session, for instance, may include a customer ID rather than the Customer’s full details. If your application needs both objects, Stripe’s expand parameter can ask for the linked data in the same request. It’s a small feature with a useful effect: fewer round trips, and a response that’s easier to work with.

From an ID to a full object

Stripe resources are connected. A Checkout Session can reference a Customer, a PaymentIntent, a Subscription, and other objects, depending on how the Session was created. By default, many related resources appear as IDs. That keeps responses compact and predictable, but it means your code may need to make another API call to fetch the details behind an ID.

Expansion changes that response. Add the expand parameter with the name of an expandable field, and Stripe returns the related object’s data in place of its ID. For example, a request to retrieve a Checkout Session might include:


curl https://api.stripe.com/v1/checkout/sessions/cs_test_123 \

-u sk_test_your_key: \

-G \

--data-urlencode "expand[]=customer"

The response still contains the Checkout Session, but its customer field can now contain a Customer object rather than a string ID. Your application can read the customer’s available details directly from that response.

The parameter is called expand in Stripe’s API. In many requests, it is passed as an array using the form expand[], even when you’re expanding just one field. Stripe’s official API reference shows which fields support expansion for each resource.

Why one call can help

Every API request takes time. Your application sends a request, waits for Stripe’s response, then may send another request for the related object. In a flow that displays a Checkout Session and customer details, that extra step can add latency and more code to manage.

Expansion can make the flow simpler. One response may contain the data your page or service needs, which can reduce network traffic and the number of separate requests. That’s particularly handy when a backend needs to make a quick decision based on related information.

There’s a trade-off, though. A larger response takes more data to transfer and parse. If your application only needs the customer ID, fetching the full Customer object adds weight without much value. Expansion is most useful when the related details are actually needed.

Expanding nested relationships

Some Stripe fields point to objects that have their own expandable fields. You can use a dotted path to ask for a nested object. For example, a Checkout Session may have a PaymentIntent, and that PaymentIntent may reference a PaymentMethod. A request can ask for both levels:


curl https://api.stripe.com/v1/checkout/sessions/cs_test_123 \

-u sk_test_your_key: \

-G \

--data-urlencode "expand[]=payment_intent.payment_method"

This tells Stripe to include the PaymentIntent and its PaymentMethod in the response, where those fields are available and expandable. Nested expansion can be handy when a service needs a compact view of a related chain of data.

Still, it’s wise to keep the path focused. A deep expansion can create a large, complex response, and not every field supports expansion. If a request returns an error, check the API reference for the resource and field names, and confirm that the path is valid for the API version your integration uses.

Expanding objects in a list

Stripe also supports expansion for certain list responses. When the object you want is inside a list’s data array, the path often starts with data.. For example, a request that lists Checkout Sessions can expand each Session’s Customer with:


curl https://api.stripe.com/v1/checkout/sessions \

-u sk_test_your_key: \

-G \

--data-urlencode "expand[]=data.customer"

That pattern is useful when a page shows a collection of records and a small amount of related information for each one. Without it, an application might need to fetch each Customer separately, which can create many requests. With expansion, the list response can include those customer objects alongside the Sessions.

But a list can grow quickly. Expanding several objects for every item may make the response much larger than expected. Consider what the page really displays, and request only the relationships that support that view.

A few details worth keeping in mind

Expansion affects the shape of a response. A field that was a string ID may become an object, so code should be ready to handle the expanded form. This matters especially if some requests expand a field and others don’t. A thoughtful integration treats related fields as potentially either an ID or an object, rather than assuming one shape everywhere.

Expansion also doesn’t change what your API key is allowed to access. Stripe’s permissions and account context still apply. Nor does expansion replace webhooks: a webhook event is often the right way to learn that something happened, while an API request can retrieve the latest resource details when your service needs them.

API versioning matters, too. Stripe’s response fields and resource behavior can vary by API version. Keep the version used by your integration in mind when reading documentation or investigating a response that differs from an example. A saved response from an older integration can be a useful clue, but the current API reference for your version should guide implementation.

Finally, don’t treat an expanded object as a shortcut around sound data handling. Return only the customer information your application needs, and be careful about exposing Stripe response data to a browser or logging it unnecessarily. The fact that a value arrived in the same response doesn’t mean every part of it belongs in every part of your system.

Keep requests purposeful

The expand parameter is a practical way to retrieve related Stripe objects in one API call. For a Checkout Session and its Customer, expanding customer can provide both resources together. For nested relationships, dotted paths can request additional levels; for list responses, paths may begin with data..

Used with care, expansion can simplify code and reduce needless requests. Used indiscriminately, it can make responses heavy and harder to manage. The useful middle ground is simple: expand the fields your application needs, check the API reference for supported paths, and handle the response shape deliberately. That keeps your integration tidy without asking Stripe to send more data than the job calls for.