Docs

Client reference

AdminUpdated Sep 15, 2026

Client reference

Every method on the @cookiemunch/sdk client, grouped by namespace. All methods return Promises and throw CookieMunchApiError on non-2xx responses (see install & initialize). Each method maps 1:1 to a route documented in the REST API section — follow the links for full request/response details.

import { createCookieMunch } from '@cookiemunch/sdk';
const client = createCookieMunch({ apiKey: 'fck_…', baseUrl: 'https://api.cookiemunch.net' });

client.me()

me(): Promise<Identity>

Identity for the API key: { orgId, plan, keyPrefix }.

const { orgId, plan } = await client.me();

client.sites

Maps to /v1/sites/....

sites: {
  list(): Promise<Site[]>;
  create(input: SiteCreate): Promise<Site>;
  get(cbid: string): Promise<Site>;
  delete(cbid: string): Promise<void>;
  getConfig(cbid: string): Promise<SiteConfig>;
  putConfig(cbid: string, config: SiteConfig): Promise<SiteConfig>;
  cookies(cbid: string): Promise<SiteCookie[]>;
  scan(cbid: string): Promise<ScanResult>;
  scanStatus(cbid: string): Promise<ScanResult>;
  ab(cbid: string): Promise<AbResult[]>;
  snippet(cbid: string, opts?: SnippetOptions): Promise<InstallSnippet>;
  verify(cbid: string, method: 'dns' | 'meta' | 'file'): Promise<VerifyResult>;
  brand(cbid: string): Promise<BrandExtractionResult>;
}
const site = await client.sites.create({ domain: 'example.com' });
const config = await client.sites.getConfig(site.cbid);
await client.sites.putConfig(site.cbid, { ...config, banner: { ...config.banner, layout: 'popup' } });

const { snippet } = await client.sites.snippet(site.cbid, { blockingMode: 'auto', culture: 'en' });
// paste `snippet` into <head>

await client.sites.scan(site.cbid);                 // kick off a crawl
const status = await client.sites.scanStatus(site.cbid); // { status: 'scanning' | 'idle', lastScannedAt }

const { verified } = await client.sites.verify(site.cbid, 'dns');
const { suggestion } = await client.sites.brand(site.cbid); // "Match my site" theme extraction

client.consent

Maps to /v1/sites/{cbid}/consent/..., /v1/sites/{cbid}/receipt/{stamp}, /v1/sites/{cbid}/erase-consent, /v1/sites/{cbid}/subject-export — see consent & sites.

consent: {
  stats(cbid: string, query?: RangeQuery): Promise<ConsentDay[]>;
  log(cbid: string, query?: LogQuery): Promise<ConsentLogRow[]>;
  export(cbid: string, query?: RangeQuery): Promise<string>; // raw CSV text
  receipt(cbid: string, stamp: string): Promise<SignedReceipt>;
  eraseSubject(cbid: string, stamp: string): Promise<{ erased: number }>;
  exportSubject(cbid: string, stamp: string): Promise<{ cbid: string; stamp: string; records: unknown[]; count: number }>;
}
const days = await client.consent.stats(cbid, { from: Date.now() - 30 * 86_400_000 });
const recent = await client.consent.log(cbid, { limit: 50 });
const csv = await client.consent.export(cbid); // requires a verified domain

const receipt = await client.consent.receipt(cbid, 'stamp_abc123'); // requires a verified domain

// GDPR/CCPA erasure and portability, keyed by the consent-receipt stamp:
await client.consent.eraseSubject(cbid, 'stamp_abc123');   // irreversible
const bundle = await client.consent.exportSubject(cbid, 'stamp_abc123');

client.dsar

Maps to /v1/dsar.

dsar: {
  list(): Promise<DsarRequest[]>;
  create(input: DsarCreate): Promise<{ request: DsarRequest }>;
  advance(id: string, toStatus: DsarStatus): Promise<{ request: DsarRequest }>;
}
const { request } = await client.dsar.create({ type: 'access', subjectEmail: 'jane@example.com', regulation: 'gdpr' });
await client.dsar.advance(request.id, 'verifying');

client.vendors

Maps to /v1/vendors.

vendors: {
  list(): Promise<ScoredVendor[]>;
  create(input: VendorInput): Promise<{ vendor: Record<string, unknown>; risk: { score: number; band: string } }>;
}
const { vendor, risk } = await client.vendors.create({
  name: 'Segment', category: 'analytics', dataShared: ['device_id'],
  dpaSigned: true, subprocessors: 3, certifications: ['SOC2'], region: 'US',
});

client.ropa

Maps to /v1/ropa.

ropa: {
  list(): Promise<RopaEntry[]>;
  create(input: RopaInput): Promise<{ entry: RopaEntry }>;
}
const { entry } = await client.ropa.create({
  name: 'Email marketing', purpose: 'Send product updates', legalBasis: 'consent',
  dataCategories: ['email'], recipients: ['Mailchimp'], retentionDays: 730, crossBorderTransfer: true,
});

client.brandKits

Maps to /v1/brand-kits.

brandKits: {
  list(): Promise<BrandKit[]>;
  create(input: BrandKitCreate): Promise<{ kit: BrandKit }>;
  delete(id: string): Promise<void>;
}
const { kit } = await client.brandKits.create({ name: 'House style', theme: { primary: '#1a1a1a' } });
await client.brandKits.delete(kit.id);

client.preferences

Maps to /v1/preferences.

preferences: {
  list(): Promise<PreferenceItem[]>;
  save(subjectId: string, purposes: Record<string, boolean>): Promise<unknown>;
}
await client.preferences.save('jane@example.com', { newsletter: true, sms: false });

client.members

Maps to /v1/members.

members: {
  list(): Promise<Member[]>;
  invite(email: string, role: string): Promise<{ member: { userId: string; email: string; role: string } }>;
  setRole(userId: string, role: string): Promise<{ member: { userId: string; email: string; role: string } }>;
  remove(userId: string): Promise<unknown>;
}
await client.members.invite('teammate@example.com', 'admin');
await client.members.setRole('usr_2', 'viewer');
await client.members.remove('usr_2');

Note: members, keys, and webhooks are admin-only — only an unscoped API key can call these. See API keys, members, webhooks & usage.

client.keys

Maps to /v1/keys.

keys: {
  list(): Promise<ApiKey[]>;
  issue(input?: ApiKeyIssueInput): Promise<ApiKey>;
}
const { key, prefix } = await client.keys.issue(); // `key` is shown once — store it now

client.usage()

usage(): Promise<Usage>

Maps to GET /v1/usage.

const { domains, seats, monthlyEvents } = await client.usage();

client.webhooks

Maps to /v1/webhooks. Event catalogue and signature verification: Webhooks & events.

webhooks: {
  list(): Promise<WebhookSubscription[]>;
  create(input: WebhookCreate): Promise<WebhookSubscription>;
  delete(id: string): Promise<void>;
}
const sub = await client.webhooks.create({
  url: 'https://example.com/hooks/cookiemunch',
  events: ['consent.recorded', 'dsar.created'],
});
console.log(sub.secret); // store this now — it's never returned again
await client.webhooks.delete(sub.id);

client.banners

Maps to banner library.

banners: {
  list(): Promise<BannerSummary[]>;
  create(input: { name: string; json: SiteConfig }): Promise<BannerRecord>;
  get(id: string): Promise<BannerRecord>;
  update(id: string, patch: { name?: string; json?: SiteConfig }): Promise<BannerRecord>;
  delete(id: string): Promise<void>;
  assignments(id: string): Promise<{ cbids: string[] }>;
  setAssignments(id: string, cbids: string[]): Promise<{ cbids: string[] }>;
  publish(id: string): Promise<{ publishedCbids: string[] }>;
}
const design = await client.banners.create({ name: 'EU banner — dark', json: { v: 2, flow: { views: [] }, categories: [] } });
await client.banners.setAssignments(design.id, [site.cbid]);
const { publishedCbids } = await client.banners.publish(design.id);

Full example: onboard a site end to end

import { createCookieMunch } from '@cookiemunch/sdk';

const client = createCookieMunch({ apiKey: process.env.COOKIEMUNCH_API_KEY!, baseUrl: 'https://api.cookiemunch.net' });

const site = await client.sites.create({ domain: 'shop.example.com' });
await client.sites.verify(site.cbid, 'dns');

const { snippet } = await client.sites.snippet(site.cbid);
// hand `snippet` to whoever manages the site's <head>

await client.webhooks.create({ url: 'https://example.com/hooks/cookiemunch', events: ['consent.recorded'], cbid: site.cbid });

See also: MCP tools reference — the same capabilities exposed as tools for an AI agent, built directly on this SDK.

Was this page helpful?
Client reference