Create Index

POST /indexes

Create an index.

Headers

  • Content-Type string Required

    Payload content-type

    Value is application/json.

application/json

Responses

  • 202 application/json

    Accepted

  • 400 application/json

    Bad Request

    Hide response attributes Show response attributes object
  • 401 application/json

    Unauthorized

    Hide response attributes Show response attributes object
POST /indexes
curl \
 -X POST https://example.meilisearch.com:7700/indexes \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"uid":"movies","primaryKey":"movie_id"}'
Request example
# Headers
Content-Type: application/json

# Payload
{
  "uid": "movies",
  "primaryKey": "movie_id"
}
Response examples (202)
{
  "taskUid": 0,
  "indexUid": "movies",
  "status": "enqueued",
  "type": "indexCreation",
  "enqueuedAt": "2021-01-01T09:39:00.000000Z"
}
Response examples (400)
{
  "message": "Index `:indexUid` already exists.",
  "code": "index_already_exists",
  "type": "invalid_request",
  "link": "https://docs.meilisearch.com/errors#index_already_exists"
}
{
  "message": "`:indexUid` is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_).",
  "code": "invalid_index_uid",
  "type": "invalid_request",
  "link": "https://docs.meilisearch.com/errors#invalid_index_uid"
}
Response examples (401)
{
  "message": "The Authorization header is missing. It must use the bearer authorization method.",
  "code": "missing_authorization_header",
  "type": "auth",
  "link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}