Create a document

Create a document #

Creates a new document.

Examples #

Insert a JSON document into the my-collection collection:

POST /my-collection/_doc
{
  "message": "GET /search HTTP/1.1 200 1070000",
  "org": {
    "id": "infini"
  }
}

The API returns the following result:

{
  "_collection": "default:my-collection",
  "_id": "0,0",
  "result": "created",
  "_shards": { "total": 2, "successful": 1, "failed": 0 }
}

The API supports passing a customized UUID as the document identify, eg:

POST /my-collection/_doc/news_001
{
  "message": "GET /search HTTP/1.1 200 1070000",
  "org": {
    "id": "infini"
  }
}

The keyed form answers with the user key as _key:

{
  "_collection": "default:my-collection",
  "_id": "0,0",
  "_key": "news_001",
  "result": "created",
  "_shards": { "total": 2, "successful": 1, "failed": 0 }
}

Creating a document whose key already exists replaces the existing document in place: the response reports result: "updated" and the document keeps its original _id. When the key belonged to a deleted document, the create reuses that document’s original _id instead of allocating a new one.

Request #

POST /<target>/_doc/[<doc_id>]
{<fields>}

Path parameters #

  • <target>
    (Required, string) Name of the collection to target.
  • <doc_id>
    (Optional, string) The unique identify of the document, auto generated if not specified.

Request body #

  • <fields>
    (Required, string) Request body contains the JSON source for the document data.
Calendar September 24, 2026
Edit Edit this page