application/json

BodyRequired

  • accessobject Required
    Hide access attributes Show access attributes object
    • replicationarray[object]

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

      Hide replication attributes Show replication attributes object
  • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

  • metadataobject
    Hide metadata attribute Show metadata attribute object
  • namestring Required

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • api_keystring Required

      Generated API key.

    • Time unit for milliseconds

    • idstring Required
    • namestring Required
    • encodedstring Required

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

POST /_security/cross_cluster/api_key
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"
  }
}