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 authorization
- 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_keysobjectrequired -
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 -
clusteranyOf -
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
-
namesstring | stringrequired -
A list of indices (or index name patterns) to which the permissions in this entry apply.
-
privilegesanyOfrequired -
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 -
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