Skip to content

Update by Query

PATCH
View MD

This endpoint allows you to perform bulk updates on objects that match a specific set of criteria. It is an asynchronous operation: the API call initiates a background job, and you must poll a status URL to check its progress.

The request body consists of two main parts: a search object to define the update criteria and an update object to specify the changes.

ParameterTypeRequiredDescription
searchObjectAn object containing rules to select which items will be updated.
updateObjectAn object specifying the field changes to apply to all matching items.
ParameterTypeRequiredDescription
typesArrayAn array of strings specifying the object types to include in the search, for example ["item"].
partialObjectAn object containing the fields to match. Currently only fields is supported within partial.
ParameterTypeRequiredDescription
fieldsObjectAn object specifying the fields to update and their new values.

The process involves two steps. First, you send a PATCH request with your search and update rules to start the background job.

Authentication is required for all requests. The code demonstrates how to construct the necessary headers, including Date and Authorization. The Authorization header requires a dynamically generated HMAC signature.

The search criteria work on a partial match principle for array values and are case-sensitive. For example, a search for color: 'olive' matches a product with color: ['olive', 'red']. A search for category: 'jeans' will not match a product with category: 'Jeans'.

Important: The update operation is a replacement for the specified fields, not an incremental change.

After a successful PATCH request, the API responds with a status_url. You must then make a GET request to this URL to check the status of the background job. You may need to poll this endpoint until the status field changes from "in_progress" to "complete".

Status Check Request

GET https://live.luigisbox.com/v1/update_by_query?job_id=12345

The response shows the current status of your bulk update operation.

Once the job is finished, the GET request to the status URL returns a summary of the results, including the number of successful updates and any failures.

FieldTypeDescription
tracker_idStringYour tracker identifier.
statusStringJob status: in_progress, complete, or failed.
updates_countIntegerNumber of objects successfully updated.
failures_countIntegerNumber of objects that failed to update.
failuresObjectDetails about any failures, empty if none.
HTTP StatusDescription
400 Bad RequestThe request structure is invalid, JSON is malformed, or some objects failed validation. Check the response body for details.
403 ForbiddenThe request is not allowed for your site in Luigi’s Box.
405 Method Not AllowedThe request method is not supported for the specified resource.
413 Payload Too LargeThe request exceeds 5 MB, or 10 MB if compressed. Reduce batch size or enable compression.