Using the APIs

Interact with the Kibana APIs through the curl command and HTTP and HTTPs protocols.

It is recommended that you use HTTPs on port 5601 because it is more secure.

The Kibana Console supports only Elasticsearch APIs. You are unable to interact with the Kibana APIs with the Console and must use curl or another HTTP tool instead. For more information, refer to Console.

Authentication

Kibana supports token-based authentication with the same username and password that you use to log into the Kibana Console.

API calls

API calls are stateless. Each request that you make happens in isolation from other calls and must include all of the necessary information for Kibana to fulfill the request. API requests return JSON output, which is a format that is machine-readable and works well for automation.

Calls to the API endpoints require different operations. To interact with the Kibana APIs, use the following operations:

  • GET - Fetches the information.
  • POST - Adds new information.
  • PUT - Updates the existing information.
  • DELETE - Removes the information.

For example, the following curl command exports a dashboard:

  1. curl -X POST api/kibana/dashboards/export?dashboard=942dcef0-b2cd-11e8-ad8e-85441f0c2e5c

Request headers

For all APIs, you must use a request header. The Kibana APIs support the kbn-xsrf and Content-Type headers.

kbn-xsrf: true

By default, you must use kbn-xsrf for all API calls, except in the following scenarios:

Content-Type: application/json

Applicable only when you send a payload in the API request. Kibana API requests and responses use JSON. Typically, if you include the kbn-xsrf header, you must also include the Content-Type header.

Request header example:

  1. curl -X POST \
  2. http://localhost:5601/api/spaces/space \
  3. -H 'Content-Type: application/json' \
  4. -H 'kbn-xsrf: true' \
  5. -d '{
  6. "id": "sales",
  7. "name": "Sales",
  8. "description": "This is your Sales Space!",
  9. "disabledFeatures": []
  10. }
  11. '

Most Popular