Server setup
Use the published Node package for invoices, or call the HTTP API directly.
On this page
Install the Node package
forwend 0.2.0 requires Node 20 or later and has no runtime dependencies. It covers checkout sessions, payments, invoices, stores and webhook events, plus verifyWebhook.
The base URL must be https, or http on localhost while you develop.
npm install forwend@0.2.0Create an invoice
import { Forwend } from "forwend";
const forwend = new Forwend({
apiKey: process.env.FORWEND_KEY!,
profileId: process.env.FORWEND_PROFILE_ID!,
baseUrl: process.env.FORWEND_API_URL!,
});
const invoice = await forwend.invoices.create(
{ amountUsd: "1250.00", metadata: { order_id: "1042" } },
{ idempotencyKey: "order-1042" },
);
const latest = await forwend.invoices.get(invoice.invoiceId);Handle errors and pagination
The client throws ForwendError with status, code and retryAfter for API errors. Act on code, not message text.
The client tries a rate limit again after a short Retry-After, and a lost answer on reads and keyed creates, with the same idempotency key.
Lists are async iterables. Iterate with for await to request further pages. The client generates a create idempotency key when omitted; supply your own stable order key for retries across process restarts.