Update a rule
const url = 'https://api.shoofai.com/v1/apps/demo-store/rules/example';const options = { method: 'PUT', headers: { 'Idempotency-Key': '4f1c2a9e-7b1d-4c0e-9a51-2d3f6b8e0c47', 'x-shoof-api-key': '<x-shoof-api-key>', 'Content-Type': 'application/json' }, body: '{"description":"Pin the new collection for \"summer\"","pattern":"summer","match":"contains","pins":[{"id":"sku-77-en","position":1}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://api.shoofai.com/v1/apps/demo-store/rules/example \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 4f1c2a9e-7b1d-4c0e-9a51-2d3f6b8e0c47' \ --header 'x-shoof-api-key: <x-shoof-api-key>' \ --data '{ "description": "Pin the new collection for \"summer\"", "pattern": "summer", "match": "contains", "pins": [ { "id": "sku-77-en", "position": 1 } ] }'Replaces one rule. The body is the rule, or {"rule": {...}}.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The app’s id, shown in the dashboard (for example ali-sport-goods). demo-store is the public demo app.
Example
demo-storeThe rule’s id, from listing or adding it.
Header Parameters
Section titled “Header Parameters”A unique value, such as a UUID, that makes retrying this request safe. The first request
with a key runs; for 24 hours a retry with the same key and the same body gets the first
response again, with Idempotent-Replayed: true, and doesn’t run a second time. The same
key with a different body is refused (409 idempotency_key_reused), and so is a retry
while the first request is still running (409 idempotency_key_in_use). Keys belong to
the app. Only successful responses are kept: after an error the key is free again.
Example
4f1c2a9e-7b1d-4c0e-9a51-2d3f6b8e0c47Request Bodyrequired
Section titled “Request Bodyrequired”object
Not empty, unless match is any.
object
Field to value. Fields are AND-ed; a list matches any of its values. See Filters.
ISO 8601.
ISO 8601.
object
Field to value. Fields are AND-ed; a list matches any of its values. See Filters.
object
Field to value. Fields are AND-ed; a list matches any of its values. See Filters.
object
Any JSON up to 8 KB, returned in the search response.
Example
{ "description": "Pin the new collection for \"summer\"", "pattern": "summer", "match": "contains", "pins": [ { "id": "sku-77-en", "position": 1 } ]}Responses
Section titled “Responses”The saved rule.
object
object
Not empty, unless match is any.
object
Field to value. Fields are AND-ed; a list matches any of its values. See Filters.
ISO 8601.
ISO 8601.
object
Field to value. Fields are AND-ed; a list matches any of its values. See Filters.
object
Field to value. Fields are AND-ed; a list matches any of its values. See Filters.
object
Any JSON up to 8 KB, returned in the search response.
Example
{ "rule": { "enabled": true, "match": "is", "filters": { "brand": [ "Nike", "Asics" ], "price": { "gte": 50, "lte": 150 }, "in_stock": true }, "boosts": [ { "filters": { "brand": [ "Nike", "Asics" ], "price": { "gte": 50, "lte": 150 }, "in_stock": true }, "factor": 2 } ], "buries": [ { "filters": { "brand": [ "Nike", "Asics" ], "price": { "gte": 50, "lte": 150 }, "in_stock": true }, "factor": 2 } ] }}The request is invalid (bad_request). details lists each problem with its path.
object
object
A stable, machine-readable code.
A human-readable explanation.
More about the error, such as the validation problems.
Example
{ "error": { "code": "bad_request", "message": "Invalid request", "details": [ { "path": "hitsPerPage", "message": "Must be 100 or less" } ] }}The record doesn’t exist (not_found).
object
object
A stable, machine-readable code.
A human-readable explanation.
More about the error, such as the validation problems.
Example generated
{ "error": { "code": "example", "message": "example", "details": "example" }}The Idempotency-Key was used for a different request (idempotency_key_reused), or the
first request with it is still running (idempotency_key_in_use).
object
object
A stable, machine-readable code.
A human-readable explanation.
More about the error, such as the validation problems.
Example generated
{ "error": { "code": "example", "message": "example", "details": "example" }}Too many requests in this window (rate_limited). Wait Retry-After seconds, then retry.
object
object
A stable, machine-readable code.
A human-readable explanation.
More about the error, such as the validation problems.
Example
{ "error": { "code": "rate_limited", "message": "Rate limit exceeded" }}Headers
Section titled “Headers”Seconds to wait before retrying. Sent with every 429.
What’s left in the window (IETF draft-ietf-httpapi-ratelimit-headers): the bucket’s name,
r the requests left and t the seconds until the window resets. Sent on every response.
Example
"search";r=597;t=43The bucket’s quota q per window of w seconds. Sent on every response.
Example
"search";q=600;w=60The requests allowed per window (the older form of RateLimit-Policy).
The requests left in the window.
Seconds until the window resets.