Node SDK
Official TypeScript SDK for Subscriberbot — programmatic access to subscription providers, plans, relationships, entitlements, invoices, renewals, and more.
Installation
bun add @subscriberbot/sdk
# or
npm install @subscriberbot/sdk
Quick Start
import { SubscriberbotSDK } from '@subscriberbot/sdk';
const sdk = new SubscriberbotSDK({
workspaceEndpoint: 'https://graphqlworkspaces.burdenoff.com/workspaces/graphql',
globalEndpoint: 'https://graphql.burdenoff.com/global/graphql',
});
// Sign in
await sdk.auth.signIn({ username: '[email protected]', password: 'secret' });
// Fetch workspaces and issue workspace token
const workspaces = await sdk.auth.fetchWorkspaces();
await sdk.auth.issueWorkspaceToken(workspaces[0].id, workspaces[0].organizationId);
// Use the SDK
const providers = await sdk.subscriberbot.providers.list();
const relationships = await sdk.subscriberbot.relationships.list();
Authentication
Email / Password
const auth = await sdk.auth.signIn({ username: '[email protected]', password: 'secret' });
OAuth2 Device Code Flow
const { userCode, verificationUri, promise } = await sdk.auth.loginWithDeviceCode();
console.log(`Open ${verificationUri} and enter: ${userCode}`);
const tokens = await promise;
OAuth2 Authorization Code + PKCE
const challenge = sdk.auth.getAuthorizationUrl({
redirectUri: 'http://localhost:8400/callback',
scopes: ['openid', 'profile', 'email', 'offline_access'],
});
// Redirect user to challenge.url, then exchange the code:
const tokens = await sdk.auth.exchangeAuthCode(code, challenge.codeVerifier, challenge.redirectUri);
Client Credentials (M2M / App Auth)
const result = await sdk.auth.authenticateApp(clientId, clientSecret);
Workspace Token
await sdk.auth.issueWorkspaceToken(workspaceId, organizationId);
Modules
The SDK is a thin shell over @burdenoff/sdk-libs; each domain is mounted as a nested namespace.
| Namespace | Description |
|---|---|
sdk.auth | Sign in/up, OAuth flows, token management |
sdk.subscriberbot | Subscriberbot domain — providers, plans, relationships, assets, entitlements, renewalEvents, invoices, paymentInstruments, channels, inbox, agents, policies, workflows, system |
sdk.sandbox | Ephemeral, TTL-bound sandbox environments |
sdk.billing | Subscriptions, invoices, plans, addons, credits, refunds |
sdk.channels | Channel-based pub/sub |
sdk.conversations | Conversation CRUD + settings |
sdk.devportal | Apps, OAuth, API keys, webhooks, delegations |
sdk.export | Export jobs, templates, downloads |
sdk.files | Browse, upload, share files |
sdk.groups | Group management |
sdk.health | Gateway/service health probes |
sdk.integrations | Third-party integrations + connections |
sdk.notifications | Notification center + preferences |
sdk.organizations | Organizations + invites |
sdk.products | Products, shortcuts, content pages, feature flags |
sdk.rbac | Permissions, role assignment |
sdk.scheduler | Scheduled jobs + executions |
sdk.security | Vaults, secrets |
sdk.store | Marketplace — search, cart, orders, installs, publisher |
sdk.support | Tickets + knowledge base |
sdk.tags | Tag CRUD + tagging |
sdk.tours | Onboarding tours + progress |
sdk.workspaces | Workspace CRUD + members + projects + invites |
Configuration
interface SubscriberbotSDKConfig {
workspaceEndpoint: string; // Workspace gateway GraphQL endpoint
globalEndpoint: string; // Global gateway GraphQL endpoint
oidcIssuer?: string; // OIDC issuer URL (derived from globalEndpoint if omitted)
clientId?: string; // OAuth2 client ID
clientSecret?: string; // OAuth2 client secret
redirectUri?: string; // Redirect URI for auth code flow
apiKey?: string; // API key authentication
accessToken?: string; // Pre-existing access token
refreshToken?: string; // Pre-existing refresh token
workspaceToken?: string; // Pre-existing workspace token
timeout?: number; // Request timeout in ms (default: 30000)
autoRefresh?: boolean; // Auto-refresh tokens (default: true)
onTokenRefresh?: (tokens: TokenPair) => void | Promise<void>;
}
Error Handling
import { SubscriberbotError, AuthenticationError, NetworkError } from '@subscriberbot/sdk';
try {
await sdk.auth.signIn({ username: 'invalid', password: 'invalid' });
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Auth failed:', error.message);
} else if (error instanceof NetworkError) {
console.error('Network error:', error.message);
}
}
Development
git clone https://github.com/algoshred/subscriberbot-sdk-node.git
cd subscriberbot-sdk-node
bun install
bun run dev # Watch mode
bun run build # Production build
bun run test # Run tests
bun run sanity # All checks (format, lint, type-check, test, build)
Environment selection
The SDK defaults to production endpoints. Pass explicit endpoints for local or alpha, or set BURDENOFF_ENV before running your application if the SDK reads it from the environment. See Environment Selection for endpoint details.
Related
- Repository:
subscriberbot-sdk-node - Python SDK:
subscriberbot-sdk-python - CLI:
subscriberbot-cli