Getting Started

Get Sync As A Service running in your app in 5 minutes.


Choose Your Integration Path

Path
Best For
Complexity
What You Get

Widget Only

Quick integration, user-facing features

⭐ Easy

Users connect retailers, you get notified

Widget + Backend API

Full data access, analytics, storage

⭐⭐⭐ Advanced

Full order data in your database


Path 1: Widget Only (Quickest)

The widget handles everything—authentication, retailer connection, and sync. You just embed it and react to events.

Step 1: Add the Widget

<div id="sync-widget"></div>

<script src="https://sync-api.stackline.com/sync-sdk/latest/sdk.umd.js"></script>
<script>
  SyncSDK.init({
    clientId: "bc_your_app_id",
    environment: "sandbox",
    container: document.getElementById("sync-widget"),

    // Called when sync completes
    onSync: (result) => {
      console.log(`Synced ${result.ordersFound} orders!`);
      showSuccessMessage(`Found ${result.ordersFound} orders`);
    },

    // Called for all widget events
    onEvent: (event, data) => {
      console.log("Widget event:", event, data);
    },
  });
</script>

Step 2: That's It!

The widget handles:

  • ✅ Phone authentication (OTP)

  • ✅ Retailer selection and login

  • ✅ MFA challenges

  • ✅ Sync progress

  • ✅ Error handling and retry

You receive:

  • onSync callback with { ordersFound } when sync completes

  • onEvent callbacks for tracking user progress

What you DON'T get:

  • ❌ Direct access to order data (products, prices, dates)

  • ❌ API access from your backend

When to use: You want to show users their connected retailers and sync status, but don't need to process order data yourself.


Path 2: Widget + Backend API (Full Integration)

You need this path if you want to:

  • Store order data in your own database

  • Process orders for rewards/analytics

  • Build features based on purchase history

How It Works

Step 1: Embed the Widget (Frontend)

Same as Path 1—the widget handles user experience:

Step 2: Implement OAuth2 (Backend)

To fetch order data from your backend, you need an access token. This requires implementing OAuth2:

2a. Redirect user to authorize:

2b. Exchange code for token:

2c. Store tokens securely:

Step 3: Fetch Order Data (Backend)

Now you can fetch orders from your backend:

Step 4: Display in Your App (Frontend)


Why Backend API vs Frontend?

Why can't the frontend call Sync As A Service directly?

  1. Security - Access tokens contain user data; exposing them to the browser is risky

  2. CORS - API doesn't allow direct browser calls (prevents token theft)

  3. Your data - You likely want orders in your database, not just displayed

The pattern:


Alternative: Webhooks (Coming Soon)

Instead of polling the API, we can push order data to your server:

Contact us to enable webhooks for your integration.


Test Credentials

For sandbox testing:

  • Phone: +1-555-0199

  • OTP Code: 424242

  • Demo Client: bc_demo_sync_beta


Go to Production

  1. Change environment: "sandbox"environment: "production"

  2. Update API URLs from sync-api-beta.stackline.comsync-api.stackline.com

  3. Use your production Client ID and Secret


What's Next?

Last updated

Was this helpful?