Create a key
Owners and admins create keys on the Integrations page. There are two kinds:
- Tick only the permissions the software needs, for example Record expenses and Read balances.
- Optionally limit it to some accounts, an amount per transaction, an amount it may hold, a list of server IP addresses, and an end date.
- Copy the key. It is shown once; only a fingerprint is stored.
| Key | Starts with | Use it |
|---|---|---|
| Server key | nf_sk_ | On your own servers. Refused from browsers. |
| Public key | nf_pk_ | In a website or app, only from the websites you list on it. |
Install and record an expense
1// npm install @neuctra/finance
2import { NeuctraFinance } from "@neuctra/finance";
3
4const finance = new NeuctraFinance({
5 serverUrl: process.env.NEUCTRA_FINANCE_URL,
6 apiKey: process.env.NEUCTRA_FINANCE_KEY, // nf_sk_...
7});
8
9const { transaction, account } = await finance.expenses.record({
10 accountId: "acc_3f9a1c",
11 amount: 1200,
12 category: "Rent",
13 reference: "RENT-2026-11",
14});
15
16console.log(account.available); // what is left to spendHandle the answers that matter
Every error has a code your software can act on. The three you will meet most:
| Code | Meaning | What to do |
|---|---|---|
| INSUFFICIENT_FUNDS | Not enough available money. Nothing was deducted. | Tell the owner; err.details.shortBy says by how much. |
| APPROVAL_REQUIRED | Above the account's approval line. | Send a spend request instead. |
| PLAN_LIMIT | The owner's monthly API allowance is used up. | Wait for the 1st, or ask Neuctra to raise it. |
Retries are safe
Networks fail. Every write the SDK sends carries an idempotency key, and the SDK retries timeouts and temporary errors with the same key, so an expense is never recorded twice.
For extra safety across restarts, pass your own key, such as your purchase order number: idempotencyKey: "PO-1042". Reusing a key for a different request is refused with IDEMPOTENCY_MISMATCH.
Try it in a test business
Create a separate business for testing, with its own keys. When everything works, create a key in your real business and swap it in. The full API is described at /v1/openapi.json on the server, and the SDK and API docs list every call.
