Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an API key with a name.
Elasticsearch
POST /_security/api_key
{
"name": "[1]"
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name other than 'name' for the API key name.
Leaving the name empty or using invalid characters.
✗ Incorrect
The name field sets the API key's name. Here, my-api-key is a valid name.
2fill in blank
mediumComplete the code to specify the role descriptors for the API key.
Elasticsearch
POST /_security/api_key
{
"name": "my-api-key",
"role_descriptors": {
"[1]": {
"cluster": ["all"]
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid characters or spaces in the role name.
Omitting the role name key inside
role_descriptors.✗ Incorrect
The role_descriptors object requires a role name key. role1 is a valid role name here.
3fill in blank
hardFix the error in the code to delete an API key by its ID.
Elasticsearch
DELETE /_security/api_key/[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase, snake_case, or incorrect parameter names in the URL.
Omitting the API key ID in the delete request.
✗ Incorrect
The API key ID must be placed directly in the URL path. id is the correct placeholder here.
4fill in blank
hardFill both blanks to create an API key with limited privileges.
Elasticsearch
POST /_security/api_key
{
"name": "limited-key",
"role_descriptors": {
"[1]": {
"cluster": ["[2]"]
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'admin' privilege when limited access is intended.
Not matching the role name and privilege correctly.
✗ Incorrect
The role name is limited_role and the cluster privilege is monitor to limit access.
5fill in blank
hardFill all three blanks to create an API key with a name, role, and expiration.
Elasticsearch
POST /_security/api_key
{
"name": "[1]",
"role_descriptors": {
"[2]": {
"cluster": ["all"]
}
},
"expiration": "[3]"
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid expiration formats.
Omitting the expiration field when a temporary key is needed.
✗ Incorrect
The API key is named temp-key, uses role temp_role, and expires after 1d (one day).