API Overview
The Ledgerline API is a RESTful JSON API that powers the Ledgerline storefront, Discord bot, and admin panel. Integrators can use the same API to build custom workflows, dashboards, or automations on top of Ledgerline.
Prerequisites
- A running Ledgerline instance with network access.
- A valid session (see Authentication).
Base URL
All API endpoints are served under the /api path prefix:
https://your-domain.com/api/...
Auth endpoints use /auth directly:
https://your-domain.com/auth/...
Core Resources
| Resource | Base Path | Description |
|---|---|---|
| Auth | /auth | Authentication, sessions, and tenant switching. |
| Orders | /api/data/order | Order CRUD, status management. |
| Customers | /api/data/customer | Customer profiles, addresses, linking. |
| Products | /api/data/product | Product catalog and configuration. |
| Inventory | /api/data/inventory | Stock snapshots and transactions. |
| Discounts | /api/data/discount | Discount codes and targeting rules. |
| Users | /api/data/user | Platform user accounts and roles. |
| Payments | /api/data/payment | Payment records and confirmation. |
| Webhook Events | /api/data/webhook-event | Inbound webhook event log. |
| Tenants | /api/data/tenant | Tenant configuration. |
| Community Fund | /api/admin/community-fund | Voluntary member contributions and disbursements (admin). |
Key Concepts
- Multi-tenancy — All data is scoped to a tenant. Every request must include a tenant identifier. See Tenant Scoping.
- Session-based auth — The API uses HTTP-only session cookies. See Authentication.
- Deterministic pricing — Order totals are computed server-side. Clients submit line items and the server calculates subtotals, discounts, and totals.
- Webhook-driven integrations — External payment providers notify Ledgerline via webhooks. See Webhooks.
- Discord interactions — The Discord bot receives interactions via
POST /discord/interactions: slash commands (type 2), message components (type 3), and modal submits (type 5). Responses may include content, embeds, components, or modals. See Discord API.
Request Format
- Content type:
application/json - Tenant header:
x-tenant-id(see Tenant Scoping) - Auth: session cookie (
ledgerline_auth)
Response Format
Successful responses return JSON with the resource object or an array of objects. Error responses follow a consistent error model described in API Conventions.