Create ledger accounts
const url = 'https://api.sancho-wms.pl/v1/ledgerAccounts.create';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"integrationId":1,"values":{"integrationType":"comarch-optima","fiscalYearId":1,"parentNumber":"example","levels":[{"segment":"example","name":"example"}]}}'};
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/ledgerAccounts.create \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "integrationId": 1, "values": { "integrationType": "comarch-optima", "fiscalYearId": 1, "parentNumber": "example", "levels": [ { "segment": "example", "name": "example" } ] } }'Gets or creates analytic accounts below an existing account, one level after another: parentNumber “402” with levels “01” and “05” ends at 402-01-05. Each level is looked up by its number first, so a retry writes nothing more and an existing level keeps its name. Answers result, the last level’s account as ledgerAccounts.get reads it after the write, with warnings (empty for now). A synthetic account is never created: a missing parentNumber is 422 invalidReference at parentNumber. A subledger parent is 422 subledgerParentAccount (its analytic accounts are opened one per entry; use /ledgerAccounts.ensureSubledgerAccount), an account that already holds postings or an opening balance is 422 ledgerAccountHasEntries, and a closed fiscal year is 422 periodLocked. An account exists in the fiscal year it was created in only. A company without double-entry books (bookkeeping kpir or ryczalt) has no chart and answers 422 with the reason notDoubleEntry. Opening accounts also needs the ERP’s general-ledger module on the integration’s login (ledgerLicensed on accounting.profile), even when every account already exists: 422 ledgerNotLicensed without it.
Authorizations
Abschnitt betitelt „Authorizations“Request Bodyrequired
Abschnitt betitelt „Request Bodyrequired“object
object
object
Responses
Abschnitt betitelt „Responses“Successful response
object
object
object
Example
{ "result": { "classification": "asset", "subledgerKind": "counterParty", "subledgerEntry": { "kind": "counterParty" }, "integrationType": "comarch-optima", "accountType": "asset" }, "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": []}