Create a Discover session Generally available; added in 9.6.0

POST /api/discover_sessions

Spaces method and path for this operation:

post /s/{space_id}/api/discover_sessions

Refer to Spaces for more information.

Creates a Discover session and returns its ID, full state, and metadata.

Headers

  • kbn-xsrf string Required

    A required header to protect against CSRF attacks

application/json

Body

  • description string

    A short description of the Discover session.

    Maximum length is 10000. Default value is empty.

  • tabs array[object] Required

    Ordered list of tabs in the Discover session. Each tab requires a stable, unique ID, which other saved objects and links can reference.

    At least 1 but not more than 25 elements.

    A Discover tab definition. data_source.type identifies the data source; type identifies the tab type. The tab type describes the saved settings and does not change how Discover displays the tab. Default tabs support data views and ES|QL; metrics tabs support only ES|QL.

    Any of:
  • tags array[string]

    Tag IDs to associate with this Discover session.

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

  • title string Required

    The title of the Discover session.

    Minimum length is 1, maximum length is 1000.

Responses

  • 201 application/json

    Created

    Hide response attributes Show response attributes object
    • data object Required

      Configuration data for a Discover session.

      Additional properties are NOT allowed.

      Hide data attributes Show data attributes object
      • description string

        A short description of the Discover session.

        Maximum length is 10000. Default value is empty.

      • tabs array[object] Required

        Ordered list of tabs in the Discover session. Each tab requires a stable, unique ID, which other saved objects and links can reference.

        At least 1 but not more than 25 elements.

        A Discover tab definition. data_source.type identifies the data source; type identifies the tab type. The tab type describes the saved settings and does not change how Discover displays the tab. Default tabs support data views and ES|QL; metrics tabs support only ES|QL.

        Any of:
      • tags array[string]

        Tag IDs to associate with this Discover session.

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

      • title string Required

        The title of the Discover session.

        Minimum length is 1, maximum length is 1000.

    • id string Required

      The Discover session ID.

    • 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

    Invalid request

  • 403

    Forbidden

POST /api/discover_sessions
curl -X POST "${KIBANA_URL}/api/discover_sessions" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "elastic-api-version: 2023-10-31" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Requests by extension",
  "description": "",
  "tags": [],
  "tabs": [
    {
      "id": "requests",
      "label": "Requests",
      "type": "default",
      "data_source": {
        "type": "esql",
        "query": "FROM kibana_sample_data_logs | STATS requests = COUNT(*) BY extension | SORT requests DESC"
      },
      "column_order": [
        "extension",
        "requests"
      ],
      "sort": [],
      "hide_chart": false,
      "hide_table": false
    }
  ]
}'
POST kbn:/api/discover_sessions
{
  "title": "Requests by extension",
  "description": "",
  "tags": [],
  "tabs": [
    {
      "id": "requests",
      "label": "Requests",
      "type": "default",
      "data_source": {
        "type": "esql",
        "query": "FROM kibana_sample_data_logs | STATS requests = COUNT(*) BY extension | SORT requests DESC"
      },
      "column_order": [
        "extension",
        "requests"
      ],
      "sort": [],
      "hide_chart": false,
      "hide_table": false
    }
  ]
}
Request examples
{
  "tabs": [
    {
      "column_order": [
        "timestamp",
        "response",
        "url"
      ],
      "data_source": {
        "index_pattern": "kibana_sample_data_logs",
        "time_field": "timestamp",
        "type": "data_view_spec"
      },
      "id": "logs",
      "label": "Logs",
      "query": {
        "expression": "response: 200",
        "language": "kql"
      }
    }
  ],
  "title": "Sample web logs"
}
{
  "tabs": [
    {
      "column_order": [
        "timestamp",
        "response",
        "url"
      ],
      "data_source": {
        "ref_id": "90943e30-9a47-11e8-b64d-95841ca0b247",
        "type": "data_view_reference"
      },
      "id": "logs",
      "label": "Logs",
      "query": {
        "expression": "response: 200",
        "language": "kql"
      }
    }
  ],
  "title": "Sample web logs"
}
{
  "description": "",
  "tabs": [
    {
      "column_order": [
        "extension",
        "requests"
      ],
      "data_source": {
        "query": "FROM kibana_sample_data_logs | STATS requests = COUNT(*) BY extension | SORT requests DESC",
        "type": "esql"
      },
      "hide_chart": false,
      "hide_table": false,
      "id": "requests",
      "label": "Requests",
      "sort": [],
      "type": "default"
    }
  ],
  "tags": [],
  "title": "Requests by extension"
}
{
  "tabs": [
    {
      "counter_aggregation": "max",
      "data_source": {
        "query": "TS metrics-*",
        "type": "esql"
      },
      "dimensions": [
        "host.name"
      ],
      "gauge_aggregation": "avg",
      "grid_sort_direction": "asc",
      "grid_sort_field": "alphabetically",
      "histogram_percentile": "p95",
      "id": "metrics",
      "label": "Metrics",
      "search_term": "cpu",
      "type": "metrics"
    }
  ],
  "title": "Host metrics"
}
Response examples (201)
{
  "data": {
    "description": "",
    "tabs": [
      {
        "column_order": [
          "extension",
          "requests"
        ],
        "data_source": {
          "query": "FROM kibana_sample_data_logs | STATS requests = COUNT(*) BY extension | SORT requests DESC",
          "type": "esql"
        },
        "hide_chart": false,
        "hide_table": false,
        "id": "requests",
        "label": "Requests",
        "sort": [],
        "type": "default"
      }
    ],
    "tags": [],
    "title": "Requests by extension"
  },
  "id": "web-log-requests",
  "meta": {
    "created_at": "2026-10-15T09:00:00.000Z",
    "created_by": "u_example",
    "managed": false,
    "updated_at": "2026-10-15T09:00:00.000Z",
    "updated_by": "u_example",
    "version": "WzEsMV0="
  }
}