Add
[POST] .../v1/docpayment/add
Creates a new payment document. Create an unposted income or expense payment and return new_id; use Perform to post it. Requires add permission for the category direction and account access. Omitted attached_user_id uses the current user. Base currency uses rate 1; other currencies use the supplied positive rate or current rate. Optional stock_id must match the company. Business errors return HTTP 200 ErrorResult.
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| amount | Decimal | Required | Required payment amount. Must be greater than 0 and supports up to 3 decimal places. |
| attached_user_id | Int64 | Optional | Responsible user ID. If omitted or 0, the current request user is used. |
| category_id | Int64 | Required | Required income or expense category ID. The category direction selects income or outcome permissions. |
| contract_id | Int64 | Optional | Optional contract document ID. |
| date | Int64 | Required | Required document date as Unix time in seconds. |
| description | String | Optional | Optional additional description. Maximum length is 300 characters. |
| document | Int64 | Optional | Optional ID of the document used as the payment basis. |
| document_type_id | Int64 | Optional | Optional ID of the document type used as the payment basis. |
| exchange_rate | Decimal | Optional | Optional exchange rate for non-base currency payments. If omitted or 0, the current currency exchange rate is used; base-currency payments use 1. |
| fields | Array of FieldValueAdd | Optional | Optional custom field values. Required custom fields for payment documents must be supplied when configured. |
| firm_id | Int64 | Required | Required ID of the company participating in the payment. |
| partner_id | Int64 | Required | Required partner ID. |
| stock_id | Int64 | Optional | Optional stock ID belonging to firm_id. Omitted, null or 0 means no stock. The document basis is not used to select a stock. |
| type_id | Int64 | Required | Required payment type ID. The payment type determines the account and currency used by the payment. |
Request Example
{
"date": 1714550400,
"type_id": 3,
"document": 101,
"document_type_id": 7,
"firm_id": 2,
"partner_id": 15,
"category_id": 3,
"contract_id": 12,
"amount": 2500000.000,
"description": "Prepayment from partner"
}
Response Parameters
| Name | Type | Description |
|---|---|---|
| ok | Boolean | Indicates whether the request completed successfully. |
| result | Insert | Created record result. |
Response Example
{
"ok": true,
"result": {
"new_id": 42
}
}