Bulk Create Objects

edit

This functionality is experimental and may be changed or removed completely in a future release.

The bulk-create saved object API enables you to persist multiple Kibana saved objects.

Request

edit

POST /api/saved_objects/_bulk_create

Query Parameters

edit
overwrite (optional)
(boolean) If true, will overwrite the document with the same ID.

Request Body

edit

The request body must be a JSON array containing objects, each of which contains the following properties:

type (required)
(string) Valid options, include: visualization, dashboard, search, index-pattern, config, and timelion-sheet
id (optional)
(string) Enables specifying an ID to use, as opposed to one being randomly generated
attributes (required)
(object) The data to persist
version (optional)
(number) Enables specifying a version

Response body

edit

The response body will have a top level saved_objects property that contains an array of objects, which represent the response for each of the requested objects. The order of the objects in the response is identical to the order of the objects in the request.

For any saved object that could not be persisted, an error object will exist in its place.

Examples

edit

The following example attempts to persist an index pattern with id my-pattern and a dashboard with id my-dashboard, but only the index pattern could be persisted because there was an id collision with my-dashboard as a saved object with that id alread exists.

POST api/saved_objects/_bulk_create
[
  {
    "type": "index-pattern",
    "id": "my-pattern",
    "attributes": {
      "title": "my-pattern-*"
    }
  },
  {
    "type": "dashboard",
    "id": "my-dashboard",
    "attributes": {
      "title": "Look at my dashboard"
    }
  }
]

A successful call returns a response code of 200 and a response body containing a JSON structure similar to the following example:

{
  "saved_objects": [
    {
      "id": "my-pattern",
      "type": "index-pattern",
      "version": 1,
      "attributes": {
        "title": "my-pattern-*"
      }
    },
    {
      "id": "my-dashboard",
      "type": "dashboard",
      "error": {
        "statusCode": 409,
        "message": "version conflict, document already exists"
      }
    }
  ]
}