Repository navigation
Getting Started
This page takes you from zero to your first authenticated Backoffice API call, first with the JavaScript SDK
(@selldone/sdk-backoffice) and then with plain HTTP. If you only need the REST API from a server, you can jump to
Fast Start.
- A Selldone shop and its numeric shop ID.
- An access token with the scopes you need. See Access Token. For the examples on this page, the
ERP Bridge link from Fast Start (
backoffice:shop:read,backoffice:product:read,backoffice:product:write,backoffice:category:read) is enough. - For the SDK: a browser application built with a bundler (the SDK reads
<meta>tags and registers globals onwindow), and Node.js with npm or Yarn to install packages.
npm install @selldone/sdk-backoffice @selldone/core-jsyarn add @selldone/sdk-backoffice @selldone/core-js@selldone/core-js is already a dependency of the SDK. Installing it explicitly lets you import SelldoneCore
directly.
The SDK builds every URL from values in the page head. Add these tags to your index.html:
<meta name="service-url" content="https://selldone.com">
<meta name="selldone-api" content="https://api.selldone.com">| Meta tag | Read by | Purpose |
|---|---|---|
service-url |
SelldoneCore.Setup() |
Main Selldone URL. Setup throws if it is missing. |
selldone-api |
window.API |
Base URL of every Backoffice endpoint. |
csrf-token |
BackofficeSDK.Setup() |
Optional. Sent as X-CSRF-TOKEN. Without it, the console shows CSRF token not found!. |
If you cannot edit the page head (for example in an embedded widget), define the same keys on window.selldone_config
before you call Setup(). Selldone Core reads that object when a meta tag is missing:
window.selldone_config = {
"service-url": "https://selldone.com",
"selldone-api": "https://api.selldone.com",
};import { SelldoneCore } from "@selldone/core-js";
import { BackofficeSDK } from "@selldone/sdk-backoffice";
SelldoneCore.Setup(); // 1. Core first
BackofficeSDK.Setup(); // 2. Registers window.API and window.$backofficeBackofficeSDK.Setup():
- configures
window.axioswith theX-Requested-With,X-Platform: webandS-Timezoneheaders, and sends requests with credentials (cookies); - creates
window.API(the URL builder catalog) and its aliaseswindow.ADDRESS_APIandwindow.ARTICLE_API; - creates
window.$backofficewith the namespaces listed in JavaScript SDK.
It throws console.style not found. Please initialize 'SelldoneCore.Setup()' before initializing the Backoffice SDK.
if Selldone Core was not set up first.
BackofficeSDK.Setup() sends requests with cookies and the CSRF token, but it does not add an Authorization
header. In your own application, attach your access token to every request:
window.axios.defaults.headers.common["Authorization"] = `Bearer ${ACCESS_TOKEN}`;const SHOP_ID = 12345;
const { products, total } = await window.$backoffice.product.list(SHOP_ID, 0, 10, {
products_only: true,
with_total: true,
});
console.log(`Loaded ${products.length} of ${total} products`);
// Read one product with its variants, images and vendor data
const { product } = await window.$backoffice.product.getInfo(SHOP_ID, products[0].id, 0, 10);
// Set the stock of that product
const { quantity } = await window.$backoffice.product.setQuantity(SHOP_ID, product.id, 120);Every SDK method maps to one REST endpoint, so you can make the same calls from any language:
GET https://api.selldone.com/shops/12345/products/all-admin?offset=0&limit=10&products_only=true&with_total=true
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/jsonPOST https://api.selldone.com/shops/12345/products/9876/quantity
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
{ "quantity": 120 }try {
await window.$backoffice.product.setQuantity(SHOP_ID, PRODUCT_ID, 120);
} catch (error) {
if (error?.error) {
// The API answered with { error: true, error_msg, code }
console.warn(error.error_msg);
} else {
// Network error or HTTP error status (401, 403, 404, 422, 429, 5xx)
console.error(error);
}
}- JavaScript SDK: the full namespace reference, caching and cancellation
- Fast Start: the REST workflow for product and inventory sync
- Access Token: choose the right authentication method and scopes
- Rate Limits: stay within the request budget
- FAQ
Guides
Products
- Fetch Products List
- Edit Product
- Edit Product's Variant
- Add Images to Products/Variants
- Upload Products Category Image
Marketplace vendors
- Get Vendors List
- Vendor Products List
- Vendor Product Add
- Vendor Product Update
- Vendor Product Delete
Ecosystem
Links