Create a payment
liveRecord money paid on one issued sales invoice (incoming) or posted purchase invoice (outgoing), by bank transfer or in cash, and post its entry. The document's amount_paid and status follow.
Details
With transaction_id the payment is linked to an imported transaction that already posted it, and nothing is posted (a migration's historical payment). A bank statement line is reconciled on the bank line instead, which records its payments itself.
Parameters
headers and queryOptional replay guard for a POST (DA-065). Send a key the CLIENT generates (a uuid per user-initiated request, reused across retries of that same request). The server performs the operation at most once per (organization, key) and answers a replay with the ORIGINAL response (status, headers and body), so a double-clicked Save or a retry after an ambiguous timeout never creates or posts anything twice.
Details
A request that FAILED frees its key, so retrying after a genuine error proceeds normally. Reusing a key with a DIFFERENT body is a client bug, not a retry, and returns 409 IDEMPOTENCY_KEY_REUSED rather than the earlier response. Keys are kept for 24 hours; a retry after that is a new request. Omitting the header keeps the previous behaviour exactly.
Validate and compute without storing anything: the answer is what the real request would answer (status, errors, computed totals, assigned numbers) but nothing is saved, posted or sent, and the response carries Tracken-Dry-Run: true.
Request body
application/json · requiredA payment to record, and the document it settles.
Most used attributes of data
Money in (a customer pays a sales invoice, a supplier refunds a purchase) or out (a purchase invoice is paid, a customer is refunded). Named, never implied by a sign.
One of incoming, outgoing
The money that moved, positive, in currency. In the document's currency it is at most what is still due on the document and equals the allocation's amount.
How it was paid: bank_transfer posts to the bank account's ledger account, cash to the organization's default cash account.
One of bank_transfer, cash
The one document this payment settles.
3 attributes of each item
Currency of amount, the money that moved (ISO 4217): that of the bank or cash account. Defaults to the document's currency.
For bank_transfer: the bank account it moved on; defaults to the organization's default bank account. Not sent with cash.
4 more attributes
An imported transaction (origin: import, posted by no document) that already books this payment: the payment is linked to it and nothing is posted. Its receivable (sales) or payable (purchase) lines must carry the amount in the payment's direction beyond the payments already linked to it in that direction (400 PAYMENT_TRANSACTION_NOT_LINKABLE otherwise).
Details
It is already linked (409 PAYMENT_TRANSACTION_LINKED) when those payments cover all it carries in that direction, or when a payment of this invoice is linked to it. A linked payment may be a refund (direction against the document's) and may settle a credit note. On an invoice brought over too (origin import or opening) the linked payment is recorded whatever the invoice's approval state: it records money that already moved and pays nothing out. A live invoice's payment, linked or not, needs its approval (APPROVAL_*). A caller holding ledger:write and invoices:write can record history that never passes approval; approval guards money going out, not booked history. On a document in another currency the payment is in the book currency (amount the euros that moved, the allocation what it settled) or in the document's (the journal's bank lines are then the euros), and is the transaction's only payment. Its rate and book figures are the app's own settlement when the journal booked exactly that (its receivable or payable the book value released, its bank the euros), else read off the journal; refused (400 PAYMENT_TRANSACTION_NOT_LINKABLE) when the journal cannot be read as the payment's booking.
What a create does when a record of the same resource already holds the sent external_ref. error: 409 EXTERNAL_REF_EXISTS with existing_id. return: 200 with the existing record, unchanged.
One of error, return, update
Details
update: apply the sent fields to it as a PATCH would and answer 200; refused like a PATCH when the record is no longer editable.
Responses
errors use the error envelope| 200 | Payment · An existing payment with this external_ref (on_conflict return). |
| 201 | Payment · The recorded payment. |
| 400 | The request fails validation. This operation's own codes: BANK_ACCOUNT_NOT_FOUND, DEFAULT_AP_ACCOUNT_NOT_CONFIGURED, DEFAULT_AR_ACCOUNT_NOT_CONFIGURED, DEFAULT_BANK_ACCOUNT_NOT_CONFIGURED, DEFAULT_CASH_ACCOUNT_NOT_CONFIGURED, DIMENSION_PROHIBITED, DIMENSION_REQUIRED_MISSING, PAYMENT_AMOUNT_NOT_POSITIVE, PAYMENT_DIRECTION_MISMATCH, PAYMENT_EXCEEDS_BALANCE, PAYMENT_METHOD_REQUIRES_SETTLEMENT, PAYMENT_ON_CREDIT_NOTE, PAYMENT_ON_DRAFT, PAYMENT_ON_PREPAYMENT_INVOICE, PAYMENT_TRANSACTION_NOT_LINKABLE, PERIOD_NOT_FOUND_FOR_DATE. |
| 401 | No token, an expired token, or a token for another audience (UNAUTHENTICATED). |
| 402 | The organization's subscription is not active (SUBSCRIPTION_INACTIVE): the trial ended without a plan, a payment is overdue, the subscription was cancelled, or the accounting firm that paid for it stopped. context.reason says which (trial_ended, not_paid, cancelled, payer_stopped; accept values you do not know) and context.export_until the last day (ISO date) the organization's data can still be exported. Every operation is refused, reads included, except reading the current user and the organization and the data export. A retry unchanged fails the same way: an owner reopens the subscription in the app. |
| 403 | Not allowed. This operation's own codes: APPROVAL_REQUIRED, PERIOD_HARD_GATED. |
| 404 | Not found. This operation's own codes: INVOICE_NOT_FOUND, TRANSACTION_NOT_FOUND. |
| 409 | Conflicts with the resource's state. This operation's own codes: DIMENSION_CONFIRM_REQUIRED, EXTERNAL_REF_EXISTS, EXTRA_MONTH_CONFIRM_REQUIRED, PAYMENT_INVOICE_NOT_ISSUED, PAYMENT_TRANSACTION_LINKED, PERIOD_CONFIRM_REQUIRED, WORK_MONTH_CONFIRM_REQUIRED. An API credential cannot confirm a month: a person confirms it in the app, then retry the request unchanged, with the same Idempotency-Key; context names the month, its price and currency. |
| 429 | Rate limit exceeded (RATE_LIMITED). Wait Retry-After seconds. |
Errors this operation can return
switch oncode, never on message| Code | Status | When |
|---|---|---|
IDEMPOTENCY_KEY_REUSED | 409 | Idempotency-Key: Reusing a key with a DIFFERENT body is a client bug, not a retry, and returns 409 IDEMPOTENCY_KEY_REUSED rather than the earlier response. |
BANK_ACCOUNT_NOT_FOUND | 400 | That bank account no longer exists. |
DEFAULT_AP_ACCOUNT_NOT_CONFIGURED | 400 | No default accounts-payable account is configured. |
DEFAULT_AR_ACCOUNT_NOT_CONFIGURED | 400 | No default accounts-receivable account is configured. |
DEFAULT_BANK_ACCOUNT_NOT_CONFIGURED | 400 | No default bank account is configured. |
DEFAULT_CASH_ACCOUNT_NOT_CONFIGURED | 400 | No default cash account is configured. |
DIMENSION_PROHIBITED | 400 | This dimension isn't allowed on this account. |
DIMENSION_REQUIRED_MISSING | 400 | This account requires ‹dimension›. |
20 more codes
PAYMENT_AMOUNT_NOT_POSITIVE | 400 | Payment amount must be greater than zero. |
PAYMENT_DIRECTION_MISMATCH | 400 | The payment goes the wrong way for this invoice: a customer pays a sales invoice in, a supplier's invoice is paid out. |
PAYMENT_EXCEEDS_BALANCE | 400 | Payment can't exceed the remaining balance. |
PAYMENT_METHOD_REQUIRES_SETTLEMENT | 400 | An offset can't be recorded as a payment. |
PAYMENT_ON_CREDIT_NOTE | 400 | A credit note can't take a payment. |
PAYMENT_ON_DRAFT | 400 | A draft invoice can't take a payment. |
PAYMENT_ON_PREPAYMENT_INVOICE | 400 | A prepayment invoice is paid by the receipt it was made from. |
PERIOD_NOT_FOUND_FOR_DATE | 400 | No accounting period covers this date. |
APPROVAL_REQUIRED | 403 | The record must be approved first. |
PERIOD_HARD_GATED | 403 | This period is done and your role isn't permitted to write into it. |
INVOICE_NOT_FOUND | 404 | That invoice no longer exists. |
TRANSACTION_NOT_FOUND | 404 | That transaction no longer exists. |
DIMENSION_CONFIRM_REQUIRED | 409 | This account is missing a required dimension. |
EXTERNAL_REF_EXISTS | 409 | on_conflict: error: 409 EXTERNAL_REF_EXISTS with existing_id. |
EXTRA_MONTH_CONFIRM_REQUIRED | 409 | This change falls outside the working month, so this month is billed separately. |
PAYMENT_INVOICE_NOT_ISSUED | 409 | A payment can only be recorded once the purchase invoice is confirmed. |
PERIOD_CONFIRM_REQUIRED | 409 | This changes figures already marked done for this period. |
WORK_MONTH_CONFIRM_REQUIRED | 409 | This change starts the plan year's working month, so the working month must be confirmed first. |
PAYMENT_TRANSACTION_NOT_LINKABLE | 400 | data.transaction_id: Its receivable (sales) or payable (purchase) lines must carry the amount in the payment's direction beyond the payments already linked to it in that direction (400 PAYMENT_TRANSACTION_NOT_LINKABLE otherwise). |
PAYMENT_TRANSACTION_LINKED | 409 | data.transaction_id: It is already linked (409 PAYMENT_TRANSACTION_LINKED) when those payments cover all it carries in that direction, or when a payment of this invoice is linked to it. |
Plus the general codes every operation can answer (UNAUTHENTICATED, RATE_LIMITED …): handle them once.