Skip to main content

API Reference

A compact map of every SDK method to the endpoint it calls. All endpoints live under /api/sdk and are protected as described in Security & Rate Limiting. Every network method returns a Promise.

Initialization​

const sdk = new SitePackSDK({ type: 'theme' | 'app', id: 'my-theme-or-app' });
OptionDefaultNotes
type'theme''theme' or 'app'.
id'default'Non-empty identifier for attribution.

Instance methods​

MethodEndpointVerb
generateLead(leadData)/leads/generatePOST
contactSiteOwner(contactData, trackAs?)/contactPOST

Ecommerce — sdk.ecommerce​

MethodEndpointVerb
getProducts(params?)/ecommerce/products/listGET
getProduct(productUuid)/ecommerce/productGET
fetchRelatedProducts(productUuid)/ecommerce/products/relatedGET
getCart(forceRefresh?)/ecommerce/cartGET
addToCart(productUuid, quantity?, retries?)/ecommerce/cart/addPOST
updateCartQuantity(productUuid, quantity)/ecommerce/cart/updatePATCH
clearCart()/ecommerce/cart/clearDELETE
getCheckoutInfo(data?)/ecommerce/checkout-infoPOST
claimCoupon(couponCode)/ecommerce/cart/couponPOST
fetchAddress(countryCode, postalCode, number)/ecommerce/addressGET
getCategories()/ecommerce/categoriesGET
getFilters(categorySlug)/ecommerce/category/filtersGET
getStockInfo(productUuid, forceRefresh?)/ecommerce/stock, or /ecommerce/stock/batch when several products are asked in the same tickGET
checkOrderCapability(productUuid, forceRefresh?)/ecommerce/products/check-capabilityGET

Cart-mutating methods emit sitepack:cart:updated, sitepack:cart:added and sitepack:cart:removed on window; createOrder() emits sitepack:order:created, and the order confirmation page raises sitepack:checkout:thank-you once the order is paid. Leads, newsletter, contact and login emit sitepack:lead:generated, sitepack:newsletter:subscribed, sitepack:contact:completed and sitepack:account:login. See Ecommerce and Storefront Blocks & Events.

Account​

MethodEndpointVerb
getUserInfo()/account/infoGET
login(email, password)/account/loginPOST
resetPassword(email)/account/reset-passwordPOST

Extra throttling applies — see Account.

Content — sdk.content​

MethodEndpointVerb
get(handle)/content/getGET
list(params?)/content/listGET
getLegalPages()/content/legalGET

Search — sdk.search​

MethodEndpointVerb
query(phrase, options?)/search/queryGET

Leads — sdk.leads​

MethodEndpointVerb
generate(leadData)/leads/generatePOST

Newsletter — sdk.newsletter​

MethodEndpointVerb
subscribe(email, options?)/newsletter/subscribePOST
unsubscribe(token)/newsletter/unsubscribePOST

USPs — sdk.usps​

MethodEndpointVerb
list(placement?)/uspsPOST

Events — sdk.events​

MethodEndpointVerb
list(limit?, scope?)/eventsPOST

scope is 'upcoming' (default), 'past' or 'all'.

Payments​

MethodEndpointVerb
getStatus(orderUuid)/payments/statusGET

UI — sdk.ui​

MethodTransportNotes
setHeight(height)postMessageTo the trusted site origin only.
notify(message, type?)postMessage + /ui/notify (POST)type: success | info | warning | error.

Cookies — sdk.cookies​

MethodNotes
set(name, value, days)First-party, SameSite=Lax, path=/. Client-side only.
get(name)Returns the value or null. Client-side only.

Globals injected by the platform​

GlobalPurpose
SITEPACK_CLIENT_IDRequest-binding hash (not a secret).
SITEPACK_CSRF_TOKENCSRF token for /api/sdk/*.
SITEPACK_SITE_UUIDCurrent site identifier.
SITEPACK_DOMAINSite origin, e.g. https://example.com.