Skip to content

Authentication

To interact with the WebbiOS Core API, your SDK instance must be authenticated. WebbiOS uses token-based authentication via API Keys.

  1. Log in to your WebbiOS Admin Dashboard (admin.webbios.dev or your shop’s admin panel).
  2. Navigate to Settings > API Keys.
  3. Click Generate New Key.
  4. Assign the appropriate permissions (e.g., read:products, write:orders).
  5. Copy the generated token. Keep this secret!

Pass your endpoint URL and the API token to the WebbiSDK constructor.

import { WebbiSDK } from '@webbi/sdk';
const sdk = new WebbiSDK({
// The base URL of the WebbiOS instance you are connecting to
endpoint: 'https://api.yourstore.com/v1/admin',
// Your secret API Token
token: 'YOUR_ACCESS_TOKEN'
});
// The SDK will now automatically include the Authorization header
// in all requests.
const me = await sdk.auth.me();
console.log('Authenticated as:', me.email);

For security reasons, you should never hardcode your API tokens in your source code. Instead, use environment variables:

import { WebbiSDK } from '@webbi/sdk';
const sdk = new WebbiSDK({
endpoint: process.env.WEBBIOS_API_ENDPOINT,
token: process.env.WEBBIOS_API_TOKEN
});

If you are running inside a Cloudflare Worker, use the env object provided by the Worker:

export default {
async fetch(request, env, ctx) {
const sdk = new WebbiSDK({
endpoint: env.WEBBIOS_API_ENDPOINT,
token: env.WEBBIOS_API_TOKEN
});
// ...
}
};