|
| 1 | +[[saved-objects-api-bulk-update]] |
| 2 | +=== Bulk update object API |
| 3 | +++++ |
| 4 | +<titleabbrev>Bulk update objects</titleabbrev> |
| 5 | +++++ |
| 6 | + |
| 7 | +experimental[] Update the attributes for multiple existing {kib} saved objects. |
| 8 | + |
| 9 | +[[saved-objects-api-bulk-update-request]] |
| 10 | +==== Request |
| 11 | + |
| 12 | +`PUT <kibana host>:<port>/api/saved_objects/_bulk_update` |
| 13 | + |
| 14 | +`PUT <kibana host>:<port>/s/<space_id>/api/saved_objects/_bulk_update` |
| 15 | + |
| 16 | +[[saved-objects-api-bulk-update-path-params]] |
| 17 | +==== Path parameters |
| 18 | + |
| 19 | +`space_id`:: |
| 20 | + (Optional, string) An identifier for the space. If `space_id` is not provided in the URL, the default space is used. |
| 21 | + |
| 22 | +[[saved-objects-api-bulk-update-request-body]] |
| 23 | +==== Request body |
| 24 | + |
| 25 | +`type`:: |
| 26 | + (Required, string) Valid options include `visualization`, `dashboard`, `search`, `index-pattern`, `config`. |
| 27 | + |
| 28 | +`id`:: |
| 29 | + (Required, string) The object ID to update. |
| 30 | + |
| 31 | +`attributes`:: |
| 32 | + (Required, object) The data to persist. |
| 33 | ++ |
| 34 | +WARNING: When you update, attributes are not validated, which allows you to pass arbitrary and ill-formed data into the API and break {kib}. Make sure any data that you send to the API is properly formed. |
| 35 | + |
| 36 | +`references`:: |
| 37 | + (Optional, array) Objects with `name`, `id`, and `type` properties that describe the other saved objects this object references. To refer to the other saved object, use `name` in the attributes, but never the `id`, which automatically updates during migrations or import/export. |
| 38 | + |
| 39 | +`version`:: |
| 40 | + (Optional, number) Ensures the version matches that of the persisted object. |
| 41 | + |
| 42 | +`namespace`:: (Optional, string) Identifier for the space in which to update this object. If this is defined, it will supersede the space ID that is in the URL. |
| 43 | + |
| 44 | +[[saved-objects-api-bulk-update-codes]] |
| 45 | +==== Response code |
| 46 | + |
| 47 | +`200`:: |
| 48 | + Indicates a successful call. Note, this HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual |
| 49 | + objects will be returned in the response body. Refer to the example below for details. |
| 50 | + |
| 51 | +[[saved-objects-api-bulk-update-example]] |
| 52 | +==== Example |
| 53 | + |
| 54 | +Update three saved objects, where one of them does not exist: |
| 55 | + |
| 56 | +[source,sh] |
| 57 | +-------------------------------------------------- |
| 58 | +$ curl -X PUT api/saved_objects/_bulk_update |
| 59 | +[ |
| 60 | + { |
| 61 | + type: 'visualization', |
| 62 | + id: 'not an id', |
| 63 | + attributes: { |
| 64 | + title: 'An existing visualization', |
| 65 | + }, |
| 66 | + }, |
| 67 | + { |
| 68 | + type: 'dashboard', |
| 69 | + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', |
| 70 | + attributes: { |
| 71 | + title: 'An existing dashboard', |
| 72 | + }, |
| 73 | + { |
| 74 | + type: 'index-pattern', |
| 75 | + id: 'logstash-*', |
| 76 | + attributes: { title: 'my-logstash-pattern' } |
| 77 | + } |
| 78 | +] |
| 79 | +-------------------------------------------------- |
| 80 | +// KIBANA |
| 81 | + |
| 82 | +The API returns the following: |
| 83 | + |
| 84 | +[source,sh] |
| 85 | +-------------------------------------------------- |
| 86 | +[ |
| 87 | + { |
| 88 | + "type": "visualization", |
| 89 | + "id": "not an id", |
| 90 | + "error": { |
| 91 | + "statusCode": 404, |
| 92 | + "error": "Not Found", |
| 93 | + "message": "Saved object [visualization/not an id] not found", |
| 94 | + }, |
| 95 | + }, |
| 96 | + { |
| 97 | + "type": "dashboard", |
| 98 | + "id": "be3733a0-9efe-11e7-acb3-3dab96693fab", |
| 99 | + "version": 2, |
| 100 | + "attributes": { |
| 101 | + "title": "An existing dashboard", |
| 102 | + }, |
| 103 | + }, |
| 104 | + { |
| 105 | + "type": "index-pattern", |
| 106 | + "id": "logstash-*", |
| 107 | + "attributes": { |
| 108 | + "title": "my-logstash-pattern", |
| 109 | + } |
| 110 | + } |
| 111 | +] |
| 112 | +-------------------------------------------------- |
0 commit comments