API Reference

POST /v2/indices/{index public key}/documents/

Create a new document to the index.

By default, the Documents API endpoint creates a random id for each new document. If you want to define the id for the document or generate the id using the URL field, use the Update Document endpoint.

Payload

The request body should be a JSON object describing the document contents.

{
  "custom_fields": {
    "title": "Example product",
    "description": "Description for example product",
    "price_cents": 599,
    "average_customer_rating": 4.5,
    "release_date": 1589200255
  }
}

Document fields

  • custom_fields: Optional. A map of key value pairs for custom fields. Multiple datatypes are supported. See “Custom field data types” below.

Custom field data types

Data types for custom fields are automatically collected from the content. Supported data types are:

  • text
  • integer
  • double

Dates should be defined as UNIX timestamps with integer values.

Please note that once you have defined a specific data type for the custom field, the data type cannot be changed.

Indexing unsupported values will fail. If you have defined an unsupported data type, create a new custom field with a different name.

Response

A request to create a new document adds the document to a queue. On success, the endpoint will return a response HTTP 201 Created, with a URL pointing to the created document in the response header “Location”. It might take a few seconds for the document to become available.

Was this helpful?

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.