HTTP/REST clients and security
The Elasticsearch security features work with standard HTTP basic authentication headers to authenticate users. Since Elasticsearch is stateless, this header must be sent with every request:
Authorization: Basic <TOKEN>
| The |
Alternatively, you can use token-based authentication services.
Client examples
This example uses curl without basic auth to create an index:
curl -XPUT 'localhost:9200/idx'
{
"error": "AuthenticationException[Missing authentication token]",
"status": 401
} Since no user is associated with the request above, an authentication error is returned. Now we’ll use curl with basic auth to create an index as the rdeniro user:
curl --user rdeniro:taxidriver -XPUT 'localhost:9200/idx'
{
"acknowledged": true
} Secondary authorization
Some APIs support secondary authorization headers for situations where you want tasks to run with a different set of credentials. For example, you can send the following header in addition to the basic authentication header:
es-secondary-authorization: Basic <TOKEN>
| The |
The es-secondary-authorization header has the same syntax as the Authorization header. It therefore also supports the use of token-based authentication services. For example:
es-secondary-authorization: ApiKey <TOKEN>
| The |
Client libraries over HTTP
For more information about using security features with the language specific clients, refer to:
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/http-clients.html