Create a counterparty
const url = 'https://api.sancho-wms.pl/v1/counterParties.create';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"integrationId":1,"importSource":{"appId":"example","rowId":"example"},"data":{"integrationType":"comarch-optima","code":"example","name":"example","taxId":"example","taxIdCountry":"example","countryCode":"example","city":"example","street":"example","streetNumber":"example","unitNumber":"example","postalCode":"example","province":"example","active":true,"roles":["supplier"],"isFinalCustomer":true,"group":"example","vatTransactionKind":"domestic","regon":"example","phone":"example","fax":"example","email":"example","website":"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/counterParties.create \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "integrationId": 1, "importSource": { "appId": "example", "rowId": "example" }, "data": { "integrationType": "comarch-optima", "code": "example", "name": "example", "taxId": "example", "taxIdCountry": "example", "countryCode": "example", "city": "example", "street": "example", "streetNumber": "example", "unitNumber": "example", "postalCode": "example", "province": "example", "active": true, "roles": [ "supplier" ], "isFinalCustomer": true, "group": "example", "vatTransactionKind": "domestic", "regon": "example", "phone": "example", "fax": "example", "email": "example", "website": "example" } }'Creates a counterparty card in the ERP and answers result, the card as counterParties.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. Only the comarch-optima integration type stores it; the others answer 400 to one. The ERP also refuses a code already in use (422 duplicateDocument); Sancho compares no tax ID, so look one up with /counterParties.list first when it must not get a second card. Send result.modifiedAt to /counterParties.update as expectedModifiedAt, or null where the card has none.
Authorizations
Dział zatytułowany „Authorizations”Request Bodyrequired
Dział zatytułowany „Request Bodyrequired”object
object
object
object
object
Responses
Dział zatytułowany „Responses”Successful response
object
object
object
object
object
object
Example
{ "result": { "countryCode": null, "status": "draft", "vatTransactionKind": null, "taxIdCountry": null, "currency": null, "integrationType": "comarch-optima", "roles": [], "isFinalCustomer": false, "group": null, "province": null, "phone": null, "email": null, "website": null, "fax": null, "regon": null, "modifiedAt": null, "modifiedBy": null, "importSource": null }, "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": []}