Public API reference
This is the stable part of the API: the routes a partner app, an integration or
a script can build on and keep. Version 1.6. The same document, as
OpenAPI, is served by your installation at /api/v1/openapi.public.json and
committed as docs/_generated/public-openapi.json; the typed TypeScript SDK
(@erp/sdk) is generated from it. Everything else under /api/v1 is the
product's own and may change in any release — the full index is
The API.
Authentication
Send Authorization: Bearer <credential> on every call.
- An API key (
erpapi.…) — issued by an administrator on Settings → Integrations → API clients, bound to a role and narrowed by scopes. For a system of your own: a till, a webstore, a script. - An OAuth access token (
erpoat_…) — granted to a partner app by a person on the consent screen, through the authorization-code flow with PKCE. It acts as that person in that company, narrowed to the scopes they approved, and never more. It lasts an hour; refresh it with its refresh token (erport_…, thirty days, rotated on every use). See The developer platform.
Pagination
A list answers {items, total, limit, offset, next_offset}. Ask for the next
page with offset=next_offset; next_offset is null on the last page. limit
is at most 200. The SDK's paginate() does this for you.
Money
An amount is a string of digits, never a JSON number, in the shape its schema
shows: "12.50" or {"amount": "12.50", "currency": "USD"}. A receipt's
amounts and an invoice line's unit price also take a plain "12.50", in the
customer's or invoice's currency; a supplier payment's amount also takes
{"amount", "currency"} beside the payment's own currency when the two are
the same. An amount in a currency the document is not in is refused, never
converted or ignored.
Idempotency keys
Send Idempotency-Key: <a unique string> on any POST, PUT, PATCH or
DELETE and a retried request is performed once. The retry is answered with
the first answer and the header Idempotent-Replay: true. The same key with
a different body is refused (409). The SDK sends one for you and keeps it
across its retries.
A retry sent while the first attempt is still running waits up to three
seconds for it and then answers as it did. Every endpoint behaves the same
way; a slower one, such as splitting a bank deposit across several
customers, can still be running after three seconds, and the retry is then
answered 409 idempotency_key_in_flight. Nothing was done twice: send it
again in a moment with the same key.
Errors
Every refusal is JSON with a stable code, a message written for a person,
and the request_id to quote when you ask for help:
{ "code": "permission_denied", "message": "…", "permission": "customer.read", "request_id": "…" }
A refusal for want of a permission names it as permission, for a program to
act on; the SDK's ErpApiError carries it.
| Status | Means |
|---|---|
| 400, 422 | The request needs fixing; message says what |
| 401 | The credential is not valid: refresh the token, or ask for a new key |
| 403 | The credential lacks the permission, or the company has switched that app off |
| 404 | No such record, in this company |
| 409 | Somebody changed it first, or a reused idempotency key |
| 429 | Over the rate limit: wait Retry-After seconds |
Rate limits
Per API key and per partner app in each company, 120 requests a minute unless
the company's administrator changed it. Over it the answer is 429 with
Retry-After in seconds, and nothing else is done. The SDK waits and retries.
Versioning
Within /api/v1 a public route only grows: new optional parameters, new
response fields, new routes. Ignore fields you do not know. A route marked
beta is published but outside that promise.
Routes
POST /api/v1/oauth/revoke
Revoke a token. Revoke an access or refresh token (RFC 7009). A refresh token takes its family.
Since 1.0 · stable · authentication: none — anybody may read it
Answers 200 with any.
POST /api/v1/oauth/token
Exchange a code or a refresh token for tokens. Exchange an authorization code, or a refresh token, for tokens (RFC 6749 §4.1.3, §6).
Since 1.0 · stable · authentication: none — anybody may read it
Answers 200 with OAuthAppTokenResponse.
GET /api/v1/public/customers
List customers. Customers, by name, a page at a time.
Since 1.0 · stable · authentication: bearer
| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
q | query | string or null | no | Name, number or tax id. |
status | query | CustomerStatus or null | no | Only customers in this status. |
limit | query | integer | no | At most 200. |
offset | query | integer | no | Where the page starts. |
Answers 200 with PublicApiCustomerPage.
GET /api/v1/public/customers/{customer_id}
Get a customer. One customer.
Since 1.0 · stable · authentication: bearer
| Parameter | In | Type | Required | What it is |
|---|---|---|---|---|
customer_id | path | string | yes | — |
Answers 200 with PublicApiCustomer.
GET /api/v1/public/whoami
Who am I. Who this credential is, in which company, holding what.
Since 1.0 · stable · authentication: bearer
Answers 200 with PublicApiWhoAmI.
POST /api/v1/tax/quote
Quote tax on lines. What these lines would be taxed — as an order of them would charge.
Since 1.0 · stable · authentication: bearer
Body: QuoteRequest.
Answers 200 with QuoteResponse.
GET /api/v1/webhooks/catalogue
Webhook event catalogue. Every event a webhook can be told, with its version and payload schema (A7, E1).
Since 1.0 · stable · authentication: none — anybody may read it
Answers 200 with WebhookCatalogue.
Schemas
AmountLimitResponse
The floor or cap that decided a tax's amount.
| Field | Type | Always sent | What it is |
|---|---|---|---|
kind | LimitKind | yes | — |
per | string | yes | — |
count | string | yes | — |
unlimited | string | yes | — |
AppliedTaxResponse
| Field | Type | Always sent | What it is |
|---|---|---|---|
tax_code_id | string | yes | — |
code | string | yes | — |
name | string | yes | — |
jurisdiction_id | string | yes | — |
jurisdiction_name | string | yes | — |
kind | TaxKind | yes | — |
basis | TaxBasis | yes | — |
burden | ExciseBurden | yes | — |
rate | string | yes | — |
taxable | MoneySchema-Output | yes | — |
amount | MoneySchema-Output | yes | — |
measured_quantity | string or null | yes | — |
measure | string or null | yes | — |
exempted_by | string or null | yes | — |
exemption_reason | ExemptionReason or null | yes | — |
limit | AmountLimitResponse or null | no | — |
percent_of | PercentOf or null | no | — |
bracket | QuoteBracketResponse or null | no | — |
relief | QuoteReliefResponse or null | no | — |
discount | MoneySchema-Output or null | no | — |
CustomerKind
The legal nature of a customer.
one of organisation, individual.
CustomerStatus
Where an account is in its life.
one of prospect, pending_approval, active, on_hold, inactive.
ExciseBurden
Who ends up paying an excise tax.
one of passed_on, absorbed.
ExemptionReason
Why a customer is not charged tax.
one of resale, exempt_organisation, manufacturing, export, licensed_distributor, other.
HTTPValidationError
| Field | Type | Always sent | What it is |
|---|---|---|---|
detail | list of ValidationError | no | — |
JurisdictionLevel
How far down a taxing authority sits.
one of country, state, county, city, special.
JurisdictionResponse
| Field | Type | Always sent | What it is |
|---|---|---|---|
id | string | yes | — |
code | string | yes | — |
name | string | yes | — |
level | JurisdictionLevel | yes | — |
country_code | string | yes | — |
subdivision | string or null | yes | — |
subdivision_code | string or null | no | — |
city | string or null | yes | — |
postal_code | string or null | yes | — |
county_fips | string or null | no | — |
county | string or null | yes | — |
registration_number | string or null | yes | — |
is_active | boolean | yes | — |
version | integer | yes | — |
LicenceStatus
What the regulator says about a licence today.
one of unverified, verified, suspended, revoked.
LicenceType
What a licence permits.
one of tobacco, cigarette, vape, kratom, atc, resale, sales_tax, drivers_licence, hemp, distributor, manufacturer, other.
LimitKind
Which bound decided a tax's amount.
one of floor, cap.
MoneySchema-Input
A monetary amount in an API request or response.
| Field | Type | Always sent | What it is |
|---|---|---|---|
amount | number or string | yes | — |
currency | string | yes | — |
MoneySchema-Output
A monetary amount in an API request or response.
| Field | Type | Always sent | What it is |
|---|---|---|---|
amount | string | yes | — |
currency | string | yes | — |
OAuthAppTokenResponse
RFC 6749 §5.1.
| Field | Type | Always sent | What it is |
|---|---|---|---|
access_token | string | yes | — |
token_type | string | no | — |
expires_in | integer | yes | — |
refresh_token | string | yes | — |
scope | string | yes | — |
PactScopeReason
Why a shipped line is on a PACT report, or is not. One per line.
one of covered, forced_in, not_covered, unclassified, handed_over, licensed_distributor, forced_out.
PercentOf
What a percentage tax is a percentage of.
one of line_amount, manufacturer_list, wholesale_cost, retail_price.
PublicApiApp
| Field | Type | Always sent | What it is |
|---|---|---|---|
client_id | string | yes | — |
name | string | yes | — |
PublicApiCustomer
A customer, in the public API's stable shape.
| Field | Type | Always sent | What it is |
|---|---|---|---|
id | string | yes | — |
number | string | yes | — |
name | string | yes | — |
legal_name | string or null | yes | — |
dba_name | string or null | yes | — |
status | string | yes | — |
email | string or null | yes | — |
phone | string or null | yes | — |
website | string or null | yes | — |
currency | string | yes | — |
created_at | string | yes | — |
updated_at | string | yes | — |
PublicApiCustomerPage
One page of customers. Ask for the next with offset=next_offset.
| Field | Type | Always sent | What it is |
|---|---|---|---|
items | list of PublicApiCustomer | yes | — |
total | integer | yes | — |
limit | integer | yes | — |
offset | integer | yes | — |
next_offset | integer or null | yes | — |
PublicApiWhoAmI
Who a credential is, where, and with what.
| Field | Type | Always sent | What it is |
|---|---|---|---|
company_id | string | yes | — |
company_name | string | yes | — |
actor_type | string | yes | — |
principal_id | string or null | yes | — |
app | PublicApiApp or null | yes | — |
permissions | list of string | yes | — |
api_version | string | yes | — |
QuoteBasis
What a quote's answer about the buyer rests on.
one of on_file, caller_stated.
QuoteBracketResponse
What a statute's bracket decided on one line (audit of 21 October, 20).
| Field | Type | Always sent | What it is |
|---|---|---|---|
key | string | yes | — |
sale_taxable | string | yes | — |
sale_tax | string | yes | — |
unbracketed | string | yes | — |
QuoteBuyerResponse
Who the quote was priced for, and what about them it rested on.
| Field | Type | Always sent | What it is |
|---|---|---|---|
customer_id | string or null | no | — |
ship_to_id | string or null | no | — |
name | string or null | no | — |
stated_licences | list of StatedLicence | no | — |
stated_licences_ignored | boolean | no | — |
sale_to_a_person_no_account | boolean | no | — |
note | string or null | no | — |
QuoteChannel
How the goods a quote prices reach the buyer.
one of delivery, counter, web.
QuoteLine
One line to price.
| Field | Type | Always sent | What it is |
|---|---|---|---|
item_id | string | yes | — |
quantity | number or string | yes | — |
net | MoneySchema-Input | yes | An amount and its currency, {"amount": "12.50", "currency": "USD"}, or the amount alone as a string, "12.50", in the currency of the document it is for. Never a JSON number. |
reference | string or null | no | — |
discount | MoneySchema-Input or null | no | An amount and its currency, {"amount": "12.50", "currency": "USD"}, or the amount alone as a string, "12.50", in the currency of the document it is for. Never a JSON number. |
QuoteLineResponse
| Field | Type | Always sent | What it is |
|---|---|---|---|
reference | string or null | yes | — |
taxes | list of AppliedTaxResponse | yes | — |
charged | MoneySchema-Output | yes | — |
absorbed | MoneySchema-Output | yes | — |
trace | list of TaxTraceLineResponse | no | — |
pact | QuotePactScopeResponse or null | no | — |
notes | list of QuoteNoteResponse | no | — |
QuoteNoteResponse
A gate the sale will ask, said on the quote instead of refusing it.
| Field | Type | Always sent | What it is |
|---|---|---|---|
cause | string | yes | — |
message | string | yes | — |
QuotePactScopeResponse
Whether a sale like this line would be on a PACT filing, and why.
| Field | Type | Always sent | What it is |
|---|---|---|---|
reason | PactScopeReason | yes | — |
included | boolean | yes | — |
QuoteReliefResponse
A tax due only on the first sale to a retailer, decided by the buyer (audit of 21 October, 20).
| Field | Type | Always sent | What it is |
|---|---|---|---|
buyer | string | yes | — |
sentence | string | yes | — |
licence_number | string or null | no | — |
current_on | string or null | no | — |
authority | string | no | — |
QuoteRequest
What to tax, where it is going, and when.
| Field | Type | Always sent | What it is |
|---|---|---|---|
lines | list of QuoteLine | yes | — |
on | string | yes | — |
country_code | string or null | no | — |
subdivision | string or null | no | — |
city | string or null | no | — |
postal_code | string or null | no | — |
county_fips | string or null | no | — |
record_type | string or null | no | — |
record_id | string or null | no | — |
channel | QuoteChannel | no | — |
customer_id | string or null | no | — |
ship_to_id | string or null | no | — |
store_id | string or null | no | — |
ships_on | string or null | no | — |
buyer | StatedBuyer or null | no | — |
QuoteResponse
| Field | Type | Always sent | What it is |
|---|---|---|---|
lines | list of QuoteLineResponse | yes | — |
jurisdictions | list of JurisdictionResponse | yes | — |
charged | MoneySchema-Output | yes | — |
absorbed | MoneySchema-Output | yes | — |
rounding | Rounding | yes |