[POST] .../v1/docinvoice/add
Creates an invoice document. Use this method to create an invoice header manually before adding item lines with InvoiceOperation/Add or before sending an already prepared invoice through EDI. The request body must contain date, firm_id, partner_id, currency_id, invoice_type and vat_calculation_type; code, contract_id, source document fields, corrected source fields, exchange_rate, description and attached_user_id are optional or conditional by business workflow. The method validates invoice direction when a contract_id is supplied, checks the invoice tariff, resolves exchange_rate from the currency catalog for non-base currency when needed and for Corrective invoices validates the supported source document workflow. The current request user must have invoice add permission; validation, permission, tariff, contract direction, source document, currency, database, transaction or webhook failures are returned as HTTP 200 ErrorResult business errors.
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| attached_user_id | Int64 | Optional | Responsible user ID. If omitted or 0, the API uses the current request user. |
| code | String | Optional | Invoice code. If omitted, the API generates the next invoice number. Maximum length is 50 characters. |
| contract_id | Int64 | Optional | Contract ID. Optional; positive values assign a contract and the contract direction must match invoice_type. |
| corrected_code | String | Optional | Code of the corrected source document. Used only for corrective invoices when the source document code is supplied by the request. Maximum length is 50 characters. |
| corrected_date | Int64 | Optional | Date of the corrected source document as Unix time in seconds. Used only for corrective invoices when the source document date is supplied by the request. |
| currency_id | Int64 | Required | Currency ID. |
| date | Int64 | Required | Invoice date as Unix time in seconds. |
| description | String | Optional | Additional description. Maximum length is 300 characters. |
| document_id | Int64 | Optional | ID of the source document that the corrective invoice is created from. Required by business logic for supported corrective workflows. |
| document_type_id | Int64 | Optional | ID of the source document type that the corrective invoice is created from. Required by business logic for supported corrective workflows. |
| exchange_rate | Decimal | Optional | Exchange rate. Optional; base currency uses 1 and missing non-base rate is taken from the currency catalog. |
| firm_id | Int64 | Required | Company ID. |
| invoice_type | String | Required | Invoice document type: Income - incoming invoice, Outcome - outgoing invoice, Corrective - corrective invoice. Allowed values: Default, Income, Outcome, Corrective. |
| partner_id | Int64 | Required | Partner ID. |
| vat_calculation_type | String | Required | VAT calculation mode: No - do not accrue, Exclude - included in the amount, Include - added on top. Allowed values: No, Exclude, Include. |
Request Example
{
"code": "INV-0009101",
"date": 1767225600,
"contract_id": 701,
"firm_id": 1,
"partner_id": 301,
"currency_id": 1,
"exchange_rate": 1,
"description": "Invoice for wholesale shipment",
"invoice_type": "Outcome",
"vat_calculation_type": "Exclude",
"attached_user_id": 5
}
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": 9101
}
}