Create api key – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.4

Briefly, this error occurs when a user tries to create an API key in Elasticsearch but fails due to insufficient permissions, incorrect syntax, or a misconfigured Elasticsearch cluster. To resolve this issue, ensure that the user has the necessary permissions to create an API key. If permissions are not the issue, check the syntax of the command used to create the API key. Lastly, verify that the Elasticsearch cluster is correctly configured and functioning properly.

This guide will help you check for common problems that cause the log ” create api key ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: plugin.

Log Context

Log “create api key” class name is We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 securityIndex.prepareIndexIfNeededThenExecute(listener::onFailure; () ->
 executeAsyncWithOrigin(client; SECURITY_ORIGIN; SearchAction.INSTANCE; searchRequest;
 indexResponse -> {
 if (indexResponse.getHits().getTotalHits().value > 0) {
 listener.onFailure(traceLog("create api key"; new ElasticsearchSecurityException(
 "Error creating api key as api key with name [{}] already exists"; request.getName())));
 } else {
 createApiKeyAndIndexIt(authentication; request; userRoles; listener);


How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?