Core
API v2.x
2

create #

Creates a new document in the persistent data storage.

Returns an error if the document already exists.


Query Syntax #

HTTP #

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

Other protocols #

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

Kourou #

kourou document:create <index> <collection> <body>
kourou document:create <index> <collection> <id> <body>
kourou document:create <index> <collection> <body> -a silent=true

Arguments #

  • collection: collection name
  • index: index name

Optional: #

  • _id: 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
  • silent: if set, then Kuzzle will not generate notifications
    Available since 2.9.2

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)
{
  "status": 200,
  "error": null,
  "index": "<index>",
  "collection": "<collection>",
  "controller": "document",
  "action": "create",
  "requestId": "<unique request identifier>",
  "result": {
    "_id": "<documentId>",
    "_version": 1,
    "_source": {
      // ...
    },
  }
}