Create an APM agent key
Base URL
https://{kibana_url}
Auth
Create a new agent key for APM.
The user creating an APM agent API key must have at least the manage_own_api_key cluster privilege and the APM application-level privileges that it wishes to grant.
After it is created, you can copy the API key (Base64 encoded) and use it to to authorize requests from APM agents to the APM Server.
Expand all
The version of the API to use
Values:
2023-10-31
A required header to protect against CSRF attacks
{
}
name
string
required
The name of the APM agent key.
privileges
enum []
required
The APM agent key privileges. It can take one or more of the following values:
event:write, which is required for ingesting APM agent events. * config_agent:read, which is required for APM agents to read agent configuration remotely.
Values:
event:write
config_agent:read
200
Agent key created successfully
application/json
agentKey
object
Agent key
+
Show 5 properties
expiration
integer · format: int64
message
string
Error message
statusCode
number
Error status code
message
string
Error message
statusCode
number
Error status code
message
string
Error message
statusCode
number
Error status code
500
Internal Server Error response
application/json
message
string
Error message
statusCode
number
Error status code
Thank you for your feedback.
Base URL
https://{kibana_url}
Examples
Request
Console
1 / 2 languages
‹
›
Run POST /api/apm/agent_keys to create an APM agent API key with the specified privileges.
Show more
1
2
3
4
5
6
7
8
POST kbn:/api/apm/agent_keys
{
"name": "apm-key",
"privileges": [
"event:write",
"config_agent:read"
]
}
Generated from the API spec
1
2
3
4
5
6
7
8
9
10
11
12
curl -X POST "${KIBANA_URL}/api/apm/agent_keys" \
-H "elastic-api-version: 2023-10-31" \
-H "kbn-xsrf: true" \
-H "Authorization: ApiKey ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "apm-key",
"privileges": [
"event:write",
"config_agent:read"
]
}'
Generated from the API spec
Response
An example of a successful response from POST /api/apm/agent_keys, which creates an APM agent API key.
Show more
An example of a 400 Bad Request response, returned when the request payload or query parameters fail validation.
Show more
An example of a 401 Unauthorized response, returned when the request is missing valid authentication credentials.
Show more
An example of a 403 Forbidden response, returned when the authenticated user lacks the required APM and User Experience privileges.
Show more
An example of a 500 Internal Server Error response, returned when an unexpected error occurs while processing the request.
Show more
1
2
3
4
5
6
7
8
{
"agentKey": {
"api_key": "PjGloCGOTzaZr8ilUPvkjA",
"encoded": "M0RDTG1uMEIzWk1oTFVhN1dCRzk6UGpHbG9DR09UemFacjhpbFVQdmtqQQ==",
"id": "3DCLmn0B3ZMhLUa7WBG9",
"name": "apm-key"
}
}
1
2
3
4
5
{
"error": "Bad Request",
"message": "[request body]: expected value of type [string] but got [undefined]",
"statusCode": 400
}
1
2
3
4
5
{
"error": "Unauthorized",
"message": "[security_exception]: missing authentication credentials for REST request",
"statusCode": 401
}
1
2
3
4
5
{
"error": "Forbidden",
"message": "Insufficient privileges to perform this action. The APM and User Experience feature requires \u0060all\u0060 privileges.",
"statusCode": 403
}
1
2
3
4
5
{
"error": "Internal Server Error",
"message": "An internal server error occurred. Check the Kibana server logs for details.",
"statusCode": 500
}