Overview / SDKs

SDKs

Official client libraries for .NET, Laravel and Node.js. Each one covers every endpoint in this reference with typed models, walks paginated lists for you, retries rate-limited requests and verifies webhook signatures.

What every SDK does for you

AuthenticationSends your API key and secret on every request. Without explicit options the client reads FLACTRUM_API_KEY, FLACTRUM_API_SECRET and FLACTRUM_BASE_URL.
Every endpointEach resource is a property and each method mirrors an operation id from this reference — products.list becomes products.list().
PaginationList calls return a page object that can walk every following page on demand.
ErrorsFailures raise a single exception type carrying the stable error code, HTTP status and per-field validation messages.
Retries429 responses are retried after Retry-After. Network errors and 5xx are retried for GET, PUT and DELETE only; give a POST an idempotency key to make it safe to retry.
FilesFile fields are sent as multipart automatically; exports and downloads come back as files.
WebhooksVerifies X-Flactrum-Signature against the raw body and hands you the parsed event.

Create a key in the panel under System → API keys. The secret is shown once.

Install

Package @flactrum/sdkNode 16+ESM and CommonJSFully typed
npm install @flactrum/sdk

Configure and make a first request

With no options the client reads the FLACTRUM_* environment variables. The key may also be passed as a single "key:secret" string.

import { Flactrum } from '@flactrum/sdk';

const flactrum = new Flactrum({
  apiKey: process.env.FLACTRUM_API_KEY,      // flk_…
  apiSecret: process.env.FLACTRUM_API_SECRET,
  language: 'en',                            // optional: translatable fields
});

const product = await flactrum.products.create({ name: 'Latte', price: 95 });
const orders = await flactrum.orders.list({ per_page: 50 });

// CommonJS
const { Flactrum } = require('@flactrum/sdk');

Pagination

Lists return a Page. Iterate it with for await to walk every following page.

const page = await flactrum.customers.list({ per_page: 100, updated_since: '2026-10-01T00:00:00Z' });

page.data;      // this page
page.meta;      // { total, page, per_page, last_page }
page.hasMore;

for await (const customer of page) {
  // every customer, fetched page by page
}

Errors

import { FlactrumError } from '@flactrum/sdk';

try {
  await flactrum.products.create({ name: 'Latte' } as any);
} catch (error) {
  if (error instanceof FlactrumError) {
    error.status;   // 422
    error.code;     // 'validation_failed'
    error.fields;   // { price: ['The price field is required.'] }
    error.details;  // e.g. missing scopes for 'insufficient_scope'
  }
}

Retries, timeouts and idempotency

const flactrum = new Flactrum({ apiKey, apiSecret, maxRetries: 3, timeoutMs: 15_000 });

await flactrum.orders.create(order, { idempotencyKey: crypto.randomUUID(), timeoutMs: 60_000 });

Files

File fields accept a Blob, Uint8Array, ArrayBuffer or toFile(bytes, name, type). Exports return the bytes.

import { readFile, writeFile } from 'node:fs/promises';
import { toFile } from '@flactrum/sdk';

await flactrum.products.update(id, {
  image: toFile(await readFile('latte.jpg'), 'latte.jpg', 'image/jpeg'),
});

const file = await flactrum.cashRecords.export(id, { format: 'pdf' });
await writeFile(file.filename ?? 'cash.pdf', file.data);

Webhooks

Verify against the raw body, before parsing JSON. Event names are exported as WEBHOOK_EVENTS.

import express from 'express';
import { Webhook, WebhookSignatureError } from '@flactrum/sdk';

app.post('/flactrum/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  try {
    const event = Webhook.constructEvent(
      req.body,
      req.header('X-Flactrum-Signature'),
      process.env.FLACTRUM_WEBHOOK_SECRET!,
    );

    if (event.event === 'order.completed') {
      // event.data …
    }

    res.sendStatus(204);
  } catch (error) {
    if (error instanceof WebhookSignatureError) return res.sendStatus(400);
    throw error;
  }
});

Any other endpoint

const body = await flactrum.request({ method: 'GET', path: '/products', query: { page: 2 } });

Webhook deliveries

Every delivery is signed as X-Flactrum-Signature: sha256=<HMAC-SHA256 of the raw body> with the webhook's secret. X-Flactrum-Delivery is unique per delivery — store it to process each one once.

Answer with a 2xx quickly and do heavy work in the background. Every attempt is recorded in the panel's delivery log with the status code and body you returned, and an endpoint that keeps failing is paused automatically.