Installation
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install onboarding@skills-hub
Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled).
Plugin onboarding v1.0.0 follows the Agent Plugins spec.
gh skills-hub install onboarding Don't have the extension? Run gh extension install samueltauil/skills-hub first.
Download and extract to your repository:
.github/skills/cloud-onboarding/ Extract the ZIP to .github/skills/ in your repo. The folder name must match cloud-onboarding for Copilot to auto-discover it.
Skill Files (2)
SKILL.md 16.0 KB
---
name: cloud-onboarding
description: >
Onboard an Elastic Cloud organization: configure the `elastic` CLI's Cloud context
and API key, establish a default region, then invite users, assign predefined or
custom Serverless project roles, and create or revoke Cloud API keys. Use when setting
up Cloud authentication or when granting, modifying, or auditing user access to
an organization and its projects.
compatibility: >
Requires the `elastic` CLI (>= 0.2) with `cloud` support and network access to the
Elastic Cloud API (api.elastic-cloud.com). Custom-role operations additionally need
an Elasticsearch context on the target Serverless project with `manage_security`.
Targets the Elastic Cloud control plane; not applicable to self-managed clusters.
metadata:
author: elastic
version: 0.3.0
universal: true
---
# Cloud Onboarding
Stand up access to an Elastic Cloud organization end to end: configure the `elastic` CLI so it can operate the control
plane, then manage identity and access — invite users, assign predefined or custom roles to Serverless projects, and
manage Cloud API keys. For creating and operating projects and deployments, use the **cloud-provisioning** skill.
## Environment Configuration
This skill configures the `elastic` CLI itself, so its setup lives here rather than being assumed. If the
[`elastic` CLI](https://github.com/elastic/cli#configuration) is not installed, tell the user what it is needed for.
Cloud control-plane access is authenticated by an **Elastic Cloud API key** (organization scope), stored in a CLI
**context**. Register it without ever having the user paste the secret into the chat:
- Only **Organization owners** can create Cloud API keys. Direct the user to generate one at
[Elastic Cloud API keys](https://cloud.elastic.co/account/keys) with **Project Admin** privileges or higher so it can
manage serverless projects.
- If the user has no Elastic Cloud account, propose the free
[Elastic Cloud trial](https://cloud.elastic.co/registration) (14 days, no credit card). Once registered, continue with
key generation.
- Add the key to a context (the secret is stored in the OS keychain, not echoed):
`elastic config context add cloud --cloud-url https://api.elastic-cloud.com --cloud-api-key <KEY>`, then make it
active with `elastic config current-context set cloud`.
Do not guess credentials, bypass the CLI to call the HTTP API directly, or ask the user to reveal the key. This skill
references control-plane operations in HTTP-shorthand form with the `cloud:` prefix (for example,
`GET cloud:/api/v1/organizations`); the [Operations](#operations) table maps each to the equivalent `elastic cloud`
command.
For detailed API schemas (role assignments, Cloud API keys, custom roles), see
[references/api-reference.md](references/api-reference.md). For Elasticsearch-level role management beyond Cloud roles
(native users, role mappings, DLS/FLS) see **elasticsearch-authz**.
## Jobs to be done
- Configure and validate a Cloud context; establish a default region for later project creation
- Invite a user and assign a Serverless project role; list members and their roles; update or remove access
- Create, list, and revoke Cloud API keys, optionally with Elasticsearch/Kibana API access on projects
- Create a custom role in a Serverless project and assign it via the Cloud API's `application_roles`
- Translate a natural-language access request into invite, role, and API key tasks
## Process: validate the environment
1. **Validate the Cloud context.** Confirm the active context can reach the control plane by calling
`GET cloud:/api/v1/organizations`. A successful response lists the organizations the key belongs to and yields the
organization ID other steps need. If it returns an authentication error, the context is missing or the key is invalid
or expired — return to [Environment Configuration](#environment-configuration) and register a valid key. Do not
proceed until validation succeeds, and never ask the user for the organization ID — discover it here.
2. **Establish a default region (optional).** When the user plans to create projects, list the available regions with
`GET cloud:/api/v1/serverless/regions` and confirm a default. Default to `gcp-us-central1` unless the user requests
otherwise; only regions with `project_creation_enabled: true` accept new projects. Region choice is permanent per
project, so surface it early.
## Permissions
This skill does not pre-check roles; it attempts the operation and lets the API enforce authorization. On a `403`, stop
and ask the user to verify the API key's permissions.
| Operation | Required permission |
| ---------------------------------- | -------------------------------------------------------------- |
| Invite / remove members | Organization owner (`organization-admin`) |
| Assign or remove roles | Organization owner (`organization-admin`) |
| Create / revoke Cloud API keys | Organization owner (`organization-admin`) |
| List members, invitations, or keys | Any organization member |
| Create / delete custom roles | `manage_security` cluster privilege on the project ES endpoint |
## Predefined roles
Prefer predefined roles; only create a custom role when they lack the required granularity.
**Organization:** `organization-admin` (full admin), `billing-admin` (billing only).
**Serverless project roles** (assign at invitation or via role-assignment update):
| Role | `role_id` | Available on |
| --------- | ---------------------------------------------------------------------- | --------------------- |
| Admin | `admin` | Search, Obs, Security |
| Developer | `developer` | Search |
| Viewer | `viewer` | Search, Obs, Security |
| Editor | `editor` | Obs, Security |
| Analysts | `t1_analyst`, `t2_analyst`, `t3_analyst`, `soc_manager`, `rule_author` | Security |
See [references/api-reference.md](references/api-reference.md) for the full `role_assignments` schema (organization,
deployment, and project scopes) and the complete Security role list.
## Process: decompose an access request
When the user describes access in natural language (for example, "add Alice to my search project as a developer"), break
it down before executing.
1. **Identify components.** Who (new invite vs existing member), what (which project or org-level), access level
(predefined vs custom role), and whether an API key is also needed.
2. **Check existing state first.** List members with `GET cloud:/api/v1/organizations/{org_id}/members` and, for key
requests, existing keys with `GET cloud:/api/v1/users/auth/keys`. If the user is already a member, update their roles
instead of inviting. If an active key already exists **for the same purpose** with the right roles and enough
remaining lifetime, reuse it.
3. **Execute the smallest sufficient change.**
- **Invite** a new member with `POST cloud:/api/v1/organizations/{org_id}/invitations` (include project role
assignments, or invite without roles when a custom role will follow).
- **Update** an existing member's roles with `POST cloud:/api/v1/users/{user_id}/role_assignments`; remove with the
`DELETE` variant.
- **Remove** a member with `DELETE cloud:/api/v1/organizations/{org_id}/members/{user_ids}` (confirm first).
- **Create a Cloud API key** with `POST cloud:/api/v1/users/auth/keys`; revoke with
`DELETE cloud:/api/v1/users/auth/keys` (confirm first). Confirm destructive actions (remove member, revoke key)
with the user before executing.
4. **Verify.** List members or keys again to confirm the change took effect.
## Custom roles (Serverless)
When predefined roles lack the granularity, create a custom role in the project via the Elasticsearch security API and
assign it through the Cloud API's `application_roles`:
1. Create the role in the project with `PUT /_security/role/{name}` (runs against the project's Elasticsearch endpoint;
requires `manage_security`). Role names must start with a letter or digit and contain only letters, digits, `_`, `-`,
`.`. Run-as privileges are not available in Serverless.
2. Invite the user if needed — **without** project role assignments (the custom role handles project access).
3. Assign the custom role by setting `application_roles` on a project-scoped role assignment
(`POST cloud:/api/v1/users/{user_id}/role_assignments`) with `role_id` set to the project-type viewer
(`elasticsearch-viewer`, `observability-viewer`, `security-viewer`).
> **Do not also assign a predefined Cloud role for the same project.** A custom role already grants Viewer-level Cloud
> access; adding `viewer` (or another predefined role) gives the user the union of both, widening access beyond what the
> custom role intends.
## Cloud API keys with stack access
Cloud API keys can also call Elasticsearch and Kibana APIs on Serverless projects by including `application_roles` in
their `role_assignments`. Unlike users, **API keys never inherit stack roles from `role_id`** — without
`application_roles` the key has Cloud-API-only access and receives `403` on ES/Kibana calls.
- **Default to project-scoped** assignments (`project` key) so the key only reaches named projects or all projects of a
type.
- **Organization-scoped** assignments (`organization` key) grant ES/Kibana access to **all current and future** projects
— the broadest data-plane scope. Only use it for genuine cross-project automation, and confirm with the user first.
- Custom role names in `application_roles` must exist in each target project, or the key silently gets no access there.
Predefined roles (`admin`, `developer`, `viewer`) exist in every project by default.
## Examples
**"Set up my cloud environment"** — verify a Cloud context exists, then validate it with
`GET cloud:/api/v1/organizations`. If it fails, walk the user through generating an Organization-level Cloud API key and
registering it as a context (never in chat), then re-validate and report the discovered organization.
**"Set up cloud in the EU region"** — after validating the context, list regions with
`GET cloud:/api/v1/serverless/regions`, pick an EU region (for example `aws-eu-west-1`), and confirm it as the default
for subsequent project creation.
**"Add `alice@example.com` to my search project with read-only access"** — check members with
`GET cloud:/api/v1/organizations/{org_id}/members`; if Alice is new,
`POST cloud:/api/v1/organizations/{org_id}/invitations` with a project-scoped `viewer` role for the Elasticsearch
project.
**"Create a 30-day CI key that can index into our search projects"** — list keys with
`GET cloud:/api/v1/users/auth/keys` to avoid duplicates, then `POST cloud:/api/v1/users/auth/keys` with a project-scoped
`developer` role assignment including `application_roles: ["developer"]` and `expiration: "30d"`. The secret is shown
once — never repeat it in chat.
**"Give `bob@example.com` read-only access to marketing-\* on my search project"** — create a custom role with
`PUT /_security/role/marketing-reader` (read on `marketing-*`), invite Bob without project roles, then assign the custom
role via `application_roles` on `POST cloud:/api/v1/users/{user_id}/role_assignments`. Do not also assign `viewer`.
**"Show who has access to my organization"** — `GET cloud:/api/v1/organizations/{org_id}/members` and present each
member's ID, email, and roles.
## Guidelines
- Validate the Cloud context first; discover the organization ID from `GET cloud:/api/v1/organizations` — do not ask for
it.
- **Never receive, echo, or log credentials in chat.** Register the Cloud API key into a CLI context so the secret goes
to the OS keychain; if the user offers to paste a key, decline and point them to context registration instead. A
created key's secret is shown only once — tell the user to store it securely; never repeat it.
- **Default region is `gcp-us-central1`** — only change it when the user requests a different region.
- Confirm destructive actions (remove member, revoke key) before executing.
- Prefer predefined roles; reach for custom roles only when needed, and never stack a predefined Cloud role on the same
project as a custom role.
- **API key hygiene:** check existing keys before creating; set an `expiration` matching the task lifetime; prompt the
user to revoke keys no longer needed. Each organization supports up to 500 active keys; default expiration is 3
months. Invitations expire after 72 hours by default. Cloud API keys inherit roles at creation and cannot be updated —
revoke and recreate to change roles.
- For creating and operating projects, traffic filters, and deployments, see **cloud-provisioning**; for ES-level role
management see **elasticsearch-authz**.
## Operations
| HTTP API (shorthand) | `elastic` CLI command |
| ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| `GET cloud:/api/v1/organizations` | `elastic cloud orgs list-organizations` |
| `GET cloud:/api/v1/serverless/regions` | `elastic cloud serverless regions list-regions` |
| `GET cloud:/api/v1/organizations/{org_id}/members` | `elastic cloud orgs list-organization-members --organization-id <org_id>` |
| `POST cloud:/api/v1/organizations/{org_id}/invitations` | `elastic cloud orgs create-organization-invitations --organization-id <org_id> --input-file <json>` |
| `GET cloud:/api/v1/organizations/{org_id}/invitations` | `elastic cloud orgs list-organization-invitations --organization-id <org_id>` |
| `DELETE cloud:/api/v1/organizations/{org_id}/invitations/{tokens}` | `elastic cloud orgs delete-organization-invitations --organization-id <org_id> --invitation-tokens <csv>` |
| `DELETE cloud:/api/v1/organizations/{org_id}/members/{user_ids}` | `elastic cloud orgs delete-organization-memberships --organization-id <org_id> --user-ids <csv>` |
| `POST cloud:/api/v1/users/{user_id}/role_assignments` | `elastic cloud users add-role-assignments --user-id <user_id> --input-file <json>` |
| `DELETE cloud:/api/v1/users/{user_id}/role_assignments` | `elastic cloud users remove-role-assignments --user-id <user_id> --input-file <json>` |
| `POST cloud:/api/v1/users/auth/keys` | `elastic cloud auth create-api-key --input-file <json>` |
| `GET cloud:/api/v1/users/auth/keys` | `elastic cloud auth get-api-keys` |
| `DELETE cloud:/api/v1/users/auth/keys` | `elastic cloud auth delete-api-keys --input-file <json>` |
| `PUT /_security/role/{name}` | `elastic es security put-role --name <name> --input-file <json>` |
| `GET /_security/role` | `elastic es security get-role` |
| `DELETE /_security/role/{name}` | `elastic es security delete-role --name <name>` |
api-reference.md 20.3 KB
# Cloud Onboarding — API Reference
All Cloud API calls use base URL `https://api.elastic-cloud.com/api/v1` and require the header
`Authorization: ApiKey $EC_API_KEY`.
Serverless ES API calls use the project Elasticsearch endpoint and require either basic auth or an Elasticsearch API key
with `manage_security` privileges.
## Table of Contents
- [Organization Discovery](#organization-discovery)
- [Organization Members](#organization-members)
- [List members](#list-members)
- [Invite users](#invite-users)
- [List pending invitations](#list-pending-invitations)
- [Cancel invitations](#cancel-invitations)
- [Remove members](#remove-members)
- [Role Assignments](#role-assignments)
- [Add role assignments to a user](#add-role-assignments-to-a-user)
- [Role assignments schema](#role-assignments-schema)
- [Assign a custom role using application_roles](#assign-a-custom-role-using-application_roles)
- [Remove role assignments](#remove-role-assignments)
- [Cloud API Keys](#cloud-api-keys)
- [Create an API key](#create-an-api-key)
- [List all API keys](#list-all-api-keys)
- [Delete API keys](#delete-api-keys)
- [Serverless Custom Roles (Elasticsearch Security API)](#serverless-custom-roles-elasticsearch-security-api)
- [Create or update a custom role](#create-or-update-a-custom-role)
- [Get a custom role](#get-a-custom-role)
- [List all roles](#list-all-roles)
- [Delete a custom role](#delete-a-custom-role)
---
## Organization Discovery
> **Official API docs:**
> [List organizations](https://www.elastic.co/docs/api/doc/cloud/operation/operation-list-organizations)
### Get organizations
```text
GET /organizations
```
Returns the list of organizations the authenticated user belongs to. Use to auto-discover `organization_id`.
```bash
curl -s -H "Authorization: ApiKey $EC_API_KEY" \
"https://api.elastic-cloud.com/api/v1/organizations"
```
**Response** (200):
```json
{
"organizations": [
{
"id": "org-uuid-here",
"name": "My Organization"
}
]
}
```
---
## Organization Members
> **Official API docs:**
> [List members](https://www.elastic.co/docs/api/doc/cloud/operation/operation-list-organization-members) ·
> [Invite users](https://www.elastic.co/docs/api/doc/cloud/operation/operation-create-organization-invitations) ·
> [List invitations](https://www.elastic.co/docs/api/doc/cloud/operation/operation-list-organization-invitations) ·
> [Delete invitations](https://www.elastic.co/docs/api/doc/cloud/operation/operation-delete-organization-invitations) ·
> [Remove members](https://www.elastic.co/docs/api/doc/cloud/operation/operation-delete-organization-memberships)
### List members
```text
GET /organizations/{organization_id}/members
```
```bash
curl -s -H "Authorization: ApiKey $EC_API_KEY" \
"https://api.elastic-cloud.com/api/v1/organizations/$ORG_ID/members"
```
**Response** (200):
```json
{
"members": [
{
"user_id": "user-uuid",
"email": "alice@example.com",
"name": "Alice",
"role_assignments": { ... }
}
]
}
```
| Status | Meaning |
| ------ | --------------------------- |
| 200 | Members listed successfully |
| 404 | Organization not found |
### Invite users
```text
POST /organizations/{organization_id}/invitations
```
```bash
curl -s -X POST \
-H "Authorization: ApiKey $EC_API_KEY" \
-H "Content-Type: application/json" \
"https://api.elastic-cloud.com/api/v1/organizations/$ORG_ID/invitations" \
-d '{
"emails": ["alice@example.com", "bob@example.com"],
"expires_in": "3d",
"role_assignments": {
"organization": [
{ "role_id": "billing-admin" }
],
"deployment": [
{
"role_id": "deployment-viewer",
"organization_id": "'"$ORG_ID"'",
"all": true
}
]
}
}'
```
**Request body fields:**
| Field | Type | Required | Description |
| ------------------ | --------------- | -------- | ---------------------------------------------------------------- |
| `emails` | array\[string\] | Yes | Email addresses to invite |
| `expires_in` | string | No | Expiration duration (default: `3d`) |
| `role_assignments` | object | No | Cloud roles to assign on acceptance (see Role Assignments below) |
| Status | Meaning | Error code |
| ------ | --------------------- | ------------------------------------------------ |
| 201 | Invitations created | |
| 400 | User already in org | `organization.user_organization_already_belongs` |
| 400 | Invitation exists | `organization.invitation_already_exists` |
| 400 | Invalid email | `organization.invitation_invalid_email` |
| 403 | Invalid auth | `root.invalid_authentication` |
| 404 | Org or user not found | `organization.not_found` |
| 429 | Rate limit exceeded | `organization.invitations_rate_limit_exceeded` |
Cloud invitation payloads support Cloud role assignments including `application_roles` for custom roles. However, the
recommended flow is to invite the user first (without project roles) and then assign the custom role separately using
`assign-custom-role` after the invitation is accepted. This avoids accidentally combining a predefined role with a
custom role for the same project.
### List pending invitations
```text
GET /organizations/{organization_id}/invitations
```
```bash
curl -s -H "Authorization: ApiKey $EC_API_KEY" \
"https://api.elastic-cloud.com/api/v1/organizations/$ORG_ID/invitations"
```
### Cancel invitations
```text
DELETE /organizations/{organization_id}/invitations/{invitation_tokens}
```
`invitation_tokens` is a comma-separated list of invitation token strings.
```bash
curl -s -X DELETE -H "Authorization: ApiKey $EC_API_KEY" \
"https://api.elastic-cloud.com/api/v1/organizations/$ORG_ID/invitations/$TOKEN"
```
### Remove members
```text
DELETE /organizations/{organization_id}/members/{user_ids}
```
`user_ids` is a comma-separated list of user IDs.
```bash
curl -s -X DELETE -H "Authorization: ApiKey $EC_API_KEY" \
"https://api.elastic-cloud.com/api/v1/organizations/$ORG_ID/members/$USER_ID"
```
| Status | Meaning |
| ------ | ------------------------------------ |
| 200 | Members removed |
| 404 | Organization or membership not found |
---
## Role Assignments
> **Official API docs:**
> [Add role assignments](https://www.elastic.co/docs/api/doc/cloud/operation/operation-add-role-assignments) ·
> [Remove role assignments](https://www.elastic.co/docs/api/doc/cloud/operation/operation-remove-role-assignments)
### Add role assignments to a user
```text
POST /users/{user_id}/role_assignments
```
```bash
curl -s -X POST \
-H "Authorization: ApiKey $EC_API_KEY" \
-H "Content-Type: application/json" \
"https://api.elastic-cloud.com/api/v1/users/$USER_ID/role_assignments" \
-d '{
"organization": [
{ "role_id": "organization-admin" }
],
"deployment": [
{
"role_id": "deployment-editor",
"organization_id": "'"$ORG_ID"'",
"all": true
}
],
"project": {
"elasticsearch": [
{
"role_id": "admin",
"organization_id": "'"$ORG_ID"'",
"all": false,
"project_ids": ["project-uuid-here"]
}
],
"observability": [],
"security": []
}
}'
```
### Role assignments schema
```json
{
"organization": [
{
"role_id": "<org-role-id>",
"organization_id": "<org-id>",
"application_roles": ["<predefined-or-custom-role>"]
}
],
"deployment": [
{
"role_id": "<deployment-role-id>",
"organization_id": "<org-id>",
"all": true,
"deployment_ids": []
}
],
"project": {
"elasticsearch": [
{
"role_id": "<project-role-id>",
"organization_id": "<org-id>",
"all": false,
"project_ids": ["<project-id>"],
"application_roles": ["<custom-role-name>"]
}
],
"observability": [],
"security": []
}
}
```
**Organization role IDs:** `organization-admin`, `billing-admin`
**Deployment role IDs:** `deployment-admin`, `deployment-editor`, `deployment-viewer`
**Serverless project role IDs (Elasticsearch):** `admin`, `developer`, `viewer`
**Serverless project role IDs (Observability):** `admin`, `editor`, `viewer`
**Serverless project role IDs (Security):** `admin`, `editor`, `viewer`, `t1_analyst`, `t2_analyst`, `t3_analyst`,
`threat_intel_analyst`, `rule_author`, `soc_manager`, `endpoint_operations_analyst`, `platform_engineer`,
`detections_admin`, `endpoint_policy_manager`
For project-scoped assignments that include `application_roles`, use project-type-specific viewer role IDs:
`elasticsearch-viewer`, `observability-viewer`, `security-viewer` (not the generic `viewer`).
**`application_roles`** (optional, array of strings): Specifies which ES/Kibana roles to grant. Accepts predefined role
names (`admin`, `developer`, `viewer`, and solution-specific roles) or custom role names created in the project via
`PUT /_security/role/{name}`. Serverless only. Behavior depends on the principal type:
- **For users:** When set on a project-scoped assignment, the user receives these roles when signing into the project
instead of the default stack role mapped to `role_id`.
- **For API keys:** Grants ES/Kibana API access. Unlike users, API keys **never** inherit stack roles from `role_id` —
`application_roles` must be explicitly provided. If omitted or empty, the API key has Cloud API access only and
receives 403 Forbidden when calling ES/Kibana endpoints.
- **On organization scope:** Grants the specified roles across **all projects (current and future)** in the
organization. Supported for API keys.
> **Broad access warning:** Organization-scoped `application_roles` is the broadest possible data-plane scope — it
> grants ES/Kibana access to every project in the organization, including projects created after the key. Use
> project-scoped assignments when the key only needs access to specific projects. Reserve org-scoped `application_roles`
> for platform automation keys that genuinely require cross-project access.
>
> **Custom roles with org scope:** When using a custom role name in `application_roles`, the role must be defined in
> each project where the key should have access (via `PUT /_security/role/{name}`). If a project does not have that
> role, the key silently gets no access there — no error is raised. Predefined roles (`admin`, `developer`, `viewer`)
> are available in every project by default and do not have this limitation.
>
> **Security:** When using `application_roles`, the user automatically receives Viewer-level Cloud access for the
> project. Do not also assign a predefined Cloud role (such as `viewer`) for the same project as a separate role
> assignment — the user would receive the union of both roles on sign-in, which is broader than the custom role intends.
### Assign a custom role using application_roles
```bash
curl -s -X POST \
-H "Authorization: ApiKey $EC_API_KEY" \
-H "Content-Type: application/json" \
"https://api.elastic-cloud.com/api/v1/users/$USER_ID/role_assignments" \
-d '{
"project": {
"elasticsearch": [
{
"role_id": "elasticsearch-viewer",
"organization_id": "'"$ORG_ID"'",
"all": false,
"project_ids": ["'"$PROJECT_ID"'"],
"application_roles": ["marketing-reader"]
}
]
}
}'
```
This grants the user Viewer-level Cloud access (project visible in the console) and **only** the `marketing-reader`
custom role when they SSO into the project — not the full Viewer stack role. Use the project-type-specific Viewer role
ID (`elasticsearch-viewer`, `observability-viewer`, or `security-viewer`) for the `role_id` value.
### Remove role assignments
```text
DELETE /users/{user_id}/role_assignments
```
Uses the same body schema as `POST`. Removes the specified role assignments from the user.
---
## Cloud API Keys
> **Official API docs:** [Create API key](https://www.elastic.co/docs/api/doc/cloud/operation/operation-create-api-key)
> · [List API keys](https://www.elastic.co/docs/api/doc/cloud/operation/operation-get-api-keys) ·
> [Delete API keys](https://www.elastic.co/docs/api/doc/cloud/operation/operation-delete-api-keys)
Only Organization owners (`organization-admin` role) can create and manage Cloud API keys. Non-owner requests
return 403.
### Create an API key
```text
POST /users/auth/keys
```
```bash
curl -s -X POST \
-H "Authorization: ApiKey $EC_API_KEY" \
-H "Content-Type: application/json" \
"https://api.elastic-cloud.com/api/v1/users/auth/keys" \
-d '{
"description": "CI/CD pipeline key",
"expiration": "30d",
"role_assignments": {
"organization": [
{ "role_id": "billing-admin" }
],
"deployment": [
{
"role_id": "deployment-editor",
"organization_id": "'"$ORG_ID"'",
"all": true
}
]
}
}'
```
**Project-scoped API key with ES access** (grants developer access to all Elasticsearch projects):
```bash
curl -s -X POST \
-H "Authorization: ApiKey $EC_API_KEY" \
-H "Content-Type: application/json" \
"https://api.elastic-cloud.com/api/v1/users/auth/keys" \
-d '{
"description": "CI pipeline with ES access",
"expiration": "30d",
"role_assignments": {
"project": {
"elasticsearch": [
{
"role_id": "developer",
"organization_id": "'"$ORG_ID"'",
"all": true,
"application_roles": ["developer"]
}
]
}
}
}'
```
**Organization-scoped API key with ES access** (grants admin access to ALL current and future projects):
```bash
curl -s -X POST \
-H "Authorization: ApiKey $EC_API_KEY" \
-H "Content-Type: application/json" \
"https://api.elastic-cloud.com/api/v1/users/auth/keys" \
-d '{
"description": "Platform automation key",
"expiration": "7d",
"role_assignments": {
"organization": [
{
"role_id": "organization-admin",
"organization_id": "'"$ORG_ID"'",
"application_roles": ["admin"]
}
]
}
}'
```
> **Caution:** This grants admin-level ES/Kibana access to every project in the organization, including projects created
> after the key. Use project-scoped assignments for narrower access.
**Request body fields:**
| Field | Type | Required | Description |
| ----------------------------------------------------- | ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `description` | string | No | Human-readable label for the key |
| `expiration` | string | No | Duration string (for example, `1d`, `30d`, `3h`). Default: 3mo |
| `role_assignments` | object | No | Roles scoped to the key (same schema as above) |
| `role_assignments.organization[].application_roles` | array[string] | No | ES/Kibana role names for stack access across all projects (org-scoped). If omitted or empty, the key has Cloud API access only. Predefined: `admin`, `developer`, `viewer`, and solution-specific roles. Custom role names also accepted. |
| `role_assignments.project.<type>[].application_roles` | array[string] | No | ES/Kibana role names for stack access on specific projects (project-scoped). Same values as above. Required for ES/Kibana API calls — without it, the key receives 403. |
> **403 on ES/Kibana calls:** If an API key without `application_roles` calls an Elasticsearch or Kibana endpoint, the
> request returns 403 Forbidden. Unlike users, API keys never inherit stack roles from `role_id`. Add explicit
> `application_roles` when the key needs data-plane access.
**Response** (201):
```json
{
"id": "key-uuid",
"key": "the-actual-api-key-value",
"description": "CI/CD pipeline key",
"creation_date": "2026-02-27T10:00:00Z",
"expiration_date": "2026-03-29T10:00:00Z",
"organization_id": "org-uuid",
"user_id": "user-uuid",
"role_assignments": { ... }
}
```
The `key` field is returned **only once** at creation. Store it securely.
### List all API keys
```text
GET /users/auth/keys
```
```bash
curl -s -H "Authorization: ApiKey $EC_API_KEY" \
"https://api.elastic-cloud.com/api/v1/users/auth/keys"
```
### Delete API keys
```text
DELETE /users/auth/keys
```
```bash
curl -s -X DELETE \
-H "Authorization: ApiKey $EC_API_KEY" \
-H "Content-Type: application/json" \
"https://api.elastic-cloud.com/api/v1/users/auth/keys" \
-d '{"keys": ["key-id-1", "key-id-2"]}'
```
| Status | Meaning |
| ------ | ------------ |
| 200 | Keys deleted |
---
## Serverless Custom Roles (Elasticsearch Security API)
> **Official API docs:**
> [Create/update role](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-put-role) ·
> [Get role](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-role) ·
> [Delete role](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-delete-role)
These endpoints run against the **project Elasticsearch endpoint**, not the Cloud API. They require an Elasticsearch API
key or credentials with `manage_security` cluster privilege.
### Create or update a custom role
```text
PUT /_security/role/{name}
```
```bash
curl -s -X PUT \
-H "Authorization: ApiKey $ELASTICSEARCH_API_KEY" \
-H "Content-Type: application/json" \
"$ELASTICSEARCH_URL/_security/role/marketing-analyst" \
-d '{
"cluster": [],
"indices": [
{
"names": ["marketing-*"],
"privileges": ["read", "view_index_metadata"]
}
],
"applications": [
{
"application": "kibana-.kibana",
"privileges": ["feature_discover.read", "feature_dashboard.read"],
"resources": ["*"]
}
]
}'
```
**Request body fields:**
| Field | Type | Description |
| -------------- | --------------- | ---------------------------------------------------- |
| `cluster` | array\[string\] | Cluster-level privileges |
| `indices` | array\[object\] | Index privilege entries (names, privileges, DLS/FLS) |
| `applications` | array\[object\] | Kibana feature privileges |
**Naming rules:** Must start with a letter or digit. Only letters, digits, `_`, `-`, `.` are allowed.
**Limitation:** Run-as privileges are not available in Serverless.
### Get a custom role
```text
GET /_security/role/{name}
```
```bash
curl -s -H "Authorization: ApiKey $ELASTICSEARCH_API_KEY" \
"$ELASTICSEARCH_URL/_security/role/marketing-analyst"
```
### List all roles
```text
GET /_security/role
```
```bash
curl -s -H "Authorization: ApiKey $ELASTICSEARCH_API_KEY" \
"$ELASTICSEARCH_URL/_security/role"
```
### Delete a custom role
```text
DELETE /_security/role/{name}
```
```bash
curl -s -X DELETE -H "Authorization: ApiKey $ELASTICSEARCH_API_KEY" \
"$ELASTICSEARCH_URL/_security/role/marketing-analyst"
```
License (Apache-2.0)
View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/elastic/agent-skills/blob/main/LICENSE