Customers' purchases amount
const url = 'https://api-admin.billz.ai/v1/customer/bulk?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: '{"customers":[{"customer_id":"0c4bacfa-5a20-4ee0-befb-e2c27da19d0c","purchase_amount":2100000},{"customer_id":"2be17079-dead-45a2-9b27-c7a7ceaf1476","purchase_amount":650000}]}'};
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/v1/customer/bulk?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 '{ "customers": [ { "customer_id": "0c4bacfa-5a20-4ee0-befb-e2c27da19d0c", "purchase_amount": 2100000 }, { "customer_id": "2be17079-dead-45a2-9b27-c7a7ceaf1476", "purchase_amount": 650000 } ] }'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.
Sets the total purchases amount of customers: the new value replaces the current one rather than being added to it. Up to 1000 customers per request, request body no larger than 1 MB.
All or nothing: if at least one customer is not found in the company, nobody is updated, and the 404 response lists the customers not found.
Zero and negative amounts are allowed. Deleted and archived customers are updated too.
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”Header 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
Customers and their new purchases amounts; a customer must not be repeated
object
Customer ID
Total purchases amount; replaces the current one
Example
{ "customers": [ { "customer_id": "0c4bacfa-5a20-4ee0-befb-e2c27da19d0c", "purchase_amount": 2100000 }, { "customer_id": "2be17079-dead-45a2-9b27-c7a7ceaf1476", "purchase_amount": 650000 } ]}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
object
How many customers were updated
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, "topic": "v1.user_service.customer.bulk_patch.success", "data": { "updated": 2 }}The request was not accepted, nobody was updated. With an unknown field in the body, with invalid JSON or with a body larger than 1 MB — 400 immediately, without an envelope. Other reasons come in the envelope, the code is in data.error_code:
1007— thecustomerslist is empty;1008— more than 1000 customers;1009—customer_idis not a UUID;1010— a customer is repeated in the request;1011—purchase_amountis not passed for a customer.
Validation stops at the first error; for 1009–1011 data.data holds that customer’s customer_id as a string.
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": {}}At least one customer was not found in the company, nobody was updated. data.error_code = 1012, data.data holds missing_customer_ids (no more than 100) and missing_total — how many were not found in total.
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": 404, "topic": "v1.user_service.customer.bulk_patch.failed", "data": { "error_code": 1012, "message": "customers not found, nothing was updated", "data": { "missing_customer_ids": [ "2be17079-dead-45a2-9b27-c7a7ceaf1476" ], "missing_total": 1 } }}