create

Creates a new document in the persistent data storage.

Returns an error if the document already exists.


Query Syntax

HTTP

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>/_create[?refresh=wait_for]
URL(2): http://kuzzle:7512/<index>/<collection>/<documentId>/_create[?refresh=wait_for]
Method: POST
Body:
Copied to clipboard!
{
  // document content
}

Other protocols

Copied to clipboard!
{
  "index": "<index>",
  "collection": "<collection>",
  "controller": "document",
  "action": "create",
  "_id": "<documentId>",
  "body": {
    // document content
  }
}

Arguments

  • collection: collection name
  • index: index name

Optional:

  • documentId: set the document unique ID to the provided value, instead of auto-generating a random ID
  • refresh: if set to wait_for, Kuzzle will not respond until the newly created document is indexed

Body properties

Document content to create.


Response

Returns an object with the following properties:

  • _id: created document unique identifier
  • _source: document content
  • _version: version of the created document (should be 1)
Copied to clipboard!
{
  "status": 200,
  "error": null,
  "index": "<index>",
  "collection": "<collection>",
  "controller": "document",
  "action": "create",
  "requestId": "<unique request identifier>",
  "result": {
    "_id": "<documentId>",
    "_version": 1,
    "_source": {
      // ...
    },
  }
}