Get API key information
- GET /_security/api_key
Retrieves information for one or more API keys.
NOTE: If you have only the manage_own_api_key privilege, this API returns only the API keys that you own.
If you have read_security, manage_api_key or greater privileges (including manage_security), this API returns all API keys regardless of ownership.
Required privileges
- Cluster privileges manage_own_api_key read_security
Query parameters
-
namestring -
An API key name. This parameter cannot be used with any of
id,realm_nameorusername. It supports prefix search with wildcard. -
ownerboolean · default: false -
A boolean flag that can be used to query API keys owned by the currently authenticated user. The
realm_nameorusernameparameters cannot be specified when this parameter is set totrueas they are assumed to be the currently authenticated ones. -
realm_namestring -
The name of an authentication realm. This parameter cannot be used with either
idornameor whenownerflag is set totrue. -
usernamestring -
The username of a user. This parameter cannot be used with either
idornameor whenownerflag is set totrue. -
with_limited_byboolean · default: false -
Return the snapshot of the owner user's role descriptors associated with the API key. An API key's actual permission is the intersection of its assigned role descriptors and the owner user's role descriptors.
-
active_onlyboolean · default: false -
A boolean flag that can be used to query API keys that are currently active. An API key is considered active if it is neither invalidated, nor expired at query time. You can specify this together with other parameters such as
ownerorname. Ifactive_onlyis false, the response will include both active and inactive (expired or invalidated) keys.
Response
-
api_keysobject[]required -
invalidatedbooleanrequired -
Invalidation status for the API key. If the key has been invalidated, it has a value of
true. Otherwise, it isfalse. -
role_descriptorsmap string to object -
The role descriptors assigned to this API key when it was created or last updated. An empty role descriptor means the API key inherits the owner user’s permissions.
-
<string>object -
clusterunion anyOf[] -
A list of cluster privileges. These privileges define the cluster level actions that API keys are able to execute.
-
Values:
allcancel_taskmanagemanage_api_keymanage_behavioral_analyticsmanage_enrichmanage_esqlmanage_index_templatesmanage_inferencemanage_ingest_pipelinesmanage_logstash_pipelinesmanage_mlmanage_own_api_keymanage_pipelinemanage_reindexmanage_search_applicationmanage_search_query_rulesmanage_search_synonymsmanage_securitymanage_transformmonitormonitor_enrichmonitor_esqlmonitor_inferencemonitor_mlmonitor_reindexmonitor_transformnonepost_behavioral_analytics_eventread_pipelineread_securityread_project_routingmanage_project_routing -
indicesobject[] -
A list of indices permissions entries.
-
field_securityobject -
The document fields that the owners of the role have read access to.
- Reference
-
namesunion string | string[]required -
A list of indices (or index name patterns) to which the permissions in this entry apply.
-
privilegesunion anyOf[]required -
The index level privileges that owners of the role have on the specified indices.
-
Values:
allauto_configurecreatecreate_doccreate_indexcreate_viewdeletedelete_indexdelete_viewindexmaintenancemanagemanage_data_stream_lifecyclemanage_viewmonitornonereadread_view_metadataview_index_metadatawrite -
queryunion oneOf -
A search query that defines the documents the owners of the role have access to. A document within the specified indices must match this query for it to be accessible by the owners of the role.
- One of:
-
templateobject -
When you create a role, you can specify a query that defines the document level security permissions. You can optionally use Mustache templates in the role query to insert the username of the current authenticated user into the role. Like other places in Elasticsearch that support templating or scripting, you can specify inline, stored, or file-based templates and define custom parameters. You access the details for the current authenticated user through the _user parameter.
- Reference
-
sourceunion oneOf - One of:
-
paramsmap string to object -
Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.
-
langunion anyOf · default: painless -
Specifies the language the script is written in.
Supported values include:
painless: Painless scripting language, purpose-built for Elasticsearch.expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.mustache: Mustache templated, used for templates.java: Expert Java API
-
Values:
painlessexpressionmustachejava -
metadataobject -
Optional meta-data. Within the metadata object, keys that begin with
_are reserved for system usage. -
run_asstring[] -
A list of users that the API keys can impersonate. NOTE: In Elastic Cloud Serverless, the run-as feature is disabled. For API compatibility, you can still specify an empty
run_asfield, but a non-empty list will be rejected. - Reference
-
limited_bystring to object[] -
The owner user’s permissions associated with the API key. It is a point-in-time snapshot captured at creation and subsequent updates. An API key’s effective permissions are an intersection of its assigned privileges and the owner user’s permissions.
-
accessobject -
The access granted to cross-cluster API keys. The access is composed of permissions for cross cluster search and cross cluster replication. At least one of them must be specified. When specified, the new access assignment fully replaces the previously assigned access.
-
searchobject[] -
A list of indices permission entries for cross-cluster search.
-
field_securityobject -
The document fields that the owners of the role have read access to.
- Reference
-
namesunion string | string[]required -
A list of indices (or index name patterns) to which the permissions in this entry apply.
-
queryunion oneOf -
A search query that defines the documents the owners of the role have access to. A document within the specified indices must match this query for it to be accessible by the owners of the role.
- One of:
-
templateobject -
When you create a role, you can specify a query that defines the document level security permissions. You can optionally use Mustache templates in the role query to insert the username of the current authenticated user into the role. Like other places in Elasticsearch that support templating or scripting, you can specify inline, stored, or file-based templates and define custom parameters. You access the details for the current authenticated user through the _user parameter.
- Reference
-
sourceunion oneOf - One of:
-
paramsmap string to object -
Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.
-
langunion anyOf · default: painless -
Specifies the language the script is written in.
Supported values include:
painless: Painless scripting language, purpose-built for Elasticsearch.expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.mustache: Mustache templated, used for templates.java: Expert Java API
-
Values:
painlessexpressionmustachejava
Query
An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
Query
An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
Query
An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
Query
An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.