Skip to main content

API

The REST API is served under /v1 on the platform host. It is what the web UI uses; everything the UI can do, a script can do.

Reference​

The complete, generated description is the OpenAPI document:

The API server also serves interactive documentation at /docs, outside /v1, which the chart's Ingress does not route; reach it directly:

kubectl -n idekube port-forward svc/idekube-apiserver 8080
# then open http://127.0.0.1:8080/docs

Resource groups​

PrefixResourceNeeds
/v1/authSign in, refresh, sign out, identity-provider flow, device sign-in.Nothing; signed in to confirm who one is or to authorize a device.
/v1/metaWhat each module that runs tells before anyone signs in, under its name: the site name and announcement (system), the sign-in methods (auth), volume classes (worker), prices (team), defaults of the workspace form (workspace), and the plugins that are on with what each of them tells.Nothing.
/v1/users/meThe caller's profile and permissions, avatar, two-step verification, linked providers, sessions, API tokens, SSH keys and environment variables.Signed in.
/v1/usersAccounts: create, change, disable, delete, sign out, reset a second factor.user:read, user:write.
/v1/roles, /v1/permissionsRoles and the permissions they bundle.role:read, role:write; signed in to list the roles.
/v1/teamsTeams, their members, quotas, credit and ledger.Signed in for one's own; team:read, team:create, team:manage; billing:read, billing:credit for credit.
/v1/templates, /v1/template-languageTemplates, their revisions and the language they are written in.Signed in for one's own and shared ones; template:author to write, template:review to approve or reject, template:read, template:manage for other teams'.
/v1/workersWorkers: enroll, configure, cordon, rotate the token, remove. /v1/workers/connect is the agents' WebSocket.worker:read, worker:manage; the worker's token for connect.
/v1/workers/locationsThe workers a new workspace or volume may be placed on.Signed in.
/v1/workspacesWorkspaces: create, update, start, stop, delete, open, set the volumes they mount, variables, and tokens for their sidecars.Signed in; workspace:maintain to start, stop or delete other teams' workspaces; workspace:manage for full cross-team access.
/v1/clustersClusters of workspaces: create, change (their size too), start, stop, delete; their variables and network rules.Signed in; workspace:maintain to start, stop or delete other teams' clusters; workspace:manage for full cross-team access.
/v1/volumesVolumes.Signed in; storage:maintain to archive, restore or delete other teams' volumes; storage:manage for full cross-team access.
/v1/notifications, /v1/announcementsOne's notifications and preferences; announcements.Signed in; notification:send to announce.
/v1/network/workersHow each worker's network is checked.settings:read, settings:write.
/v1/auditThe audit log.audit:read.
/v1/settingsRuntime settings.settings:read, settings:write.
/v1/pluginsThe plugins of the release; turn one on or off.settings:read, settings:write.
/v1/systemVersion, replica.settings:read.
/v1/jobs, /v1/job-kindsBackground jobs and their schedules.job:read; retrying, cancelling, running and rescheduling need job:manage.
/v1/mcpThe Model Context Protocol server, for AI agents.Signed in; on unless the mcp settings turn it off.

Authentication​

For scripts, create an API token on your profile (Developer tab) and send it as a bearer token:

BASE=https://idekube.example.org
curl -sS "$BASE/v1/workspaces" -H "Authorization: Bearer $IDEKUBE_TOKEN"

An API token starts with idk_ and lasts until it expires or is deleted. POST /v1/users/me/tokens makes one, from a session that confirmed who it is; its scopes are those of API tokens and permissions the caller holds, and none, the default, is full access. A request beyond them is refused with 403 and insufficient_scope. GET /v1/users/me returns the token's token_scopes.

A command-line client signs in without handling a password through the device authorization flow (RFC 8628), as idk login does:

  1. POST /v1/auth/device with {"name": "…"}, the name of the token to make, and optionally scopes and expires_in_days, returns a device_code, a user_code of eight characters such as ABCD-EFGH, and verification_uri_complete, the platform's /device?code=… page. Both codes last expires_in seconds, 600.
  2. The person opens that page, signed in, and authorizes it after confirming who they are, or denies it.
  3. Meanwhile the client calls POST /v1/auth/device/token with {"device_code": "…"} every interval seconds, 3. It answers 400 and authorization_pending until then, the new token once it is authorized, 403 and device_denied if it was denied, and 400 and device_code_invalid once the code expired or was used.

Interactive clients sign in directly instead:

curl -sS "$BASE/v1/auth/login" -H 'Content-Type: application/json' \
-d '{"username": "alice", "password": "..."}'

The response is {"tokens": {...}, "mfa": null}, where tokens holds access_token, refresh_token, token_type (bearer) and expires_in, the lifetime of the access token in seconds. For an account with two-step verification it is {"tokens": null, "mfa": {"ticket": "...", "methods": ["totp", "webauthn", "recovery"]}}; complete it with POST /v1/auth/mfa/verify and {"ticket", "method", "code"}.

  • POST /v1/auth/refresh with {"refresh_token": "..."} returns a new pair. Store the new refresh token: the old one stops working a minute later. Asking again with the old one within that minute, for example after losing the answer, returns the same new refresh token.
  • POST /v1/auth/logout with the refresh token ends its session.

Errors​

Errors are JSON objects with a stable, machine-readable code and a human-readable message:

{"code": "quota_exceeded.memory_mb", "message": "memory_mb quota exceeded: 4096 used + 16384 requested > 16384"}
StatusCodesMeaning
400captcha_required, captcha_invalid, or a specific code such as volume_shrink, workspace_domain_unset, authorization_pendingThe request cannot be carried out as stated.
401unauthorized, invalid_credentials, invalid_token, account_inactiveMissing, wrong or expired credentials.
402insufficient_credit, storage_frozenThe team has no credit for it.
403forbidden, insufficient_scope, reauth_required, wrong_password, mcp_disabled, device_deniedThe caller or its token may not do it, has not confirmed who it is, or the feature is turned off.
404not_found, template_unavailableThe resource does not exist, or the caller may not see it.
409name_taken, username_taken, volume_attached, mount_path_taken, workspace_managed, volume_managed, worker_full, worker_cordonedThe resource already exists, is still referenced, is part of something changed only as a whole, or is in the wrong state.
422quota_exceeded.<dimension>, invalid, worker_unoffered, volumes_apart, volume_elsewhereA quota would be exceeded, a value is invalid, or what is asked cannot be placed.
429too_many_requests, too_many_attemptsOver a rate or guessing limit; Retry-After says how many seconds to wait.
500internal_errorA fault of the platform. It is logged with the request's ID; the message says no more.
502worker_unreachable, worker_error, worker_outdatedA worker's agent is away, refused, or is of a release that does not know what was asked.
503unavailable, captcha_unavailableThe database is busy, or a Turnstile challenge cannot be checked right now. Try again.
504timeoutThe operation took too long.

A request whose body or parameters do not match the schema is answered with 422 and the code invalid. details lists every problem found, each at its location, for a form to show by its field:

{"code": "invalid", "message": "body.name: expected length >= 1", "details": [
{"location": "body.name", "message": "expected length >= 1"},
{"location": "body.cpu_m", "message": "expected number >= 100"}
]}

Pagination​

List endpoints take limit (1 to 500, default 50) and offset (default 0) and return a page:

{"items": [], "total": 0}

total is the number of matches before paging. Most lists also take q for a text search; workspaces, clusters and volumes take all=true to include other teams' resources, which is honoured with the corresponding :read, :maintain or :manage permission.

Batch operations​

POST /v1/workspaces/batch (start, stop, delete) and POST /v1/users/batch (enable, disable, delete) take up to 500 ids. Each item succeeds or fails on its own:

{"succeeded": ["k3v9x0a2bq"], "failed": {"p0o9i8u7y6": {"code": "not_found", "message": "workspace not found"}}}

Asynchronous results​

Creating, starting, stopping or deleting a workspace or volume returns as soon as the request is recorded. The cluster follows. Poll the resource and read phase to see the outcome; see Workspaces. While the platform cannot get there, status_code says why, as one of the codes above, and status_message in words; it keeps trying, ever less often, until it can. After a success, status_code is empty and status_message holds what the worker said of the resource, if anything.

Clients​

The idk command line and the MCP server for AI agents act through this API. Both are built on the Go package github.com/idekube-project/idekube-platform/backend/client, which other Go programs may import as well.