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
| Authentication | Sends 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 endpoint | Each resource is a property and each method mirrors an operation id from this reference — products.list becomes products.list(). |
| Pagination | List calls return a page object that can walk every following page on demand. |
| Errors | Failures raise a single exception type carrying the stable error code, HTTP status and per-field validation messages. |
| Retries | 429 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. |
| Files | File fields are sent as multipart automatically; exports and downloads come back as files. |
| Webhooks | Verifies 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
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 } });
Install
composer require flactrum/laravel
Add the credentials to .env. Publishing the config file is optional.
FLACTRUM_API_KEY=flk_...
FLACTRUM_API_SECRET=...
# FLACTRUM_LANGUAGE=en
# FLACTRUM_WEBHOOK_SECRET=...
php artisan vendor:publish --tag=flactrum-config
First request
Use the facade, or inject Flactrum\Laravel\FlactrumClient. Responses are arrays (the API's data).
use Flactrum\Laravel\Facades\Flactrum;
$product = Flactrum::products()->create(['name' => 'Latte', 'price' => 95]);
$product = Flactrum::products()->show($id, ['branch' => $branchId]);
Flactrum::products()->update($id, ['price' => 99]);
Flactrum::products()->delete($id);
// Several brands, or another language for one call
$client = Flactrum::withCredentials($brand->flactrum_key, $brand->flactrum_secret);
$client->orders()->list();
Flactrum::withLanguage('de')->menu()->show();
Pagination
Lists return a Flactrum\Laravel\Page; lazy() walks every page as a lazy collection.
$page = Flactrum::customers()->list(['per_page' => 100, 'updated_since' => now()->subDay()->toIso8601String()]);
$page->items(); // this page (array)
$page->total();
$page->hasMorePages();
Flactrum::customers()->list(['per_page' => 100])
->lazy()
->each(fn (array $customer) => Customer::syncFromFlactrum($customer));
Errors
use Flactrum\Laravel\Exceptions\FlactrumException;
try {
Flactrum::products()->create(['name' => 'Latte']);
} catch (FlactrumException $e) {
$e->status; // 422
$e->errorCode; // 'validation_failed'
$e->fields(); // ['price' => ['The price field is required.']]
$e->details; // e.g. missing scopes for 'insufficient_scope'
}
Retries, timeouts and idempotency
Defaults come from config/flactrum.php (timeout, retries).
Flactrum::orders()->create($order, options: [
'idempotency_key' => (string) Str::uuid(),
'timeout' => 60,
'retries' => 3,
]);
Files
File fields accept an UploadedFile, an SplFileInfo, a stream or Upload. Exports return a FileDownload.
use Flactrum\Laravel\Upload;
Flactrum::products()->update($id, ['image' => $request->file('photo')]);
Flactrum::products()->update($id, ['image' => Upload::fromPath(storage_path('latte.jpg'))]);
$file = Flactrum::cashRecords()->export($id, ['format' => 'pdf']);
$file->store('exports', 's3'); // to a disk
return $file->toResponse(); // to the browser
Webhooks
The route verifies X-Flactrum-Signature with FLACTRUM_WEBHOOK_SECRET and answers 400 on a mismatch. Queue heavy work in a ShouldQueue listener.
// routes/api.php
Route::flactrumWebhooks('flactrum/webhook');
// a listener
use Flactrum\Laravel\Events\WebhookReceived;
use Flactrum\Laravel\Generated\WebhookEvents;
Event::listen(function (WebhookReceived $webhook) {
if ($webhook->event === WebhookEvents::ORDER_COMPLETED) {
// $webhook->data, $webhook->brandId(), $webhook->deliveryId …
}
});
// or your own controller
Route::post('hooks/flactrum', MyWebhookController::class)->middleware('flactrum.webhook');
Testing your code and other endpoints
The client is built on Laravel's HTTP client, so Http::fake() works as usual.
Http::fake([
'api.flactrum.com/v1/products*' => Http::response(['data' => ['id' => 'p1', 'name' => 'Latte']]),
]);
$json = Flactrum::request('GET', '/products', ['page' => 2]);
Install
dotnet add package Flactrum.Sdk
Configure and make a first request
new FlactrumClient() with no options reads the FLACTRUM_* environment variables. The client is thread-safe: create it once.
using Flactrum;
using Flactrum.Models;
using Flactrum.Queries;
var flactrum = new FlactrumClient(new FlactrumOptions
{
ApiKey = "flk_...",
ApiSecret = "...",
});
var product = await flactrum.Products.CreateAsync(new ProductInput { Name = "Latte", Price = 95 });
var orders = await flactrum.Orders.ListAsync(new OrdersListQuery { PerPage = 50 });
ASP.NET Core
AddFlactrum registers the client with IHttpClientFactory and returns the IHttpClientBuilder, so you can add handlers (logging, proxies, Polly).
builder.Services.AddFlactrum(o =>
{
o.ApiKey = builder.Configuration["Flactrum:ApiKey"];
o.ApiSecret = builder.Configuration["Flactrum:ApiSecret"];
o.Language = "en";
});
// then inject FlactrumClient
Partial updates
Input classes send only the properties you assign, so a PATCH changes only those fields; assigning null sends an explicit null.
await flactrum.Products.UpdateAsync(id, new ProductInput { Price = 99, Description = null });
// PATCH body: {"price":99,"description":null}
Pagination
var page = await flactrum.Customers.ListAsync(new CustomersListQuery { PerPage = 100, UpdatedSince = "2026-10-01T00:00:00Z" });
page.Data; // this page
page.Meta; // Total, Page, PerPage, LastPage
page.HasMore;
await foreach (var customer in page.AllAsync())
{
// every customer, fetched page by page
}
Errors
try
{
await flactrum.Products.CreateAsync(new ProductInput { Name = "Latte" });
}
catch (FlactrumException e) when (e.IsValidation)
{
// e.Status == 422, e.Code == "validation_failed"
// e.Fields["price"] == ["The price field is required."]
}
Retries, timeouts and idempotency
await flactrum.Orders.CreateAsync(order, new RequestOptions
{
IdempotencyKey = Guid.NewGuid().ToString(),
Timeout = TimeSpan.FromSeconds(60),
});
Files
File fields take a FlactrumFile; exports return a FileDownload.
await flactrum.Products.UpdateAsync(id, new ProductInput { Image = FlactrumFile.FromPath("latte.jpg") });
var file = await flactrum.CashRecords.ExportAsync(id, new CashRecordsExportQuery { Format = "pdf" });
file.SaveTo(file.FileName ?? "cash.pdf");
Webhooks
Verify the raw body before parsing JSON.
app.MapPost("/flactrum/webhook", async (HttpRequest request) =>
{
using var ms = new MemoryStream();
await request.Body.CopyToAsync(ms);
try
{
var evt = FlactrumWebhook.ConstructEvent(ms.ToArray(), request.Headers[FlactrumWebhook.SignatureHeader], secret);
if (evt.Event == WebhookEvents.OrderCompleted)
{
var order = evt.DataAs<Order>();
}
return Results.NoContent();
}
catch (WebhookSignatureException)
{
return Results.BadRequest();
}
});
Any other endpoint
JsonElement body = await flactrum.RequestAsync("GET", "/products", new Dictionary<string, object?> { ["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.