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' });
| Option | Default | Notes |
|---|---|---|
type | 'theme' | 'theme' or 'app'. |
id | 'default' | Non-empty identifier for attribution. |
Instance methods
| Method | Endpoint | Verb |
|---|---|---|
generateLead(leadData) | /leads/generate | POST |
contactSiteOwner(contactData) | /contact | POST |
Ecommerce — sdk.ecommerce
| Method | Endpoint | Verb |
|---|---|---|
getProducts(params?) | /ecommerce/products/list | GET |
getProduct(productUuid) | /ecommerce/product | GET |
fetchRelatedProducts(productUuid) | /ecommerce/products/related | GET |
getCart(forceRefresh?) | /ecommerce/cart | GET |
addToCart(productUuid, quantity?, retries?) | /ecommerce/cart/add | POST |
updateCartQuantity(productUuid, quantity) | /ecommerce/cart/update | PATCH |
clearCart() | /ecommerce/cart/clear | DELETE |
getCheckoutInfo(data?) | /ecommerce/checkout-info | POST |
claimCoupon(couponCode) | /ecommerce/cart/coupon | POST |
fetchAddress(countryCode, postalCode, number) | /ecommerce/address | GET |
getCategories() | /ecommerce/categories | GET |
getFilters(categorySlug) | /ecommerce/category/filters | GET |
getStockInfo(productUuid) | /ecommerce/stock | GET |
checkOrderCapability(productUuid, forceRefresh?) | /ecommerce/products/check-capability | GET |
Cart-mutating methods emit sitepack:cart:updated on window. See Ecommerce.
Account
| Method | Endpoint | Verb |
|---|---|---|
getUserInfo() | /account/info | GET |
login(email, password) | /account/login | POST |
resetPassword(email) | /account/reset-password | POST |
Extra throttling applies — see Account.
Content — sdk.content
| Method | Endpoint | Verb |
|---|---|---|
get(handle) | /content/get | GET |
list(params?) | /content/list | GET |
getLegalPages() | /content/legal | GET |
Search — sdk.search
| Method | Endpoint | Verb |
|---|---|---|
query(phrase, options?) | /search/query | GET |
Leads — sdk.leads
| Method | Endpoint | Verb |
|---|---|---|
generate(leadData) | /leads/generate | POST |
Payments
| Method | Endpoint | Verb |
|---|---|---|
getStatus(orderUuid) | /payments/status | GET |
UI — sdk.ui
| Method | Transport | Notes |
|---|---|---|
setHeight(height) | postMessage | To the trusted site origin only. |
notify(message, type?) | postMessage + /ui/notify (POST) | type: success | info | warning | error. |
Cookies — sdk.cookies
| Method | Notes |
|---|---|
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
| Global | Purpose |
|---|---|
SITEPACK_CLIENT_ID | Request-binding hash (not a secret). |
SITEPACK_CSRF_TOKEN | CSRF token for /api/sdk/*. |
SITEPACK_SITE_UUID | Current site identifier. |
SITEPACK_DOMAIN | Site origin, e.g. https://example.com. |