SUQODocs
User GuideAPI ReferenceSDKs

Examples

Runnable example scripts for the SUQO TypeScript SDK.

The SDK ships a set of runnable scripts under examples/ in its repository — real calls against your own sandbox, not mocked. The Quickstart walks through the full end-to-end flow; this page covers the other scripts.

The snippets below are excerpts from those actual scripts, verified against them, not hand-written from memory. If something here ever looks wrong, the real, runnable source under examples/ is the source of truth.

Setup

examples/ isn't part of the published @suqo/sdk package (only the built library is) — to run these scripts as-is, clone the SDK's repository first:

git clone https://github.com/suqo-ai/suqo-sdk-ts
cd suqo-sdk-ts
npm install
npm run build   # examples import @suqo/sdk the same way your own project would

Set SUQO_API_KEY to a sandbox key (su_test_key_...), then run any script with tsx:

SUQO_API_KEY=su_test_key_... npx tsx examples/list-products.ts

Browsing the catalog

const page = await suqo.products.list();
for (const product of page.results) {
  console.log(`${product.name} — ${product.productId}`);
}

The subscription lifecycle

Continuing from the subscription created in Quickstart:

// Cancel — schedules for the end of the current billing period, not immediate
await suqo.subscriptions.cancel(subscription.subscriptionId);

// Change the next billing date
await suqo.subscriptions.updateBillingCycle({
  subscriptionId: subscription.subscriptionId,
  nextBillingCycle: "2027-06-01", // any date from today onward
});

// Resume
await suqo.subscriptions.resume(subscription.subscriptionId);

Listing and retrieving customers

const page = await suqo.customers.list();
const first = page.results[0];
if (first) {
  const fetched = await suqo.customers.retrieve(first.id);
  console.log(fetched);
}

Verifying a webhook, without a real delivery

Signing a payload the same way SUQO's backend does lets you exercise verify() end to end — genuine, tampered, and stale — with no network call at all:

import { createHmac } from "node:crypto";

const secret = "whsec_example_only_do_not_reuse";
const timestamp = String(Math.floor(Date.now() / 1000));
const rawBody = JSON.stringify({ event: "checkout.succeeded", subscription_id: "...", amount: "500.00", status: "succeeded" });
const signature = `sha256=${createHmac("sha256", secret).update(`${timestamp}.`).update(rawBody).digest("hex")}`;

suqo.webhooks.verify({ rawBody, signature, timestamp, secret }); // → true
Testing against a live key? Creating a subscription sends a real SMS/email to whatever customer.phone/customer.email you use. Use a dedicated test number and your own email address — never a real customer's.

On this page