Перейти до вмісту

Create a cash transaction

POST
/cashTransactions.create
curl --request POST \
--url https://api.sancho-wms.pl/v1/cashTransactions.create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "integrationId": 1, "importSource": { "appId": "example", "rowId": "example" }, "values": { "integrationType": "comarch-optima", "cashAccountId": 1, "cashStatementId": 1, "date": "2026-04-15", "direction": "incoming", "amount": 1, "documentSymbol": "example", "party": { "kind": "counterParty", "id": 1 }, "externalNumber": "example", "description": "example", "bankAccountNumber": "example", "categoryId": 1, "settlements": [ { "cashFlowItemId": 1, "amount": 1 } ] } }'

Writes one bank-statement line or cash slip into a cash account, with the cash-flow items it settles, in one save: everything lands or nothing does. 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. The cash account must exist and be active (invalidReference at cashAccountId) and be in the company’s base currency, baseCurrency on accounting.profile (notSupported at cashAccountId). With cashStatementId null the transaction goes into the statement covering date; a closed one is 422 statementClosed, a day after every statement opens a new one, and a day in a gap between statements is 422 noOpenStatement. party null takes the first settled cash-flow item’s. The amount may be part of either document, never more than what is left on it (settlementExceedsRemaining); both must be in the same currency (settlementCurrencyMismatch) and subject to settlement (settlementNotApplicable). The ERP keeps these amounts to two decimals, from 0.01 to 9999999999999.99. An amount within 0.00000001 of two decimals (a little more for very large amounts, where a number cannot be told apart more finely) is written rounded to two decimals: 0.30000000000000004 as 0.3, 0.010000001 as 0.01. An amount further from two decimals is 422 notSupported at its path, and so is one that rounds to zero or to more than 9999999999999.99. An ERP that keeps the ledger’s settlement items apart from its cash-flow items mirrors a settlement into the ledger itself in a company with double-entry books; when that fails the write still stands and warnings carries stage ledgerSyncFailed with the ERP’s own text.

Media typeapplication/json
object
integrationId
required
number
importSource
required
Any of:
ImportSourceWrite
object
appId
required
string
/^[A-Za-z0-9._:-]{1,5}$/
rowId
required
string
/^[A-Za-z0-9._:-]{1,36}$/
values
required
CashTransactionWrite
One of: discriminator: integrationType
ComarchOptimaCashTransactionWrite
object
integrationType
required
string
Allowed value: comarch-optima
cashAccountId
required
integer
> 0 <= 9007199254740991
cashStatementId
required
Any of:
integer
> 0 <= 9007199254740991
date
required
string format: date
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$/
direction
required
string
Allowed values: incoming outgoing
amount
required
number
> 0
documentSymbol
required
Any of:
string
>= 1 characters <= 5 characters
party
required
Any of:
object
kind
required
string
Allowed value: counterParty
id
required
integer
> 0 <= 9007199254740991
externalNumber
required
Any of:
string
<= 256 characters
description
required
Any of:
string
<= 1024 characters
bankAccountNumber
required
Any of:
string
<= 51 characters
categoryId
required
Any of:
integer
> 0 <= 9007199254740991
settlements
required
Array<object>
object
cashFlowItemId
required
integer
> 0 <= 9007199254740991
amount
required
number
> 0

Successful response

Media typeapplication/json
CashTransactionWriteResult
object
result
required
CashTransactionDetails
One of: discriminator: integrationType
ComarchOptimaCashTransactionDetails
object
id
required
number
number
required
string
externalNumber
required
string | null
cashStatementId
required
number | null
cashAccountId
required
number | null
date
required
string format: date
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$/
direction
required
string
Allowed values: incoming outgoing
method
required
string
Allowed values: cash transfer card other
amount
required
number
settledAmount
required
number
remainingAmount
required
number
currency
required
string
settlementStatus
required
string
Allowed values: notApplicable unsettled partiallySettled settled
party
required
Any of:
object
kind
required
string
Allowed values: counterParty bank employee shareholder taxAuthority other
id
required
number
partyName
required
string | null
bankAccountNumber
required
string | null
description
required
string | null
status
required
string
Allowed values: draft approved posted reversed voided
importSource
required
Any of:
ImportSourceOutput
object
appId
required
string
rowId
required
string
createdAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
modifiedAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
modifiedBy
required
string | null
integrationId
required
number
integrationType
required
string
Allowed value: comarch-optima
position
required
number
categoryId
required
number | null
settlements
required
Array<object>
Settlement
One of: discriminator: integrationType
ComarchOptimaSettlement
object
id
required
number
number
required
string | null
date
required
string format: date
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$/
amount
required
number
currency
required
string
exchangeDifferenceBase
required
number
sides
required
array
>= 2 items <= 2 items
importSource
required
Any of:
ImportSourceOutput
object
appId
required
string
rowId
required
string
createdAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
modifiedAt
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
modifiedBy
required
string | null
integrationId
required
number
integrationType
required
string
Allowed value: comarch-optima
ledgerSettlementItemId
required
number | null
automatic
required
boolean
warnings
required
Array<object>
CashWriteWarning
object
stage
required
string
Allowed values: ledgerSyncFailed
detail
required
string

Example

{
"result": {
"direction": "incoming",
"method": "cash",
"settlementStatus": "notApplicable",
"party": {
"kind": "counterParty"
},
"status": "draft",
"integrationType": "comarch-optima",
"settlements": [
{
"integrationType": "comarch-optima"
}
]
},
"warnings": [
{
"stage": "ledgerSyncFailed"
}
]
}

Bad request

Media typeapplication/json
error.BAD_REQUEST

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "BAD_REQUEST",
"message": "Bad request",
"issues": []
}

Unauthorized

Media typeapplication/json
error.UNAUTHORIZED

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "UNAUTHORIZED",
"message": "Unauthorized",
"issues": []
}

Payment required

Media typeapplication/json
error.PAYMENT_REQUIRED

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "PAYMENT_REQUIRED",
"message": "Payment required",
"issues": []
}

Forbidden

Media typeapplication/json
error.FORBIDDEN

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "FORBIDDEN",
"message": "Forbidden",
"issues": []
}

Not found

Media typeapplication/json
error.NOT_FOUND

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "NOT_FOUND",
"message": "Not found",
"issues": []
}

Conflict

Media typeapplication/json
error.CONFLICT

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "CONFLICT",
"message": "Conflict",
"issues": []
}

Unprocessable content

Media typeapplication/json
error.UNPROCESSABLE_CONTENT

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "UNPROCESSABLE_CONTENT",
"message": "Unprocessable content",
"issues": []
}

Too many requests

Media typeapplication/json
error.TOO_MANY_REQUESTS

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "TOO_MANY_REQUESTS",
"message": "Too many requests",
"issues": []
}

Internal server error

Media typeapplication/json
error.INTERNAL_SERVER_ERROR

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}

Service unavailable

Media typeapplication/json
error.SERVICE_UNAVAILABLE

The error information

object
message
required

The error message

string
code
required

The error code

string
issues

An array of issues that were responsible for the error

Array<object>
object
message
required
string

Example

{
"code": "SERVICE_UNAVAILABLE",
"message": "Service unavailable",
"issues": []
}