building an adapter
This walkthrough takes you from nothing to a registered, tested inbound adapter. It assumes you have read the adapter specification and understand the four required methods.
when to build a custom adapter
Use the built-in generic-webhook, csv-import, or poll-adapter whenever your source system outputs standard JSON or CSV with a straightforward field structure. They cover most cases and require no code.
Build a custom adapter when:
The source system has a proprietary wire format, non-JSON encoding, or unusual authentication scheme that the generic adapters cannot handle through field mapping alone.
The source system requires request signing or a custom auth handshake that the generic adapters don't support.
You have specific deduplication logic — for example, a source system that re-sends records with the same ID but different states and you need custom handling to pick the right one.
You need custom type mapping logic: the source system's event taxonomy doesn't map cleanly to the standard transaction type taxonomy and requires conditional logic.
step 1 — choose the adapter mode
Decide whether your adapter will be webhook, poll, or file import (or a combination). This determines the shape of your normalize() input.
Webhook
The source system pushes events to a URL on each transaction
Poll
The source system exposes an API you call to fetch recent transactions
File import
Operators upload batch exports from the source system
Create one adapter per mode. Avoid a single adapter that handles multiple modes — it becomes harder to test and maintain.
step 2 — implement adapter.meta()
This is the simplest method. Return static metadata describing your adapter.
The name must be unique across all registered adapters and follow the {source-system}-{mode} pattern.
step 3 — implement adapter.validate(input)
Validate the raw input before any normalization happens. Check that required fields are present and in the expected format. Return a clean errors array if everything is valid; return a list of error objects if not.
Be specific in your error messages — operators will read them in the Transactions page when a payload fails.
step 4 — implement adapter.normalize(input)
The core method. Call validate() first, then map source fields to the canonical schema.
Key rules in normalize():
Rules 9 and 10: do not set COA account codes, do not add top-level fields outside the schema.
Rules 2–8: see the adapter specification for the full list.
step 5 — implement adapter.healthcheck()
For a webhook adapter, return ok immediately — there is no source to call:
For a poll adapter, make a lightweight API call:
step 6 — write tests
Your adapter must include unit tests covering at minimum:
A valid completed transaction —
normalize()returnsstatus: "ok"with a correctly-formed canonical record.A failed transaction — record has
status: "failed"andmetadata._adapter_flag === "failed-passthrough".Missing required fields —
validate()returnsvalid: falsewith a non-emptyerrorsarray.A test-environment transaction — record has
source.environment: "test".
step 7 — add fixture files
Create a /fixtures directory inside your adapter folder. Add real or realistic anonymised payloads from the source system — one file per test scenario. Use these fixtures in your tests so they are grounded in actual source data, not invented shapes.
step 8 — write a README
Your adapter's README must document:
Supported modes
Required and optional config keys (in
SCREAMING_SNAKE_CASE)Any known limitations or edge cases
The
source_idstrategy you used, and what to do if the source system provides no stable IDAny custom
typevalues the adapter emits that fall outside the standard taxonomy, and why
step 9 — register the adapter
Place the adapter folder in the
/adaptersdirectory, following the{source-system}-{mode}naming convention.On the next Ledgerise startup, the engine calls
adapter.meta()and registers it.The engine calls
adapter.healthcheck()before the first run.Go to Settings → Adapters in the Ledgerise UI, find your adapter, enter its config values, and enable it.
→ See adapter specification § registration for full details
Last updated
