Upsert a Vega library item Generally available

PUT /api/vega/{id}

Spaces method and path for this operation:

put /s/{space_id}/api/vega/{id}

Refer to Spaces for more information.

Replaces the full state of a Vega library item. If no item exists with the specified ID, a new one is created.

Headers

  • kbn-xsrf string Required

    A required header to protect against CSRF attacks

Path parameters

  • id string Required

    The unique ID of the Vega library item to create or update. A new ID must contain only lowercase letters, numbers, hyphens, and underscores.

application/json

Body

  • description string

    A short description of the Vega library item.

    Minimum length is 0, maximum length is 10000.

  • filters array[object]

    Filters. Applied together with the dashboard filters to Elasticsearch and ES|QL data sources that use %context%: true, and to Elasticsearch data sources that use %dashboard_context-*% placeholders.

    Not more than 100 elements.

    A filter applied to query results. Can be a field condition (condition), a logical group of conditions (group), a raw Elasticsearch DSL query (dsl), or a geo spatial query (spatial).

    One of:
  • query object

    KQL or Lucene query. Applied together with the dashboard query to Elasticsearch and ES|QL data sources that use %context%: true, and to Elasticsearch data sources that use %dashboard_context-*% placeholders.

    Additional properties are NOT allowed.

    Hide query attributes Show query attributes object
    • expression string Required

      A query expression in KQL or Lucene syntax.

      Minimum length is 0, maximum length is 1000000.

    • language string Required

      Query language. Use kql for Kibana Query Language (KQL) or lucene for Lucene query syntax.

      Values are kql or lucene.

  • spec object Required

    The Vega or Vega-Lite specification. Use { "format": "hjson", "value": "<hjson-string>" } for HJSON (comments and unquoted keys are preserved) or { "format": "json", "value": { ... } } for a JSON object.

    One of:
  • tags array[string]

    Tag IDs associated with this library item.

    Not more than 1000 elements. Maximum length of each is 250. Default value is [] (empty).

  • title string Required

    The Vega library item title.

    Minimum length is 1, maximum length is 1024.

Responses

  • 200 application/json

    updated

    Hide response attributes Show response attributes object
    • data object Required

      Additional properties are NOT allowed.

      Hide data attributes Show data attributes object
      • description string

        A short description of the Vega library item.

        Minimum length is 0, maximum length is 10000.

      • filters array[object]

        Filters. Applied together with the dashboard filters to Elasticsearch and ES|QL data sources that use %context%: true, and to Elasticsearch data sources that use %dashboard_context-*% placeholders.

        Not more than 100 elements.

        A filter applied to query results. Can be a field condition (condition), a logical group of conditions (group), a raw Elasticsearch DSL query (dsl), or a geo spatial query (spatial).

        One of:
      • query object

        KQL or Lucene query. Applied together with the dashboard query to Elasticsearch and ES|QL data sources that use %context%: true, and to Elasticsearch data sources that use %dashboard_context-*% placeholders.

        Additional properties are NOT allowed.

        Hide query attributes Show query attributes object
        • expression string Required

          A query expression in KQL or Lucene syntax.

          Minimum length is 0, maximum length is 1000000.

        • language string Required

          Query language. Use kql for Kibana Query Language (KQL) or lucene for Lucene query syntax.

          Values are kql or lucene.

      • spec object Required

        The Vega or Vega-Lite specification. Use { "format": "hjson", "value": "<hjson-string>" } for HJSON (comments and unquoted keys are preserved) or { "format": "json", "value": { ... } } for a JSON object.

        One of:
      • tags array[string]

        Tag IDs associated with this library item.

        Not more than 1000 elements. Maximum length of each is 250. Default value is [] (empty).

      • title string Required

        The Vega library item title.

        Minimum length is 1, maximum length is 1024.

    • id string Required

      The unique ID of the Vega library item, as returned by the create or search endpoints.

    • meta object Required

      Additional properties are NOT allowed.

      Hide meta attributes Show meta attributes object
      • created_at string

        Timestamp when the object was created (ISO 8601).

      • created_by string

        User profile ID of the user who created the object.

      • managed boolean

        When true, the object is managed by Kibana and cannot be edited by users.

      • owner string

        Identifier of the plugin or team that owns this object.

      • updated_at string

        Timestamp when the object was last updated (ISO 8601).

      • updated_by string

        User profile ID of the user who last updated the object.

      • version string

        Internal version identifier for optimistic concurrency control.

  • 201 application/json

    created

    Hide response attributes Show response attributes object
    • data object Required

      Additional properties are NOT allowed.

      Hide data attributes Show data attributes object
      • description string

        A short description of the Vega library item.

        Minimum length is 0, maximum length is 10000.

      • filters array[object]

        Filters. Applied together with the dashboard filters to Elasticsearch and ES|QL data sources that use %context%: true, and to Elasticsearch data sources that use %dashboard_context-*% placeholders.

        Not more than 100 elements.

        A filter applied to query results. Can be a field condition (condition), a logical group of conditions (group), a raw Elasticsearch DSL query (dsl), or a geo spatial query (spatial).

        One of:
      • query object

        KQL or Lucene query. Applied together with the dashboard query to Elasticsearch and ES|QL data sources that use %context%: true, and to Elasticsearch data sources that use %dashboard_context-*% placeholders.

        Additional properties are NOT allowed.

        Hide query attributes Show query attributes object
        • expression string Required

          A query expression in KQL or Lucene syntax.

          Minimum length is 0, maximum length is 1000000.

        • language string Required

          Query language. Use kql for Kibana Query Language (KQL) or lucene for Lucene query syntax.

          Values are kql or lucene.

      • spec object Required

        The Vega or Vega-Lite specification. Use { "format": "hjson", "value": "<hjson-string>" } for HJSON (comments and unquoted keys are preserved) or { "format": "json", "value": { ... } } for a JSON object.

        One of:
      • tags array[string]

        Tag IDs associated with this library item.

        Not more than 1000 elements. Maximum length of each is 250. Default value is [] (empty).

      • title string Required

        The Vega library item title.

        Minimum length is 1, maximum length is 1024.

    • id string Required

      The unique ID of the Vega library item, as returned by the create or search endpoints.

    • meta object Required

      Additional properties are NOT allowed.

      Hide meta attributes Show meta attributes object
      • created_at string

        Timestamp when the object was created (ISO 8601).

      • created_by string

        User profile ID of the user who created the object.

      • managed boolean

        When true, the object is managed by Kibana and cannot be edited by users.

      • owner string

        Identifier of the plugin or team that owns this object.

      • updated_at string

        Timestamp when the object was last updated (ISO 8601).

      • updated_by string

        User profile ID of the user who last updated the object.

      • version string

        Internal version identifier for optimistic concurrency control.

  • 400

    bad request

  • 403

    forbidden

PUT /api/vega/{id}
curl -X PUT "${KIBANA_URL}/api/vega/7c1d8e40-9b2f-11f0-a5c3-2f6e4b8d9a10" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Top extensions (US, Windows)",
  "spec": {
    "format": "json",
    "value": {
      "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
      "data": {
        "url": {
          "%context%": true,
          "%timefield%": "timestamp",
          "index": "kibana_sample_data_logs",
          "body": {
            "size": 0,
            "aggs": {
              "extensions": {
                "terms": {
                  "field": "extension.keyword"
                }
              }
            }
          }
        },
        "format": {
          "property": "aggregations.extensions.buckets"
        }
      },
      "mark": "bar",
      "encoding": {
        "x": {
          "field": "key",
          "type": "nominal"
        },
        "y": {
          "field": "doc_count",
          "type": "quantitative"
        }
      }
    }
  },
  "query": {
    "expression": "machine.os.keyword : win*",
    "language": "kql"
  },
  "filters": [
    {
      "type": "condition",
      "data_view_id": "90943e30-9a47-11e8-b64d-95841ca0b247",
      "condition": {
        "field": "geo.dest",
        "operator": "is",
        "value": "US"
      }
    },
    {
      "type": "dsl",
      "dsl": {
        "range": {
          "bytes": {
            "gte": 1000
          }
        }
      }
    }
  ]
}'
PUT kbn:/api/vega/7c1d8e40-9b2f-11f0-a5c3-2f6e4b8d9a10
{
  "title": "Top extensions (US, Windows)",
  "spec": {
    "format": "json",
    "value": {
      "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
      "data": {
        "url": {
          "%context%": true,
          "%timefield%": "timestamp",
          "index": "kibana_sample_data_logs",
          "body": {
            "size": 0,
            "aggs": {
              "extensions": {
                "terms": {
                  "field": "extension.keyword"
                }
              }
            }
          }
        },
        "format": {
          "property": "aggregations.extensions.buckets"
        }
      },
      "mark": "bar",
      "encoding": {
        "x": {
          "field": "key",
          "type": "nominal"
        },
        "y": {
          "field": "doc_count",
          "type": "quantitative"
        }
      }
    }
  },
  "query": {
    "expression": "machine.os.keyword : win*",
    "language": "kql"
  },
  "filters": [
    {
      "type": "condition",
      "data_view_id": "90943e30-9a47-11e8-b64d-95841ca0b247",
      "condition": {
        "field": "geo.dest",
        "operator": "is",
        "value": "US"
      }
    },
    {
      "type": "dsl",
      "dsl": {
        "range": {
          "bytes": {
            "gte": 1000
          }
        }
      }
    }
  ]
}
Request example
{
  "filters": [
    {
      "condition": {
        "field": "geo.dest",
        "operator": "is",
        "value": "US"
      },
      "data_view_id": "90943e30-9a47-11e8-b64d-95841ca0b247",
      "type": "condition"
    },
    {
      "dsl": {
        "range": {
          "bytes": {
            "gte": 1000
          }
        }
      },
      "type": "dsl"
    }
  ],
  "query": {
    "expression": "machine.os.keyword : win*",
    "language": "kql"
  },
  "spec": {
    "format": "json",
    "value": {
      "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
      "data": {
        "format": {
          "property": "aggregations.extensions.buckets"
        },
        "url": {
          "%context%": true,
          "%timefield%": "timestamp",
          "body": {
            "aggs": {
              "extensions": {
                "terms": {
                  "field": "extension.keyword"
                }
              }
            },
            "size": 0
          },
          "index": "kibana_sample_data_logs"
        }
      },
      "encoding": {
        "x": {
          "field": "key",
          "type": "nominal"
        },
        "y": {
          "field": "doc_count",
          "type": "quantitative"
        }
      },
      "mark": "bar"
    }
  },
  "title": "Top extensions (US, Windows)"
}
Response examples (200)
The complete updated state. PUT replaces the entire item, so fields omitted from the request, such as `query` or `filters`, are removed.
{
  "data": {
    "filters": [
      {
        "condition": {
          "field": "geo.dest",
          "operator": "is",
          "value": "US"
        },
        "data_view_id": "90943e30-9a47-11e8-b64d-95841ca0b247",
        "type": "condition"
      },
      {
        "dsl": {
          "range": {
            "bytes": {
              "gte": 1000
            }
          }
        },
        "type": "dsl"
      }
    ],
    "query": {
      "expression": "machine.os.keyword : win*",
      "language": "kql"
    },
    "spec": {
      "format": "json",
      "value": {
        "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
        "data": {
          "format": {
            "property": "aggregations.extensions.buckets"
          },
          "url": {
            "%context%": true,
            "%timefield%": "timestamp",
            "body": {
              "aggs": {
                "extensions": {
                  "terms": {
                    "field": "extension.keyword"
                  }
                }
              },
              "size": 0
            },
            "index": "kibana_sample_data_logs"
          }
        },
        "encoding": {
          "x": {
            "field": "key",
            "type": "nominal"
          },
          "y": {
            "field": "doc_count",
            "type": "quantitative"
          }
        },
        "mark": "bar"
      }
    },
    "title": "Top extensions (US, Windows)"
  },
  "id": "7c1d8e40-9b2f-11f0-a5c3-2f6e4b8d9a10",
  "meta": {
    "created_at": "2026-09-30T10:00:00.000Z",
    "managed": false,
    "updated_at": "2026-09-30T11:00:00.000Z",
    "version": "WzYwLDFd"
  }
}
Response examples (201)
Returned when no item existed with the specified ID and a new one was created.
{
  "data": {
    "filters": [
      {
        "condition": {
          "field": "geo.dest",
          "operator": "is",
          "value": "US"
        },
        "data_view_id": "90943e30-9a47-11e8-b64d-95841ca0b247",
        "type": "condition"
      },
      {
        "dsl": {
          "range": {
            "bytes": {
              "gte": 1000
            }
          }
        },
        "type": "dsl"
      }
    ],
    "query": {
      "expression": "machine.os.keyword : win*",
      "language": "kql"
    },
    "spec": {
      "format": "json",
      "value": {
        "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
        "data": {
          "format": {
            "property": "aggregations.extensions.buckets"
          },
          "url": {
            "%context%": true,
            "%timefield%": "timestamp",
            "body": {
              "aggs": {
                "extensions": {
                  "terms": {
                    "field": "extension.keyword"
                  }
                }
              },
              "size": 0
            },
            "index": "kibana_sample_data_logs"
          }
        },
        "encoding": {
          "x": {
            "field": "key",
            "type": "nominal"
          },
          "y": {
            "field": "doc_count",
            "type": "quantitative"
          }
        },
        "mark": "bar"
      }
    },
    "title": "Top extensions (US, Windows)"
  },
  "id": "7c1d8e40-9b2f-11f0-a5c3-2f6e4b8d9a10",
  "meta": {
    "created_at": "2026-09-30T10:00:00.000Z",
    "managed": false,
    "updated_at": "2026-09-30T10:00:00.000Z",
    "version": "WzU5LDFd"
  }
}