Dynamically update line itemsPrivate preview
Update line items in response to changes made during checkout.
Private preview
This feature is in private preview. Request access to dynamic updates to checkout.
Learn how to dynamically add, remove, or update line items included in a Checkout Session.
Use cases 
This guide demonstrates how to update line items to upsell a subscription, but you can also:
- Check inventory: Run inventory checks and holds when customers attempt to change item quantities.
- Add new products: Add a complimentary product if the order total exceeds a specific amount.
- Update shipping rates: If the order total changes, update shipping rates by combining the method described in this guide with what’s out on Customize shipping options during checkout.
- Update tax rates: If you’re not using Stripe Tax, you can dynamically update tax rates on line items based on the shipping address entered.
Set up SDKServer-side
Use our official libraries to access the Stripe API from your application:
Update server SDKServer-side
To use this beta, first update your SDK to use the checkout_
beta version header.
Configure Checkout Session update permissionsServer-side
Pass in permissions.update_line_items=server_only when you create the Checkout Session to enable updating line items from your server. Passing this option will also disable client-side updates to line items, such as updateLineItemQuantity, ensuring that all updates pass through your server.
Dynamically update line itemsServer-side
Create a new endpoint on your server to update the line items on the Checkout Session. You’ll call this from the frontend in a later step.
Security tip
It’s essential to understand that client-side code runs in an environment fully controlled by the user. A malicious user can bypass your client-side validation, intercept, and modify requests, or even craft entirely new requests to your server.
When designing the endpoint, we recommend the following:
- Design endpoints for specific customer interactions instead of making them overly generic (for example, “add cross-sell item” rather than a general “update” action). Specific endpoints help keep the purpose clear and make validation logic easier to write and maintain.
- Avoid passing Session data directly from the client to your endpoint. Malicious clients can modify request data, making it an unreliable source for determining the Checkout Session state. Rather, pass the session ID to your server and use it to securely retrieve the data from Stripe’s API.
When updating line items, you must retransmit the entire array of line items.
- To keep an existing line item, specify its
id
. - To update an existing line item, specify its
id
along with the new values of the fields to update. - To add a new line item, specify a
price
andquantity
without anid
. - To remove an existing line item, omit the line item’s ID from the retransmitted array.
- To reorder a line item, specify its
id
at the desired position in the retransmitted array.