| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | --:api: query-api-key:request: QueryApiKeyRequest:response: QueryApiKeyResponse--[role="xpack"][id="{upid}-{api}"]=== Query API Key information APIAPI Key(s) information can be queried and retrieved in a paginatedfashion using this API.[id="{upid}-{api}-request"]==== Query API Key RequestThe +{request}+ supports query and retrieving API key information usingElasticsearch's {ref}/query-dsl.html[Query DSL] with{ref}/paginate-search-results.html[pagination].It supports only a subset of available query types, including:. {ref}/query-dsl-bool-query.html[Boolean query]. {ref}/query-dsl-match-all-query.html[Match all query]. {ref}/query-dsl-term-query.html[Term query]. {ref}/query-dsl-terms-query.html[Terms query]. {ref}/query-dsl-ids-query.html[IDs Query]. {ref}/query-dsl-prefix-query.html[Prefix query]. {ref}/query-dsl-wildcard-query.html[Wildcard query]. {ref}/query-dsl-range-query.html[Range query]===== Query for all API keysIn its most basic form, the request selects all API keys that the userhas access to.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[query-api-key-default-request]--------------------------------------------------===== Query API keys with Query DSLThe following query selects API keys owned by the user and also satisfy following criteria:* The API key name must begin with the word `key`* The API key name must *not* be `key-20000`["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[query-api-key-query-request]--------------------------------------------------===== Retrieve API keys with explicitly configured sort and pagingThe following request sort the API keys by their names in descending order.It also retrieves the API keys from index 1 (zero-based) and in a page size of 100.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[query-api-key-from-size-sort-request]--------------------------------------------------===== Deep pagination can be achieved with search after["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[query-api-key-search-after-request]--------------------------------------------------include::../execution.asciidoc[][id="{upid}-{api}-response"]==== Query API Key information API ResponseThe returned +{response}+ contains the information regarding the API keys that wererequested.["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[query-api-key-from-size-sort-response]--------------------------------------------------<1> Total number of API keys matched by the query<2> Number of API keys returned in this response<3> The list of API keys<4> If sorting is requested, each API key in the response contains its sort values.
 |