BodyRequired
- access
object Required - expiration
string A duration. Units can be
nanos
,micros
,ms
(milliseconds),s
(seconds),m
(minutes),h
(hours) andd
(days). Also accepts "0" without a unit and "-1" to indicate an unspecified value. - metadata
object - name
string Required
POST /_security/cross_cluster/api_key
Console
POST /_security/cross_cluster/api_key
{
"name": "my-cross-cluster-api-key",
"expiration": "1d",
"access": {
"search": [
{
"names": ["logs*"]
}
],
"replication": [
{
"names": ["archive*"]
}
]
},
"metadata": {
"description": "phase one",
"environment": {
"level": 1,
"trusted": true,
"tags": ["dev", "staging"]
}
}
}
resp = client.security.create_cross_cluster_api_key(
name="my-cross-cluster-api-key",
expiration="1d",
access={
"search": [
{
"names": [
"logs*"
]
}
],
"replication": [
{
"names": [
"archive*"
]
}
]
},
metadata={
"description": "phase one",
"environment": {
"level": 1,
"trusted": True,
"tags": [
"dev",
"staging"
]
}
},
)
const response = await client.security.createCrossClusterApiKey({
name: "my-cross-cluster-api-key",
expiration: "1d",
access: {
search: [
{
names: ["logs*"],
},
],
replication: [
{
names: ["archive*"],
},
],
},
metadata: {
description: "phase one",
environment: {
level: 1,
trusted: true,
tags: ["dev", "staging"],
},
},
});
response = client.security.create_cross_cluster_api_key(
body: {
"name": "my-cross-cluster-api-key",
"expiration": "1d",
"access": {
"search": [
{
"names": [
"logs*"
]
}
],
"replication": [
{
"names": [
"archive*"
]
}
]
},
"metadata": {
"description": "phase one",
"environment": {
"level": 1,
"trusted": true,
"tags": [
"dev",
"staging"
]
}
}
}
)
$resp = $client->security()->createCrossClusterApiKey([
"body" => [
"name" => "my-cross-cluster-api-key",
"expiration" => "1d",
"access" => [
"search" => array(
[
"names" => array(
"logs*",
),
],
),
"replication" => array(
[
"names" => array(
"archive*",
),
],
),
],
"metadata" => [
"description" => "phase one",
"environment" => [
"level" => 1,
"trusted" => true,
"tags" => array(
"dev",
"staging",
),
],
],
],
]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"name":"my-cross-cluster-api-key","expiration":"1d","access":{"search":[{"names":["logs*"]}],"replication":[{"names":["archive*"]}]},"metadata":{"description":"phase one","environment":{"level":1,"trusted":true,"tags":["dev","staging"]}}}' "$ELASTICSEARCH_URL/_security/cross_cluster/api_key"
Request example
Run `POST /_security/cross_cluster/api_key` to create a cross-cluster API key.
{
"name": "my-cross-cluster-api-key",
"expiration": "1d",
"access": {
"search": [
{
"names": ["logs*"]
}
],
"replication": [
{
"names": ["archive*"]
}
]
},
"metadata": {
"description": "phase one",
"environment": {
"level": 1,
"trusted": true,
"tags": ["dev", "staging"]
}
}
}
Response examples (200)
A successful response from `POST /_security/service/elastic/fleet-server/credential/token`.
{
"created": true,
"token": {
"name": "Jk5J1HgBuyBK5TpDrdo4",
"value": "AAEAAWVsYXN0aWM...vZmxlZXQtc2VydmVyL3Rva2VuMTo3TFdaSDZ"
}
}