Meilisearch Documentation

Add or replace documents

cURL

curl \
  -X POST 'MEILISEARCH_URL/indexes/movies/documents' \
  -H 'Content-Type: application/json' \
  --data-binary '[\
    {\
      "id": 287947,\
      "title": "Shazam",\
      "poster": "https://image.tmdb.org/t/p/w1280/xnopI5Xtky18MPhK40cZAGAOVeV.jpg",\
      "overview": "A boy is given the ability to become an adult superhero in times of need with a single magic word.",\
      "release_date": "2019-03-23"\
    }\
  ]'

Response Examples

Response Codes

202
401
404

JSON Response

{
  "taskUid": 147,
  "indexUid": null,
  "status": "enqueued",
  "type": "documentAdditionOrUpdate",
  "enqueuedAt": "2024-08-08T17:05:55.791772Z"
}

Authorizations

Authorization Header

An API key is a token that you provide when making API calls. Read more about how to secure your project.

Include the API key to the Authorization header, for instance:

-H 'Authorization: Bearer 6436fc5237b0d6e0d64253fbaac21d135012ecf1'

If you use a SDK, ensure you instantiate the client with the API key, for instance with JS SDK:

const client = new Meilisearch({
  host: 'MEILISEARCH_URL',
  apiKey: '6436fc5237b0d6e0d64253fbaac21d135012ecf1'
});

Path Parameters

index_uid

  • Type: string
  • Required: Yes
  • Unique identifier of the index.

Query Parameters

primaryKey

  • Type: string
  • Primary key field for uniquely identifying each document (optional).

Body

Type: application/json

Example Body

[
  {
    "id": 287947,
    "title": "Shazam",
    "poster": "https://image.tmdb.org/t/p/w1280/xnopI5Xtky18MPhK40cZAGAOVeV.jpg",
    "overview": "A boy is given the ability to become an adult superhero in times of need with a single magic word.",
    "release_date": "2019-03-23"
  }
]

Response

  • 202: Task successfully enqueued.

Example Response:

{
  "taskUid": 147,
  "indexUid": null,
  "status": "enqueued",
  "type": "documentAdditionOrUpdate",
  "enqueuedAt": "2024-08-08T17:05:55.791772Z"
}