Get API key information Added in 6.7.0

GET /_security/api_key

Retrieves information for one or more API keys. NOTE: If you have only the manage_own_api_key privilege, this API returns only the API keys that you own. If you have read_security, manage_api_key or greater privileges (including manage_security), this API returns all API keys regardless of ownership.

Query parameters

  • id string

    An API key id. This parameter cannot be used with any of name, realm_name or username.

  • name string

    An API key name. This parameter cannot be used with any of id, realm_name or username. It supports prefix search with wildcard.

  • owner boolean

    A boolean flag that can be used to query API keys owned by the currently authenticated user. The realm_name or username parameters cannot be specified when this parameter is set to true as they are assumed to be the currently authenticated ones.

  • The name of an authentication realm. This parameter cannot be used with either id or name or when owner flag is set to true.

  • username string

    The username of a user. This parameter cannot be used with either id or name or when owner flag is set to true.

  • Return the snapshot of the owner user's role descriptors associated with the API key. An API key's actual permission is the intersection of its assigned role descriptors and the owner user's role descriptors.

  • A boolean flag that can be used to query API keys that are currently active. An API key is considered active if it is neither invalidated, nor expired at query time. You can specify this together with other parameters such as owner or name. If active_only is false, the response will include both active and inactive (expired or invalidated) keys.

  • Determines whether to also retrieve the profile uid, for the API key owner principal, if it exists.

Responses

  • 200 application/json
    Hide response attribute Show response attribute object
    • api_keys array[object] Required
      Hide api_keys attributes Show api_keys attributes object
      • creation number

        Creation time for the API key in milliseconds.

      • Expiration time for the API key in milliseconds.

      • id string Required
      • Invalidation status for the API key. If the key has been invalidated, it has a value of true. Otherwise, it is false.

      • name string Required
      • realm string

        Realm name of the principal for which this API key was created.

      • Realm type of the principal for which this API key was created

      • username string
      • The profile uid for the API key owner principal, if requested and if it exists

      • metadata object
        Hide metadata attribute Show metadata attribute object
        • * object Additional properties

          Additional properties are allowed.

      • The role descriptors assigned to this API key when it was created or last updated. An empty role descriptor means the API key inherits the owner user’s permissions.

        Hide role_descriptors attribute Show role_descriptors attribute object
        • * object Additional properties

          Additional properties are allowed.

          Hide * attributes Show * attributes object
          • cluster array[string]

            A list of cluster privileges. These privileges define the cluster level actions that API keys are able to execute.

          • indices array[object]

            A list of indices permissions entries.

            Additional properties are allowed.

          • global array[object] | object

            An object defining global privileges. A global privilege is a form of cluster privilege that is request-aware. Support for global privileges is currently limited to the management of application privileges.

          • applications array[object]

            A list of application privilege entries

            Additional properties are allowed.

          • metadata object
            Hide metadata attribute Show metadata attribute object
            • * object Additional properties

              Additional properties are allowed.

          • run_as array[string]

            A list of users that the API keys can impersonate. Note: in Serverless, the run-as feature is disabled. For API compatibility, you can still specify an empty run_as field, but a non-empty list will be rejected.

          • Optional description of the role descriptor

          • Hide transient_metadata attribute Show transient_metadata attribute object
            • * object Additional properties

              Additional properties are allowed.

      • limited_by array[object]

        The owner user’s permissions associated with the API key. It is a point-in-time snapshot captured at creation and subsequent updates. An API key’s effective permissions are an intersection of its assigned privileges and the owner user’s permissions.

        Hide limited_by attribute Show limited_by attribute object
        • * object Additional properties

          Additional properties are allowed.

          Hide * attributes Show * attributes object
          • cluster array[string]

            A list of cluster privileges. These privileges define the cluster level actions that API keys are able to execute.

          • indices array[object]

            A list of indices permissions entries.

          • applications array[object]

            A list of application privilege entries

          • metadata object
          • run_as array[string]

            A list of users that the API keys can impersonate. Note: in Serverless, the run-as feature is disabled. For API compatibility, you can still specify an empty run_as field, but a non-empty list will be rejected.

          • Optional description of the role descriptor

      • _sort array[number | string | boolean | null | object]
GET /_security/api_key
curl \
 -X GET http://api.example.com/_security/api_key
Response examples (200)
{
  "api_keys": [
    {
      "creation": 42.0,
      "expiration": 42.0,
      "id": "string",
      "invalidated": true,
      "name": "string",
      "realm": "string",
      "realm_type": "string",
      "username": "string",
      "profile_uid": "string",
      "metadata": {
        "additionalProperty1": {},
        "additionalProperty2": {}
      },
      "role_descriptors": {
        "additionalProperty1": {
          "cluster": [
            "string"
          ],
          "indices": [
            {}
          ],
          "global": [
            {}
          ],
          "applications": [
            {}
          ],
          "metadata": {
            "additionalProperty1": {},
            "additionalProperty2": {}
          },
          "run_as": [
            "string"
          ],
          "description": "string",
          "transient_metadata": {
            "additionalProperty1": {},
            "additionalProperty2": {}
          }
        },
        "additionalProperty2": {
          "cluster": [
            "string"
          ],
          "indices": [
            {}
          ],
          "global": [
            {}
          ],
          "applications": [
            {}
          ],
          "metadata": {
            "additionalProperty1": {},
            "additionalProperty2": {}
          },
          "run_as": [
            "string"
          ],
          "description": "string",
          "transient_metadata": {
            "additionalProperty1": {},
            "additionalProperty2": {}
          }
        }
      },
      "limited_by": [
        {
          "additionalProperty1": {
            "cluster": [
              "string"
            ],
            "indices": [
              {}
            ],
            "applications": [
              {}
            ],
            "metadata": {},
            "run_as": [
              "string"
            ],
            "description": "string",
            "transient_metadata": {}
          },
          "additionalProperty2": {
            "cluster": [
              "string"
            ],
            "indices": [
              {}
            ],
            "applications": [
              {}
            ],
            "metadata": {},
            "run_as": [
              "string"
            ],
            "description": "string",
            "transient_metadata": {}
          }
        }
      ],
      "_sort": [
        42.0
      ]
    }
  ]
}