kibana/docs/user/api.asciidoc

103 lines
3.8 KiB
Plaintext
Raw Normal View History

[[api]]
= REST API
2021-10-12 19:46:58 +02:00
Some {kib} features are provided via a REST API, which is ideal for creating an
integration with {kib}, or automating certain aspects of configuring and
deploying {kib}.
[float]
[[using-apis]]
== Using the APIs
Interact with the {kib} 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.
NOTE: The {kib} Console supports only Elasticsearch APIs. You are unable to interact with the {kib} APIs with the Console and must use `curl` or another HTTP tool instead. For more information, refer to <<console-kibana,Console>>.
[float]
[[api-authentication]]
=== Authentication
2021-10-12 19:46:58 +02:00
The {kib} APIs support key- and token-based authentication.
[float]
[[token-api-authentication]]
==== Token-based authentication
2021-10-12 19:46:58 +02:00
To use token-based authentication, you use the same username and password that you use to log into Elastic.
In a given HTTP tool, and when available, you can select to use its 'Basic Authentication' option,
which is where the username and password are stored in order to be passed as part of the call.
[float]
[[key-authentication]]
==== Key-based authentication
To use key-based authentication, you create an API key using the Elastic Console, then specify the key in the header of your API calls.
For information about API keys, refer to <<api-keys,API keys>>.
[float]
[[api-calls]]
=== 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 {kib} 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 {kib} APIs, use the following operations:
* *GET* - Fetches the information.
* *POST* - Adds new information.
* *PUT* - Updates the existing information.
* *DELETE* - Removes the information.
[float]
[[api-request-headers]]
=== Request headers
For all APIs, you must use a request header. The {kib} 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:
* The API endpoint uses the `GET` or `HEAD` operations
* The path is allowed using the <<settings-xsrf-allowlist, `server.xsrf.allowlist`>> setting
* XSRF protections are disabled using the <<settings-xsrf-disableProtection, `server.xsrf.disableProtection`>> setting
`Content-Type: application/json`::
2021-10-12 19:46:58 +02:00
Applicable only when you send a payload in the API request. {kib} 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:
[source,sh]
--------------------------------------------
curl -X POST \
http://localhost:5601/api/spaces/space \
-H 'Content-Type: application/json' \
-H 'kbn-xsrf: true' \
-d '{
"id": "sales",
"name": "Sales",
"description": "This is your Sales Space!",
"disabledFeatures": []
}
'
--------------------------------------------
2019-09-11 21:59:38 +02:00
include::{kib-repo-dir}/api/features.asciidoc[]
include::{kib-repo-dir}/api/spaces-management.asciidoc[]
include::{kib-repo-dir}/api/role-management.asciidoc[]
include::{kib-repo-dir}/api/session-management.asciidoc[]
2019-09-11 21:59:38 +02:00
include::{kib-repo-dir}/api/saved-objects.asciidoc[]
include::{kib-repo-dir}/api/index-patterns.asciidoc[]
Create new alerting HTTP APIs that use the new terminology (#93977) * Move current alert HTTP APIs to legacy folder (#93943) * Move current HTTP APIs to legacy folder * Rename BASE_ALERT_API_PATH to LEGACY_BASE_ALERT_API_PATH * Fix failing tests and extra files * Create new rule HTTP APIs (#93980) * Move current HTTP APIs to legacy folder * Rename BASE_ALERT_API_PATH to LEGACY_BASE_ALERT_API_PATH * Fix failing tests and extra files * Move current alert HTTP APIs to legacy folder (#93943) * Move current HTTP APIs to legacy folder * Rename BASE_ALERT_API_PATH to LEGACY_BASE_ALERT_API_PATH * Fix failing tests and extra files * Add necessary files * Create rule route * Get rule API * Update rule API * Delete rule route * Aggregate rules API * Disable rule API * Enable rule API * Find rules API * Fix Update API * Get rule alert summary API * Get rule state API * Health API * Rule types API * Mute all API * Mute alert API * Unmute all API * Unmute alert route * Update API key API * corrected tpye by making it much more complicated * removed unneeded cocde * Fixes * Add back health route * mutedInstanceIds -> mutedAlertIds * lastRun -> last_run * alert_type_state -> rule_type_state & alert_instances -> alerts Co-authored-by: Gidi Meir Morris <github@gidi.io> * Create docs for new rule HTTP APIs, deprecate old docs (#94745) * Create docs for new APIs, deprecate old docs * Remove connector_type_id * Update docs * Add link to legacy APIs from rules API docs * Remove connector_type_id references * [DOCS] Add legacy APIs to index.asciidoc * Fix camel case Co-authored-by: lcawl <lcawley@elastic.co> * Make alerting tests use new rules APIs (#95159) * Make API integration tests use new HTTP APIs * Fix end to end tests * Fix test failures * Fix more test failures * Rename some files * Add tests for legacy APIs (#95333) * Initial commit (#95457) * Move some new alerting APIs to /internal (#95461) * Initial commit * Update README.md * Use internal API * Merge deprecated warning w/ alternative solution * Update API docs Co-authored-by: Gidi Meir Morris <github@gidi.io> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: lcawl <lcawley@elastic.co>
2021-03-30 14:27:28 +02:00
include::{kib-repo-dir}/api/alerting.asciidoc[]
include::{kib-repo-dir}/api/actions-and-connectors.asciidoc[]
include::{kib-repo-dir}/api/dashboard-api.asciidoc[]
2019-09-11 21:59:38 +02:00
include::{kib-repo-dir}/api/logstash-configuration-management.asciidoc[]
include::{kib-repo-dir}/api/machine-learning.asciidoc[]
2021-10-12 19:46:58 +02:00
include::{kib-repo-dir}/api/short-urls.asciidoc[]
include::{kib-repo-dir}/api/task-manager/health.asciidoc[]
2019-09-11 21:59:38 +02:00
include::{kib-repo-dir}/api/upgrade-assistant.asciidoc[]