Skip to main content
POST
/
1
/
indexes
/
{indexName}
/
{model}
/
recommend
/
rules
/
batch
curl
curl --request POST \
  --url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/related-products/recommend/rules/batch \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --header 'x-algolia-api-key: ALGOLIA_API_KEY' \
  --header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
  --data '
[
  {
    "_metadata": {
      "lastUpdate": "2023-07-04T12:49:15Z"
    },
    "objectID": "lorem",
    "condition": {
      "filters": "(category:Book OR category:Ebook) AND _tags:published",
      "context": "mobile"
    },
    "consequence": {
      "hide": [
        {
          "objectID": "test-record-123"
        }
      ],
      "promote": [
        {
          "objectID": "test-record-123",
          "position": 0
        }
      ],
      "params": {
        "automaticFacetFilters": [
          {
            "facet": "lorem",
            "negative": true
          }
        ],
        "filters": "(category:Book OR category:Ebook) AND _tags:published",
        "optionalFilters": [
          "category:books<score=1>",
          "category:-movies<score=1>"
        ]
      }
    },
    "description": "Boost on-sale items",
    "enabled": true,
    "validity": [
      {
        "from": 42,
        "until": 42
      }
    ]
  }
]
'
{
  "taskID": 1514562690001,
  "updatedAt": "2023-07-04T12:49:15Z"
}
Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same objectID already exists. You may also specify true for clearExistingRules, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a source item instead of a query. The main differences are the following:
  • Conditions pattern and anchoring are unavailable.
  • Condition filters triggers if the source item matches the specified filters.
  • Condition filters accepts numeric filters.
  • Consequence params only covers filtering parameters.
  • Consequence automaticFacetFilters doesn’t require a facet value placeholder (it tries to match the data source item’s attributes instead).
Required ACL: editSettings

Authorizations

x-algolia-application-id
string
header
required

Your Algolia application ID.

x-algolia-api-key
string
header
required

Your Algolia API key with the necessary permissions to make the request. Permissions are controlled through access control lists (ACL) and access restrictions. The required ACL to make a request is listed in each endpoint's reference.

Path Parameters

indexName
string
required

Name of the index on which to perform the operation.

Example:

"ALGOLIA_INDEX_NAME"

model
enum<string>
required
Available options:
related-products,
bought-together,
trending-facets,
trending-items

Body

application/json
_metadata
ruleMetadata · object

Rule metadata.

objectID
string

Unique identifier of a rule object.

condition
object

Condition that triggers the rule. If not specified, the rule is triggered for all recommendations.

consequence
object

Effect of the rule.

description
string

Description of the rule's purpose. This can be helpful for display in the Algolia dashboard.

Example:

"Boost on-sale items"

enabled
boolean
default:true

Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time.

validity
object[]

Time periods when the rule is active.

Response

OK

Response, taskID, and update timestamp.

taskID
integer<int64>
required

Unique identifier of a task.

A successful API response means that a task was added to a queue. It might not run immediately. You can check the task's progress with the task operation and this task ID.

Example:

1514562690001

updatedAt
string
required

Date and time when the object was updated, in RFC 3339 format.

Example:

"2023-07-04T12:49:15Z"

Last modified on March 23, 2026