Spaces method and path for this operation:
Refer to Spaces for more information.
Creates a new Vega library item and returns its ID, full state, and metadata.
Body
-
A short description of the Vega library item.
Minimum length is
0, maximum length is10000. -
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
100elements.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). -
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.
-
The Vega library item title.
Minimum length is
1, maximum length is1024.
curl -X POST "${KIBANA_URL}/api/vega" \
-H "Authorization: ApiKey ${API_KEY}" \
-H "kbn-xsrf: true" \
-H "Content-Type: application/json" \
-d '{
"title": "Requests over time",
"description": "Hourly request count from the sample web logs.",
"spec": {
"format": "hjson",
"value": "{\n $schema: https://vega.github.io/schema/vega-lite/v5.json\n // Applies the dashboard time range, query, and filters\n data: {\n url: {\n %context%: true\n %timefield%: timestamp\n index: kibana_sample_data_logs\n body: {\n size: 0\n aggs: { hours: { date_histogram: { field: \"timestamp\", fixed_interval: \"1h\" } } }\n }\n }\n format: { property: \"aggregations.hours.buckets\" }\n }\n mark: line\n encoding: {\n x: { field: \"key\", type: \"temporal\", title: null }\n y: { field: \"doc_count\", type: \"quantitative\", title: \"Requests\" }\n }\n}"
}
}'
POST kbn:/api/vega
{
"title": "Requests over time",
"description": "Hourly request count from the sample web logs.",
"spec": {
"format": "hjson",
"value": "{\n $schema: https://vega.github.io/schema/vega-lite/v5.json\n // Applies the dashboard time range, query, and filters\n data: {\n url: {\n %context%: true\n %timefield%: timestamp\n index: kibana_sample_data_logs\n body: {\n size: 0\n aggs: { hours: { date_histogram: { field: \"timestamp\", fixed_interval: \"1h\" } } }\n }\n }\n format: { property: \"aggregations.hours.buckets\" }\n }\n mark: line\n encoding: {\n x: { field: \"key\", type: \"temporal\", title: null }\n y: { field: \"doc_count\", type: \"quantitative\", title: \"Requests\" }\n }\n}"
}
}
{
"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 : \"osx\"",
"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, macOS)"
}
{
"description": "Hourly request count from the sample web logs.",
"spec": {
"format": "hjson",
"value": "{\n $schema: https://vega.github.io/schema/vega-lite/v5.json\n // Applies the dashboard time range, query, and filters\n data: {\n url: {\n %context%: true\n %timefield%: timestamp\n index: kibana_sample_data_logs\n body: {\n size: 0\n aggs: { hours: { date_histogram: { field: \"timestamp\", fixed_interval: \"1h\" } } }\n }\n }\n format: { property: \"aggregations.hours.buckets\" }\n }\n mark: line\n encoding: {\n x: { field: \"key\", type: \"temporal\", title: null }\n y: { field: \"doc_count\", type: \"quantitative\", title: \"Requests\" }\n }\n}"
},
"title": "Requests over time"
}
{
"data": {
"description": "Hourly request count from the sample web logs.",
"spec": {
"format": "hjson",
"value": "{\n $schema: https://vega.github.io/schema/vega-lite/v5.json\n // Applies the dashboard time range, query, and filters\n data: {\n url: {\n %context%: true\n %timefield%: timestamp\n index: kibana_sample_data_logs\n body: {\n size: 0\n aggs: { hours: { date_histogram: { field: \"timestamp\", fixed_interval: \"1h\" } } }\n }\n }\n format: { property: \"aggregations.hours.buckets\" }\n }\n mark: line\n encoding: {\n x: { field: \"key\", type: \"temporal\", title: null }\n y: { field: \"doc_count\", type: \"quantitative\", title: \"Requests\" }\n }\n}"
},
"title": "Requests over time"
},
"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"
}
}