Core
API v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

createOrReplace #

Creates a new document in the persistent data storage, or replaces its content if it already exists.


Query Syntax #

HTTP #

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>/<documentId>[?refresh=wait_for]
Method: PUT
Body:
Copied to clipboard!
{
  // Document content
}

Other protocols #

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

Arguments #

  • collection: collection name
  • documentId: unique identifier of the document to create or replace
  • index: index name

Optional: #

  • refresh: if set to wait_for, Kuzzle will not respond until the created/replaced document is indexed

Body properties #

New document content.


Response #

Returns an object with the following properties:

  • _id: created document unique identifier
  • _source: document content
  • _version: version of the created document
  • created: a boolean telling if a new document has been created
Copied to clipboard!
{
  "status": 200,
  "error": null,
  "index": "<index>",
  "collection": "<collection>",
  "controller": "document",
  "action": "createOrReplace",
  "requestId": "<unique request identifier>",
  "result": {
    "_id": "<documentId>",
    "_source": {
      // document content
    },
    "_version": 1,
    "created": true
  }
}