Skip to content

Getting Started

Mehrdad Pajuhaan edited this page Oct 23, 2026 · 1 revision

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.

Prerequisites

  • 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 on window), and Node.js with npm or Yarn to install packages.

1. Install

npm install @selldone/sdk-backoffice @selldone/core-js
yarn 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.

2. Configure the endpoints

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",
};

3. Initialize the SDK

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.$backoffice

BackofficeSDK.Setup():

  • configures window.axios with the X-Requested-With, X-Platform: web and S-Timezone headers, and sends requests with credentials (cookies);
  • creates window.API (the URL builder catalog) and its aliases window.ADDRESS_API and window.ARTICLE_API;
  • creates window.$backoffice with 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.

4. Authenticate

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}`;

5. Make your first call

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);

The same calls over HTTP

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/json
POST https://api.selldone.com/shops/12345/products/9876/quantity
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

{ "quantity": 120 }

Handle errors

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);
  }
}

Next steps

Clone this wiki locally