searchApiKeys #
Searches for API keys.
To search for an API key corresponding to a token you can search on the fingerprint
property which is a SHA256 hash of the token.
Available since 2.8.0
This method also supports the Koncorde Filters DSL to match documents by passing the lang
argument with the value koncorde
.
Koncorde filters will be translated into an Elasticsearch query.
Koncorde bool
operator and regexp
clause are not supported for search queries.
Query Syntax #
HTTP #
URL: http://kuzzle:7512/users/api-keys/_search[?from=0][&size=42][&lang=<query language>]
Method: POST
Body:
{
"match": {
"description": "sigfox"
}
}
Other protocols #
{
"controller": "auth",
"action": "searchApiKeys",
"body": {
"match": {
"description": "sigfox"
}
},
// optional arguments
"from": 0,
"size": 10,
"lang": "<query language>"
}
Arguments #
Optional: #
from
: the offset from the first result you want to fetch. Usually used with thesize
argumentsize
: the maximum number of API keys returned in one response pagelang
: specify the query language to use. By default, it'selasticsearch
butkoncorde
can also be used.Available since 2.8.0
Body properties #
Optional: #
The search query itself, using the ElasticSearch Query DSL or the Koncorde Filters DSL syntax.
If the body is left empty, the result will return all available api keys for the user.
Response #
Returns an object with the following properties:
hits
: array of object. Each object describes a found API key:_id
: API key ID_source
: API key content without thetoken
fielduserId
: user kuidexpiresAt
: expiration date in UNIX micro-timestamp format (-1
if the token never expires)ttl
: original ttldescription
: descriptionfingerprint
: SHA256 hash of the authentication token
total
: total number of API keys found. Depending on pagination options, this can be greater than the actual number of API keys in a single result page
{
"status": 200,
"error": null,
"action": "searchApiKeys",
"controller": "auth",
"requestId": "<unique request identifier>",
"result": {
"total": 2,
"hits": [
{
"_id": "api-key-1",
"_source": {
"userId": "mWakSm4BWtbu6xy6NY8K",
"expiresAt": -1,
"ttl": -1,
"description": "Sigfox callback authentication token",
"fingerprint": "4ee98cb8c614e99213e7695f822e42325d86c93cfaf39cb40e860939e784c8e6"
}
},
{
"_id": "api-key-1",
"_source" {
// API key content
}
}
]
}
}
Edit this page on Github (opens new window)