SubblySubbly
Log inGet started
  • Get started
  • Developer resources
Subbly.js SDK reference
Docs
Information
    CookiesAmounts and datesCurrencyExpand parametersErrors
Setup
    Start the SDKSet the currencySet the languageVersionConfiguration
Addresses
    List the addressesAdd an addressDelete an address
Authentication
    Authentication stateCheck the authenticationLog in with a passwordRegister a customerCheck if an email is registeredSend a one-time passwordLog in with a one-time passwordLog in with single sign-onLog outGet the access token
Bundles
    List the bundlesLoad a bundleLoad the bundle itemsLoad the bundle groupsQuote a bundle
Cart
    Create a cartLoad a cartUpdate the cartAdd an itemUpdate an itemRemove an itemGet the start datesGet the gifting datesGet the shipping methodsGet the pick-up pointsAttach the customer
Checkout
    Purchase the cart
Countries
    List the countries
Customers
    Get the customer profileUpdate the customerGet the referral link
Funnels
    Get a pre-purchase offerAccept a pre-purchase offerSkip a pre-purchase offerReset the pre-purchase offersGet a mid-purchase offerAccept a mid-purchase offerSkip a mid-purchase offerGet a post-purchase offerAccept a post-purchase offerSkip a post-purchase offer
Leads
    Capture a lead
Metafields
    List the metafields
Payment intents
    Get a payment intentConfirm a payment intent
Pick-up info
    List the pick-up infosAdd a pick-up infoDelete a pick-up info
Products
    List the productsLoad a productLoad a variantLoad a plan
Shop
    Load the shop
Stock notifications
    Get a back-in-stock alert
Subscriptions
    List the subscriptionsLoad a subscriptionUpdate a subscriptionUpdate the survey preferencesUpdate the bundleLoad a subscription itemUpdate a subscription itemUpdate an item bundleUpdate the item survey preferences
Surveys
    Load a survey
Wallet
    List the payment methodsStart a payment setupAdd a payment methodStart a 3-D Secure setup

Setup

Start Subbly.js with your Storefront API key, then set the currency and the language.

Subbly.init(config)

Starts Subbly.js with your Storefront API key and resolves with the SDK instance. Every other method in this reference is a method of that instance.

init always loads the shop first, so subbly.shop is filled in by the time the promise resolves. It then checks the stored access token, and, when you pass loadCart, loads or creates a cart and copies the cart currency onto the instance. A failed shop load rejects the promise.

Call init once per page. The SDK builds one shared HTTP client and keeps it, so a second call with a different apiKey, apiUrl or lang quietly reuses the first one.

Method parameters

configRequiredSubblyConfig

How to start the SDK. Leave it out, or pass an empty apiKey, and init rejects with Error('Missing required apiKey config').

ReturnsPromise<Subbly>

The SDK instance.

Start the SDK
import Subbly from '@subbly/sdk' const subbly = await Subbly.init({ apiKey: 'API_KEY', })
Start with a cart and a customer
const subbly = await Subbly.init({ apiKey: 'API_KEY', cartId: 'aaea067c-6364-4157-82e9-71b6edfd84a0', loadCart: true, accessToken: 'eyJh...eyJ9', })

subbly.setCurrency(currencyCode)

Sets the currency for the prices in later product, bundle and survey responses. The SDK sends it as the x-currency header.

It only fans the code out to subbly.products.setCurrency, subbly.bundles.setCurrency and subbly.surveys.setCurrency, which each store it for their own requests; an x-currency header you pass on a single call still wins.

This does not change the cart currency. Use subbly.cart.update({ currencyCode }) for that. When init loads a cart, it calls setCurrency with the cart currency itself.

Method parameters

currencyCodeRequiredstring

A currency abbreviation the shop supports, such as USD. Read the list from subbly.shop.currencies[].abbreviation.

Returnsvoid

Nothing.

Set the currency
subbly.setCurrency('EUR') // Later product prices come back in euros. const products = await subbly.products.list()

subbly.setLanguage(languageCode)

Sets the accept-language header the SDK sends with every later request.

Method parameters

languageCodeRequiredstring

A language code the shop supports. Read the list from subbly.shop.languages[].code.

Returnsvoid

Nothing.

Set the language
subbly.setLanguage('fr')

subbly.VERSION

A read-only property with the version of the @subbly/sdk package the page loaded. Useful in a bug report.

Returnsstring

The version of the @subbly/sdk package on the page.

Read the version
console.log(subbly.VERSION)

subbly.config

The three client values init received, exactly as you passed them. It leaves out cartId, loadCart and accessToken, and it does not follow a later setLanguage call.

subbly.config is not the configuration in use. The SDK applies its defaults deeper in, when it builds the HTTP client, so a value you left out stays undefined here.

ReturnsSubblyConfig

The values passed to init.

Read the configuration
const subbly = await Subbly.init({ apiKey: 'API_KEY' }) subbly.config.apiKey // 'API_KEY' subbly.config.apiUrl // undefined subbly.config.lang // undefined
Last modified on September 15, 2026
apiKeyRequiredstring

Your Storefront API key. The SDK sends it as the x-api-key header on every request, and you get it from Shop settings in Subbly Admin.

apiUrloptionalstring

Base URL of the Storefront API. Defaults to https://api.subbly.co/storefront/v1/. Change it only for a proxy or a test environment. An empty string falls back to the default.

langoptionalstring

Language code, sent as the accept-language header. Empty by default, so the server picks. Use a code from subbly.shop.languages[].code, and change it later with subbly.setLanguage.

cartIdoptionalstring

Cart to load at start-up. The SDK reads it only when loadCart is true, and falls back to the subbly_cart_id cookie when you leave it out.

loadCartoptionalboolean

Load or create a cart during start-up. false by default. When it is true, the SDK loads the cart named by cartId or the cookie, creates a new cart when there is none or the load fails, writes the subbly_cart_id cookie, and calls subbly.setCurrency with the cart currency. When it is false, subbly.cart has no id and the cart methods that need one fail.

accessTokenoptionalstring

Customer access token to verify at start-up. It beats the subbly_access_token cookie, and the SDK writes it to that cookie when the check passes. A failed check clears the cookie; it does not reject.

VERSIONstring

Version of the SDK package.

configSubblyConfig

The apiKey, apiUrl and lang the SDK started with.

cartCartModel

The cart: every field of the cart object, plus the cart methods. The Cart page writes the fields out.

shopSubblyShop

The shop: every field of the shop object, plus shop.load. The Shop page writes the fields out.

addresses, auth, bundles, checkout, countries, customers, funnels, lead, metafield, paymentIntents, pickupInfo, products, stock, subscriptions, surveys, walletobject

The rest of the namespaces, one per group in this reference. They are all built during init and are always present.

Javascript
Javascript
Javascript
Javascript
Javascript
apiKeystring

The Storefront API key you passed.

apiUrlstring | undefined

The base URL you passed, or undefined. The requests still go to https://api.subbly.co/storefront/v1/ in that case.

langstring | undefined

The language code you passed, or undefined. The server then picks the language.

Javascript