soundlink package to call the Public API with full TypeScript types. For raw HTTP, see Quickstart. Not sure which approach fits your stack? See SDK overview.
Prerequisites
- API key (
sk_*) with the scopes you need — Authentication - Node.js 18+ or an Edge runtime with
fetch
SOUNDLINK_API_KEY). Never hardcode keys or ship them to the browser.
1. Install
2. Initialize the client
new Soundlink('sk_your_prefix_your_secret').
The client sends x-api-key on every request. Your organization is determined from the key.
3. Ping and list campaigns
campaigns:read scope. Equivalent curl examples are in Quickstart.
Paginate all campaigns
Create and manage wallet campaigns
Requirescampaigns:write. Write methods take { idempotencyKey } — the SDK sends the Idempotency-Key header. Only generation: 3 (wallet) campaigns support budget, tiers, and stop. See Creating campaigns and Managing campaigns.
Response pattern
Every method returns{ data, error, meta? } — the same envelope as the REST API. HTTP errors are not thrown; check error and use requestId when contacting support.
Metrics and exports
await soundlink.metrics.breakdown.export.collect('f1e28d31-c358-4284-9bef-00a2334625fd').
Engagement exports work the same way: soundlink.metrics.engagement.export and .export.collect.
See Understanding metrics and JSONL exports.
Configuration
Methods
Every method maps 1:1 to a Public API route. All returnPromise<ApiResponse<T>> unless noted.
System
Strategies
Requirescampaigns:read.
Campaigns (read)
Requirescampaigns:read.
list params: page, pageSize (max 100), sortBy (createdAt | status), sortOrder (asc | desc).
Campaigns (write)
Requirescampaigns:write. Pass { idempotencyKey } on create, stop, and budget methods. Wallet campaigns only (generation: 3) for budget / tiers / stop.
Metrics
Requiresmetrics:read.
Date params use inclusive
YYYY-MM-DD. Export windows are capped at 90 days per request. Breakdown list pageSize max is 500.
Types
All public types are exported fromsoundlink for use in your app:
Row shapes match the warehouse schemas documented in Understanding metrics. For full field lists, use the API Reference or your IDE hover hints on the imported types.
Errors
The SDK has two error paths. Most of the time you only need the first.API errors (returned, not thrown)
When the Public API returns4xx or 5xx, the SDK resolves with { data: null, error, meta? }:
error before using data. Error codes and HTTP mapping: Errors.
SDK errors (thrown)
These extendSoundlinkSdkError and mean something went wrong outside a normal API response:
try/catch for client setup and rare transport failures. Use { data, error } for everything the API returns.