Authentication
To interact with the WebbiOS Core API, your SDK instance must be authenticated. WebbiOS uses token-based authentication via API Keys.
Obtaining an API Key
Section titled “Obtaining an API Key”- Log in to your WebbiOS Admin Dashboard (
admin.webbios.devor your shop’s admin panel). - Navigate to Settings > API Keys.
- Click Generate New Key.
- Assign the appropriate permissions (e.g.,
read:products,write:orders). - Copy the generated token. Keep this secret!
Initializing the SDK
Section titled “Initializing the SDK”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);Environment Variables
Section titled “Environment Variables”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 });
// ... }};