code | type | title | description |
---|---|---|---|
true |
page |
createApiKey |
Creates a new API key for a user |
Creates a new API key for a user.
Future<Map<String, dynamic>> createApiKey(
String userId, String description,
{String expiresIn, bool refresh})
Property | Type | Description |
---|---|---|
userId |
String |
User kuid |
description |
String |
API key description |
expiresIn |
String ( -1 ) |
Expiration duration |
refresh |
bool ( false ) |
If set to wait_for , Kuzzle will not respond until the API key is indexed |
Notes:
expiresIn
:- if a raw number is provided (not enclosed between quotes), then the expiration delay is in milliseconds. Example:
86400000
- if this value is a string, then its content is parsed by the ms library. Examples:
"6d"
,"10h"
- if
-1
is provided, the token will never expire
- if a raw number is provided (not enclosed between quotes), then the expiration delay is in milliseconds. Example:
An object containing the newly created API key:
Name | Type | Description |
---|---|---|
_id |
String |
ID of the newly created API key |
_source |
Map<String, dynamic> |
API key content |
The API key content has the following properties:
Name | Type | Description |
---|---|---|
userId |
String |
User kuid |
expiresAt |
int |
Expiration date in UNIX micro-timestamp format (-1 if the token never expires) |
ttl |
int |
Original TTL |
description |
String |
API key description |
token |
String |
Authentication token associated with this API key |
::: warning
The authentication token token
will never be returned by Kuzzle again. If you lose it, you'll have to delete the API key and recreate a new one.
:::
<<< ./snippets/create-api-key.dart