Skip to content

TypeScript / JavaScript

Terminal window
npm install @trustysweep/sdk
import { TrustySweep, SweepError, RateLimitError } from "@trustysweep/sdk";
const sweep = new TrustySweep({ apiKey: process.env.SWEEP_API_KEY });
for await (const s of sweep.sources.list({ connection_id: "cxn_…" })) console.log(s.display_name);
const { plan, receipt } = await sweep.sweep({ intent: "sweep", connection_id: "cxn_…", source_ids: ["src_…"], selection: { policy: true } });
  • Resources: providers, auth, account, billing, usage, connect, connections, sources, assets, diagnosis, graph, plans, executions, receipts, vault, migrations, destinations, automation, intel, creator, grants, principals, developer, events, jobs, webhooks.
  • PagePromise: await for the first page, for await for all items, .pages(), .all(max).
  • executions.waitFor(id) and jobs.waitFor(id) poll with backoff.
  • webhooks.constructEvent(rawBody, header, secret), receipts.verify(receipt, jwks?).
  • Errors: SweepError (problem document), RateLimitError (retryAfterSeconds), SweepConnectionError, WebhookSignatureError.
  • Options: baseUrl, fetch, maxRetries, timeoutMs, headers, credentials (browser session auth).

Types are generated from openapi.yaml; scripts/check-coverage.mjs fails the build if any operation lacks a method. Source: sdk-typescript/ in the platform repo.