Create an accounting document
const url = 'https://api.sancho-wms.pl/v1/accountingDocuments.create';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"integrationId":1,"importSource":{"appId":"example","rowId":"example"},"values":{"documentType":"invoice","documentNumber":"example","issueDate":"2026-04-15","operationDate":"2026-04-15","taxPointDate":"2026-04-15","dueDate":"2026-04-15","currency":{"symbol":"example","rate":1,"units":1,"date":"2026-04-15"},"eInvoice":{"system":"ksef","number":"example"},"notes":"example","taxReporting":{"country":"PL","ksefMarker":"OFF","vatDeclarationMonth":"example","gtu":["GTU_01"],"procedures":["WSTO_EE"],"documentMarker":"FP","splitPayment":true,"cashAccounting":true},"counterPartyId":1,"paymentMethodId":1,"precedingInvoice":{"id":1,"number":"example","issueDate":"2026-04-15","eInvoiceNumber":"example"},"kind":"purchase","receiptDate":"2026-04-15","lines":[{"description":"example","net":1,"tax":1,"taxRate":{"percent":1,"category":"standardRated"},"account":{"kind":"number","number":"example"},"dimensions":[{"dimensionId":1,"valueId":1}],"deductible":"full","lineKind":"goods","categoryId":1}],"integrationType":"comarch-optima","vatRegisterId":1,"transactionKind":"domestic","categoryId":1,"categoryDescription":"example","proposedJournalEntry":{"journalId":1,"bookingDate":"2026-04-15","description":"example","lines":[{"debitAccount":{"kind":"number","number":"example"},"creditAccount":{"kind":"number","number":"example"},"amount":1,"description":"example","categoryId":1}]},"deductionDate":"2026-04-15"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.sancho-wms.pl/v1/accountingDocuments.create \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "integrationId": 1, "importSource": { "appId": "example", "rowId": "example" }, "values": { "documentType": "invoice", "documentNumber": "example", "issueDate": "2026-04-15", "operationDate": "2026-04-15", "taxPointDate": "2026-04-15", "dueDate": "2026-04-15", "currency": { "symbol": "example", "rate": 1, "units": 1, "date": "2026-04-15" }, "eInvoice": { "system": "ksef", "number": "example" }, "notes": "example", "taxReporting": { "country": "PL", "ksefMarker": "OFF", "vatDeclarationMonth": "example", "gtu": [ "GTU_01" ], "procedures": [ "WSTO_EE" ], "documentMarker": "FP", "splitPayment": true, "cashAccounting": true }, "counterPartyId": 1, "paymentMethodId": 1, "precedingInvoice": { "id": 1, "number": "example", "issueDate": "2026-04-15", "eInvoiceNumber": "example" }, "kind": "purchase", "receiptDate": "2026-04-15", "lines": [ { "description": "example", "net": 1, "tax": 1, "taxRate": { "percent": 1, "category": "standardRated" }, "account": { "kind": "number", "number": "example" }, "dimensions": [ { "dimensionId": 1, "valueId": 1 } ], "deductible": "full", "lineKind": "goods", "categoryId": 1 } ], "integrationType": "comarch-optima", "vatRegisterId": 1, "transactionKind": "domestic", "categoryId": 1, "categoryDescription": "example", "proposedJournalEntry": { "journalId": 1, "bookingDate": "2026-04-15", "description": "example", "lines": [ { "debitAccount": { "kind": "number", "number": "example" }, "creditAccount": { "kind": "number", "number": "example" }, "amount": 1, "description": "example", "categoryId": 1 } ] }, "deductionDate": "2026-04-15" } }'Writes an approved purchase or sales invoice into the ERP’s VAT register as an accounting document and answers result, the document as accountingDocuments.get reads it after the write, with warnings (empty for now). importSource names the application the record comes from (appId) and its key there (rowId), which the ERP keeps as the record’s import mark. The ERP refuses a rowId it already holds, whatever the appId or letter case (422 duplicateDocument). A create is never replayed: after a lost answer, find the record by importAppId and importRowId before sending again. Duplicate documents are the ERP’s own check, as the company set it there (422 duplicateDocument). The register must exist (invalidReference at vatRegisterId) and be of the document’s kind (vatRegisterKindMismatch), the VAT return month must not be in an approved return (taxPeriodClosed) and every JPK_V7 code the document type and taxReporting send must exist in the ERP (invalidReference at the field that sent it, such as taxReporting.gtu[0] or documentType). A null vatRegisterId takes the only active register of the document’s kind (invalidReference at vatRegisterId when there are several or none), a null transactionKind or paymentMethodId the counterparty card’s, else the ERP’s own default, a null operationDate the issue date, and a null line lineKind or includeInProRata the ERP’s own default. A value the ERP cannot store is 422 notSupported with its path: documentType creditNote, debitNote or other, a precedingInvoice, a line’s account or dimensions, an eInvoice whose system is not ksef, taxReporting: null, a line taxRate.category that would read back as another under the transactionKind (an exempt or outOfScope line states 0 for both taxRate.percent and tax), a documentType or taxReporting.documentMarker the document’s VAT register would read back otherwise, and taxReporting.gtu or taxReporting.procedures codes on a purchase, which mark only sales. Whether the ERP makes a cash transaction or settles the payment follows the company’s own setting there. proposedJournalEntry is the journal entry you approved, kept on the document until it is posted; it needs double-entry books and the ERP’s general-ledger module (notDoubleEntry, ledgerNotLicensed otherwise), a fiscal year containing bookingDate (noFiscalYear), a journal of that year (invalidReference at proposedJournalEntry.journalId) and accounts a line may book onto (invalidReference at the line’s account, ledgerAccountNotPostable). Name an account as { kind: "number", number } or { kind: "subledger", parentNumber, entry }: a counterparty’s subledger account is opened when missing. Send proposedJournalEntry: null for a company without double-entry books (bookkeeping kpir or ryczalt).
Authorizations
Abschnitt betitelt „Authorizations“Request Bodyrequired
Abschnitt betitelt „Request Bodyrequired“object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
Responses
Abschnitt betitelt „Responses“Successful response
object
object
object
object
object
object
object
object
object
object
object
object
Example
{ "result": { "kind": "purchase", "documentType": "invoice", "origin": "invoice", "status": "draft", "eInvoice": { "system": "ksef" }, "journalEntry": { "status": "draft" }, "taxReporting": { "country": "PL", "ksefMarker": "OFF", "gtu": [ "GTU_01" ], "procedures": [ "WSTO_EE" ], "documentMarker": "FP" }, "integrationType": "comarch-optima", "transactionKind": "domestic", "lines": [ { "taxRate": { "category": "standardRated" }, "deductible": "full", "lineKind": "goods", "rateStatus": "exempt" } ], "cashFlowItems": [ { "direction": "incoming", "settlementStatus": "notApplicable" } ] }, "warnings": [ { "stage": "placements" } ]}Bad request
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "BAD_REQUEST", "message": "Bad request", "issues": []}Unauthorized
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "UNAUTHORIZED", "message": "Unauthorized", "issues": []}Payment required
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "PAYMENT_REQUIRED", "message": "Payment required", "issues": []}Forbidden
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "FORBIDDEN", "message": "Forbidden", "issues": []}Not found
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "NOT_FOUND", "message": "Not found", "issues": []}Conflict
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "CONFLICT", "message": "Conflict", "issues": []}Unprocessable content
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "UNPROCESSABLE_CONTENT", "message": "Unprocessable content", "issues": []}Too many requests
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "TOO_MANY_REQUESTS", "message": "Too many requests", "issues": []}Internal server error
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "INTERNAL_SERVER_ERROR", "message": "Internal server error", "issues": []}Service unavailable
The error information
object
The error message
The error code
An array of issues that were responsible for the error
object
Example
{ "code": "SERVICE_UNAVAILABLE", "message": "Service unavailable", "issues": []}