Change sale date
const url = 'https://api-admin.billz.ai/v2/order/5f6d2c0e-8a39-4c77-9a42-1d0a6d6f7a11?Billz-Response-Channel=HTTP';const options = { method: 'PATCH', headers: { 'platform-id': '7d4a4c38-dd84-4902-b744-0488b80a4c01', 'Billz-Response-Channel': 'HTTP', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"sold_at":"2023-05-14 18:32:10"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url 'https://api-admin.billz.ai/v2/order/5f6d2c0e-8a39-4c77-9a42-1d0a6d6f7a11?Billz-Response-Channel=HTTP' \ --header 'Authorization: Bearer <token>' \ --header 'Billz-Response-Channel: HTTP' \ --header 'Content-Type: application/json' \ --header 'platform-id: 7d4a4c38-dd84-4902-b744-0488b80a4c01' \ --data '{ "sold_at": "2023-05-14 18:32:10" }'Asynchronous method. To receive the result synchronously over HTTP, pass the Billz-Response-Channel: HTTP header — otherwise the response will be 200 {"message": "<correlation_id>"}. Maximum wait is 600 seconds, after which 408 with error.code = TIMEOUT is returned.
Changes only the date (sold_at) of a completed sale, return or exchange. Products, amounts, payments, customer and document status stay the same.
The new date is passed in the company’s time zone and must follow these rules:
- not later than the current moment and not earlier than
2000-01-01 00:00:00; - a return or exchange is not earlier than its original sale, a sale is not later than its first return or exchange;
- if finance is enabled in the company and the document belongs to a cash register shift — within that shift, old dates included.
A repeated call with the same date returns 200 with changed: false.
Dates in the response are in UTC (RFC 3339), not in the company’s time zone as in the request.
Error codes: 408 — timed out waiting for the asynchronous result; 401, 403, 429, 500 — shared by all methods. Body formats and semantics: Response codes and errors.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”ID of the sale, return or exchange
Example
5f6d2c0e-8a39-4c77-9a42-1d0a6d6f7a11Header Parameters
Section titled “Header Parameters”Platform identifier. A static value is used for integrations.
HTTP — wait for the event processing result and return it in the HTTP response. Without the header the method returns only the correlation_id of the published event.
Query Parameters
Section titled “Query Parameters”Same as the Billz-Response-Channel header — for clients that cannot send a custom header. If both are passed, the header applies.
Request Bodyrequired
Section titled “Request Bodyrequired”object
New date and time in the company’s time zone, format YYYY-MM-DD HH:MM:SS
Example
{ "sold_at": "2023-05-14 18:32:10"}Responses
Section titled “Responses”Success. With the Billz-Response-Channel: HTTP header — the asynchronous response envelope, without it — {"message": "<correlation_id>"}.
object
Customer session identifier
Final HTTP code, 200
Request identifier
Response event type, for example <event_type>.success
ID of the sale, return or exchange
object
ID of the sale, return or exchange
Document type: sale, return or exchange
Date before the change, UTC
Date after the change, UTC
false if the date passed matched the current one and the document did not change
Response of an asynchronous method without the Billz-Response-Channel header — the event has been published.
object
Correlation_id of the published event
Example
{ "session_id": "7c2a0f3e-3c52-4a4a-9d0e-5d3a8f1b2c11", "status_code": 200, "id": "5f6d2c0e-8a39-4c77-9a42-1d0a6d6f7a11", "topic": "v2.order_service.order.patch.success", "data": { "order_id": "5f6d2c0e-8a39-4c77-9a42-1d0a6d6f7a11", "order_type": "SALE", "old_sold_at": "2026-03-10T12:00:00Z", "sold_at": "2026-01-05T05:00:00Z", "changed": true }}The date was not accepted. Without sold_at, with other fields in the body or with invalid JSON — 400 immediately, without an envelope. Other reasons come in the envelope, the code is in data.error_code:
20127— the document is not completed;20128—sold_atis not in theYYYY-MM-DD HH:MM:SSformat;20129— the date is in the future or earlier than2000-01-01;20130— a return or exchange is earlier than its original sale;data.dataholdsparent_order_idandparent_sold_at(UTC,YYYY-MM-DD HH:MM:SS);20131— a sale is later than its first return or exchange;data.dataholdschild_order_idandchild_sold_at(UTC,YYYY-MM-DD HH:MM:SS);20132,20133— the date is outside the cash register shift the document belongs to.
Error body. Several error body formats coexist in the API; all formats and codes are described in the “Response codes and errors” section.
Asynchronous response envelope. Returned when the Billz-Response-Channel: HTTP header is passed. The final HTTP code of the request is taken from the status_code field.
object
Customer session identifier
Event processing status (also the final HTTP response code)
object
Error code, empty string if there is no error
Error text, empty string if there is no error
Request identifier, matches the ID of the published event
Response event type, for example <event_type>.success
Operation result, if the method returns one
object
Example
{ "session_id": "7c2a0f3e-3c52-4a4a-9d0e-5d3a8f1b2c11", "status_code": 400, "topic": "v2.order_service.order.patch.failed", "data": { "error_code": 20130, "message": "return or exchange can't be dated earlier than its sale", "data": { "parent_order_id": "a1000000-0000-4000-8000-000000000001", "parent_sold_at": "2026-03-10 12:00:00" } }}The document was not found in the company, data.error_code = 20088.
Error body. Several error body formats coexist in the API; all formats and codes are described in the “Response codes and errors” section.
Asynchronous response envelope. Returned when the Billz-Response-Channel: HTTP header is passed. The final HTTP code of the request is taken from the status_code field.
object
Customer session identifier
Event processing status (also the final HTTP response code)
object
Error code, empty string if there is no error
Error text, empty string if there is no error
Request identifier, matches the ID of the published event
Response event type, for example <event_type>.success
Operation result, if the method returns one
object
Examplegenerated
{ "code": 1, "message": "example", "error": { "code": "example", "message": "example" }, "data": {}}