Repository navigation
Description
Summary
Add the Elastic Cloud Connect API to the Elastic CLI so users can accept Cloud Connect terms, list/create/update/disconnect Cloud Connected clusters, and rotate Cloud Connect API keys from elastic cloud.
This is not AutoOps insights (#393). Insights consume events for a resource that is already monitored. Cloud Connect is how a self-managed, ECE, or ECK cluster is registered with Elastic Cloud so those services (AutoOps, and later others) can run.
Spec (source of truth)
Elastic Cloud Connected API, OpenAPI 3.0.1 (info.version 0.1.0).
- Docs: https://www.elastic.co/docs/api/cloud-connect
- OpenAPI: https://www.elastic.co/docs/api/cloud-connect.yaml
- Host:
https://api.elastic-cloud.com - Auth: Elastic Cloud API key already in the CLI Cloud context. Header
Authorization: ApiKey <key>— notBearer/ JWT. Same context aselastic cloud orgs/elastic cloud auth. - Product guide: Connect your ECE, ECK, or self-managed cluster to AutoOps
Paths are under /api/v1/cloud-connected/…. Cluster IDs are 32 hex (^[a-z0-9]{32}$). Organization IDs match ^[a-z0-9]{1,32}$ — discover with existing elastic cloud orgs list-organizations; do not invent an org-wide _all.
Already shipped — do not reimplement
| Need | Existing command |
|---|---|
Discover organization_id |
elastic cloud orgs list-organizations |
Org-scoped Cloud Connect registration key (cloud-connected-admin / cloud_connected_resource) |
elastic cloud auth create-api-key / get-api-keys |
| Elasticsearch AutoOps key on the self-managed cluster | elastic es security create-api-key / put-role |
The org registration key body (already accepted by POST /api/v1/users/auth/keys) looks like:
{
"description": "CCM Registration Key",
"role_assignments": {
"cloud_connected_resource": [
{
"organization_id": "<org_id>",
"role_id": "cloud-connected-admin",
"all": true
}
]
}
}That secret is what agents send as ELASTIC_CLOUD_CONNECTED_MODE_API_KEY. Elastic Agent 9.4.9+ / 9.5.6+ no longer uses AUTOOPS_TOKEN or AUTOOPS_TEMP_RESOURCE_ID. Do not add CLI flags for those.
Endpoints to cover
Organizations
| HTTP | Purpose |
|---|---|
GET /api/v1/cloud-connected/organizations/{organization_id}/terms-and-conditions |
Whether T&C are accepted (accepted.accepted_at / accepted_by only when accepted) |
POST /api/v1/cloud-connected/organizations/{organization_id}/terms-and-conditions/_accept |
Accept T&C (first-time connect) |
GET /api/v1/cloud-connected/organizations/{organization_id}/subscription |
Subscription state: trial | active | inactive |
Clusters
| HTTP | Purpose |
|---|---|
GET /api/v1/cloud-connected/clusters |
List. Response is { items: Cluster[] }. Schema says “paginated” but there is no cursor / next field — do not invent pagination flags. |
POST /api/v1/cloud-connected/clusters?create_api_key= |
Create / onboard. 200 if the cluster already existed, 201 if created. Query create_api_key=true returns a cloud-connected-admin key scoped to that cluster; revoked on disconnect. Required body: self_managed_cluster.{id,name,version} and license.{type,uid}. Optional name (max 255). |
GET /api/v1/cloud-connected/clusters/{id} |
Get one. Capture ETag for PATCH / DELETE / rotate. |
PATCH /api/v1/cloud-connected/clusters/{id} |
Partial update (name, self_managed_cluster, license, services.{auto_ops,eis}.enabled). Optional If-Match. |
DELETE /api/v1/cloud-connected/clusters/{id} |
Disconnect. Optional If-Match. Response is “disconnection scheduled”. Product behavior: this permanently deletes AutoOps metrics for that cluster — CLI should confirm on TTY and print that warning. |
License type enum: trial | basic | standard | dev | silver | gold | platinum | enterprise.
Cluster always includes id, name, metadata.{created_at,created_by,organization_id}, self_managed_cluster, license, services.{auto_ops,eis}. Surface those. Do not invent other service keys.
API key rotation
| HTTP | Purpose |
|---|---|
POST /api/v1/cloud-connected/clusters/{id}/apikey/_rotate |
Rotate the cluster management key. Returns { key }. Previous key revoked after 7 days or via _revoke-pending. |
POST /api/v1/cloud-connected/clusters/{id}/apikey/_revoke-pending |
Revoke pending rotated cluster keys immediately. |
POST /api/v1/cloud-connected/clusters/{id}/apikey/{service}/_rotate |
Rotate a service key. Path service enum is currently eis only (OpenAPI ServiceName). |
POST /api/v1/cloud-connected/clusters/{id}/apikey/{service}/_revoke-pending |
Revoke pending rotated service keys immediately. |
Print returned keys once. Do not log them. Optional If-Match on all four.
Errors
Bodies are { errors: [ { message, code } ] } (MultiErrorResponse). Statuses used by the spec: 400, 401, 403, 404, 409, 412, 422. Map 412 to a clear “ETag mismatch — GET again” message.
UX / command structure
Promote a connected group under elastic cloud (same idea as auth / orgs: not hosted-vs-serverless). Suggested contract:
elastic cloud connected organizations get-terms --organization-id <id>
elastic cloud connected organizations accept-terms --organization-id <id>
elastic cloud connected organizations get-subscription --organization-id <id>
elastic cloud connected clusters list
elastic cloud connected clusters create [--create-api-key] [--input-file <json>]
elastic cloud connected clusters get --id <id>
elastic cloud connected clusters update --id <id> [--if-match <etag>] [--input-file <json>]
elastic cloud connected clusters delete --id <id> [--if-match <etag>]
elastic cloud connected clusters rotate-api-key --id <id> [--if-match <etag>]
elastic cloud connected clusters revoke-pending-api-keys --id <id> [--if-match <etag>]
elastic cloud connected clusters rotate-service-api-key --id <id> --service eis [--if-match <etag>]
elastic cloud connected clusters revoke-pending-service-api-keys --id <id> --service eis [--if-match <etag>]
Codegen from the OpenAPI is fine; rename via the existing Cloud namespace maps so the user-facing tree matches the above. If the CLI can default --organization-id from the Cloud context when the user belongs to a single org, do that — still allow an explicit flag.
Flags should follow the request 1:1 (--create-api-key, --if-match, --input-file for create/update bodies).
Out of scope
- Agent install (Linux script, Docker, Helm, Kubernetes, ECK)
- Elasticsearch API keys / roles (already
elastic es security) - Org Cloud API keys (already
elastic cloud auth) - Insights search/get (#393 —
elastic cloud monitoring) - FedRAMP Cloud offerings (Cloud Connect is not available there)
Why this is needed
Without these commands, connecting a self-managed cluster requires raw HTTP against /api/v1/cloud-connected/…. Terms acceptance, cluster list/disconnect, and key rotation have no CLI equivalent today. Agent install and ES/Cloud key minting already exist elsewhere; this fills the Cloud Connect control-plane gap.
An upcoming monitor-cluster skill will walk users through that connect flow (terms, keys, agent install, verify) and will call these elastic cloud connected commands instead of the HTTP API. Same dependency pattern as the insights skill on #393.
cc @JoshMock
Activity
elastic cloud connected) #818 as a duplicate of this issueJoshMock commentedon Nov 13, 2026
@consulthys are these APIs not defined in the Cloud OpenAPI spec file for a reason? that's the source of truth that all Cloud control plane APIs are generated from.
Upstreaming those specs there would make these APIs show up automatically next time
@elastic/schemasis generated and released.If it's not possible, we'll have to modify the code generator to fold in these specs when it runs. More work on our part, and easier to fall behind if there isn't a public, downloadable OAS file we can work from, but it can be done if there's no way around it.
consulthys commentedon Nov 13, 2026
@JoshMock they are defined at https://www.elastic.co/docs/api/doc/cloud-connect and the API spec is available at https://www.elastic.co/docs/api/doc/cloud-connect.json
Same for the new Elastic Cloud Monitoring API (will be available at https://www.elastic.co/docs/api/doc/cloud-monitoring and https://www.elastic.co/docs/api/doc/cloud-monitoring.json) that will be needed for #393
There's no specific reason why they didn't fold into https://www.elastic.co/docs/api/doc/cloud.json aside from the fact that both are related to monitoring more than management and handled by very different teams
JoshMock commentedon Nov 13, 2026
Noted! Any other OAS JSON files you know of (related or unrelated to these) that might also be missing? 😆
consulthys commentedon Nov 13, 2026
Billing:
Elastic Cloud Serverless:
consulthys commentedon Nov 24, 2026
Canonical docs URL (same API;
/doc/dropped from the path): https://www.elastic.co/docs/api/cloud-connect — OpenAPI https://www.elastic.co/docs/api/cloud-connect.yaml. Spec header updated.