Generate User Token API
Introduced 2.7
Generates an authorization token for the specified user.
A token can only be generated for a service account: an internal user created with the service and enabled attributes set to true. A request for any other user fails. For more information, see Service accounts.
Endpoints
POST /_plugins/_security/api/internalusers/{username}/authtoken
Path parameters
The following table lists the available path parameters.
| Parameter | Required | Data type | Description |
|---|---|---|---|
username | Required | String | The name of the user for whom to issue an authorization token. |
Example request
The following request generates a token for the svc-account service account:
POST _plugins/_security/api/internalusers/svc-account/authtoken
Example response
The generated token is returned in the message field:
{
"status": "OK",
"message": "'svc-account' authtoken generated Basic auth token with user=svc-account, password=4Yz0kQJsliaQ35"
}
Response body fields
The response body is a JSON object with the following fields.
| Field | Data type | Description |
|---|---|---|
status | String | The status of the request. OK indicates that OpenSearch generated a token. |
message | String | The generated credentials, in the form '<username>' authtoken generated Basic auth token with user=<username>, password=<password>. |