Skip to main content

Node SDK

Official TypeScript SDK for HeadshotMarketing — programmatic access to campaigns, leads, contacts, deals, pipelines, social, ads, SEO, content, and more.

Installation

bun add @headshotmarketing/sdk
# or
npm install @headshotmarketing/sdk

Quick start

import { HeadshotmarketingSDK } from '@headshotmarketing/sdk';

// Defaults to production gateways
const sdk = new HeadshotmarketingSDK();

// 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 campaigns = await sdk.headshotmarketing.campaigns.list();
const leads = await sdk.headshotmarketing.leads.list();

Environment

The SDK targets production by default. Set BURDENOFF_ENV or pass explicit endpoints:

// Production (default)
const sdk = new HeadshotmarketingSDK();

// Explicit alpha
const sdkAlpha = new HeadshotmarketingSDK({
workspaceEndpoint: 'https://alphagraphqlworkspaces.burdenoff.com/workspaces/graphql',
globalEndpoint: 'https://alphagraphql.burdenoff.com/global/graphql',
});

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:
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.

NamespaceDescription
sdk.authSign in/up, OAuth flows, token management
sdk.headshotmarketingHeadshotMarketing domain — campaigns, leads, contacts, deals, pipelines, social, ads, seo, content, assets, landingPages, events, influencers, audiences, workflows, aiTools, reports, dashboards
sdk.sandboxEphemeral, TTL-bound sandbox environments
sdk.billingSubscriptions, invoices, plans, addons, credits, refunds
sdk.channelsChannel-based pub/sub
sdk.conversationsConversation CRUD + settings
sdk.devportalApps, OAuth, API keys, webhooks, delegations
sdk.exportExport jobs, templates, downloads
sdk.filesBrowse, upload, share files
sdk.groupsGroup management
sdk.healthGateway/service health probes
sdk.integrationsThird-party integrations + connections
sdk.notificationsNotification center + preferences
sdk.organizationsOrganizations + invites
sdk.productsProducts, shortcuts, content pages, feature flags
sdk.rbacPermissions, role assignment
sdk.schedulerScheduled jobs + executions
sdk.securityVaults, secrets
sdk.storeMarketplace — search, cart, orders, installs, publisher
sdk.supportTickets + knowledge base
sdk.tagsTag CRUD + tagging
sdk.toursOnboarding tours + progress
sdk.workspacesWorkspace CRUD + members + projects + invites

Configuration

interface HeadshotmarketingSDKConfig {
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 { HeadshotmarketingError, AuthenticationError, NetworkError } from '@headshotmarketing/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/headshotmarketing-sdk-node.git
cd headshotmarketing-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)