API Reference

PUT /v2/indices/{index public key}/documents:batch

Update a batch of documents or create new documents with predefined ids.

Payload

The request body should be a JSON object, listing the documents inside a “documents” array.

{
  "documents": [
    {
      "url": "https://www.example.com/product1.html",
      "id": "8700a03070a37982924597d6baa87be7",
      "custom_fields": {
        "title": "Example product",
        "description": "Description for example product",
        "price_cents": 599,
        "average_customer_rating": 4.5
      }
    },
    {
      "url": "https://www.example.com/product2.html",
      "id": "d3b07384d113edec49eaa6238ad5ff00",
      "custom_fields": {
        "title": "Example product",
        "description": "Description for example product",
        "price_cents": 349,
        "average_customer_rating": 4.2
      }
    }
  ]
}

The maximum size of the request body is limited to a total of 1M bytes.

Each document in the array must contain either a URL or an id field. If id is not present, the md5 checksum of the URL field will be used. If a document exists with a given id, it will be fully replaced by the given document.

Need more help?

We’re always happy to help with code or other questions you might have. Search our documentation, contact support, or connect with our sales team.