Create Transaction

Creates a transaction for a bundle. This is a critical, required step in the purchase flow - it tells Loop which products, box size, selling plan, and discount make up the bundle, and returns a txnId you attach to the cart.

Auth: Storefront-callable (no token).

If you skip this step, the purchased line items are not bundled - they land on the subscription as separate, unlinked items.

Which IDs go where

You needValueFrom
Path {id}The Bundle IDid in List / Read bundle details
boxSizeIdA box size idboxSizes[].id
sellingPlanShopifyIdA selling plan Shopify ID (or null for one-time)sellingPlans[].shopifyId
discountIdA discount id (optional)discounts[].id
productVariants[].shopifyIdVariant Shopify IDsproducts[].variants[].shopifyId

Note:

  • Create a transaction each time a customer adds a new bundle to the cart.
  • If the customer edits the same bundle before purchase, don't create another one - call Update bundle transaction with the same txnId (This API is only applicable before purchase is completed).

⚠️ Getting quantity right (most common mistake)

  • productVariants[].quantity is the quantity of that child variant in the bundle. The total number of items in the box is the sum of these.
  • Top-level quantity is the number of bundles and defaults to 1. For a BYOB bundle this should stay 1. Do not put the total item count here - passing e.g. 12 because there are 12 items will corrupt the subscription.

✅ Correct - 12 items expressed as child quantities; bundle quantity stays 1:

{
  "boxSizeId": "01HHD6D5XDTFFA83RSZ8XNEKT9",
  "sellingPlanShopifyId": 1051852993,
  "quantity": 1,
  "productVariants": [
    { "shopifyId": 47875709174063, "quantity": 8 },
    { "shopifyId": 47875709174064, "quantity": 4 }
  ]
}

After you get txnId: attach it to the cart

Add the txnId as the line-item property _bundleId: txnId on the Shopify /cart/add.js call, for every bundle line. The key must be exactly _bundleId.

Path Params
int32
required

Bundle ID

Body Params
int32
int32
int32

Pass null to add bundle as a one-time purchase

productVariants
array of objects
productVariants
int32
Defaults to 1
Response

Language
Credentials
Header
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json