Create a cross-cluster API key

  • POST /_security/cross_cluster/api_key
Auth

Create an API key of the cross_cluster type for the API key based remote cluster access. A cross_cluster API key cannot be used to authenticate through the REST interface.

Important

To authenticate this request you must use a credential that is not an API key. Even if you use an API key that has the required privilege, the API returns an error.

Cross-cluster API keys are created by the Elasticsearch API key service, which is automatically enabled.

Note

Unlike REST API keys, a cross-cluster API key does not capture permissions of the authenticated user. The API key’s effective permission is exactly as specified with the access property.

A successful request returns a JSON structure that contains the API key, its unique ID, and its name. If applicable, it also returns expiration information for the API key in milliseconds.

By default, API keys never expire. You can specify expiration information when you create the API keys.

Cross-cluster API keys can only be updated with the update cross-cluster API key API. Attempting to update them with the update REST API key API or the bulk update REST API keys API will result in an error.

Read the reference documentation

Required authorization

Cluster privileges manage_security

Request body

access object required

The access to be granted to this API key. The access is composed of permissions for cross-cluster search and cross-cluster replication. At least one of them must be specified.

Note

No explicit privileges should be specified for either search or replication access. The creation process automatically converts the access specification to a role descriptor which has relevant privileges assigned accordingly.

replication object[]

A list of indices permission entries for cross-cluster replication.

names union string | string[] required

A list of indices (or index name patterns) to which the permissions in this entry apply.

allow_restricted_indices boolean · default: false

This needs to be set to true if the patterns in the names field should cover system indices.

A list of indices permission entries for cross-cluster search.

field_security object

The document fields that the owners of the role have read access to.

except union oneOf
One of: string[] or string
grant union oneOf
One of: string[] or string
names union string | string[] required

A list of indices (or index name patterns) to which the permissions in this entry apply.

query union oneOf

A search query that defines the documents the owners of the role have access to. A document within the specified indices must match this query for it to be accessible by the owners of the role.

One of:
allow_restricted_indices boolean · default: false

Set to true if using wildcard or regular expressions for patterns that cover restricted indices. Implicitly, restricted indices have limited privileges that can cause pattern tests to fail. If restricted indices are explicitly included in the names list, Elasticsearch checks privileges against these indices regardless of the value set for allow_restricted_indices.

expiration string

Expiration time for the API key. By default, API keys never expire.

metadata object

Arbitrary metadata that you want to associate with the API key. It supports nested data structure. Within the metadata object, keys beginning with _ are reserved for system usage.

name string required

Specifies the name for this API key.

Response

application/json
api_key string required

Generated API key.

expiration number

Expiration in milliseconds for the API key.

id string required

Unique ID for this API key.

name string required

Specifies the name for this API key.

encoded string required

API key credentials which is the base64-encoding of the UTF-8 representation of id and api_key joined by a colon (:).