API documentation

Guide

This page is the path from creating a token to a working script: quick start, examples in curl, Python and Node.js, limits, error handling, CDP automation, security and answers to common questions.

Two API surfaces

The cloud API owns account data and lives at https://api.cloakctl.com/api/v2/automation. The local API starts profiles on a particular machine and lives at http://127.0.0.1:48900/api. An automation script usually uses both: create a profile in the cloud, start it locally, then connect to the browser over CDP.

Note

Port 48900 is deliberate: 58888, the Octo Browser port, is occupied by Octo's own local API, so our listener would never come up on a machine running Octo. The port can be changed in the client settings; it is stored in ~/.cloakctl/api-settings.json and can be overridden with CLOAKCTL_LOCAL_API_PORT (1024..65534). A busy port is never retried on another one automatically: the address must stay predictable, so the listener simply does not start and the panel keeps working.

SurfaceBase URLAuthentication
Cloud API v2https://api.cloakctl.com/api/v2/automationToken header
Local APIhttp://127.0.0.1:48900/apiThe same token header

Quick start

1. Get a token

Create a token in the CloakCTL client: Settings → API → Create token. The cc_… secret is shown once — save it immediately. Later the token list shows only its prefix and the last four characters.

Check that the token is alive:

bash
export CLOAKCTL_API_TOKEN="cc_your_token"
curl -sS "https://api.cloakctl.com/api/v2/automation/subscription" \
  -H "X-Octo-Api-Token: $CLOAKCTL_API_TOKEN"

The response starts with {"success": true, "data": {…}}; data contains plan, limits and usage.

2. Create a profile

bash
curl -sS -X POST "https://api.cloakctl.com/api/v2/automation/profiles" \
  -H "X-Octo-Api-Token: $CLOAKCTL_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"alpha","description":"Client A","fingerprint":{"os":"win","os_version":"11","os_arch":"x86"}}'

Take data.uuid from the response — an identifier like prof_35ef8623. The local API needs exactly this value.

3. Start the profile and connect

bash
curl -sS -X POST "http://127.0.0.1:48900/api/profiles/start" \
  -H "X-Octo-Api-Token: $CLOAKCTL_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"uuid":"prof_35ef8623","headless":true,"debug_port":true}'

Take ws_endpoint from the response (ws://127.0.0.1:…/devtools/browser/…) and hand it to a CDP client. Detailed examples are in the CDP automation section.

Creating a token in the client

  1. Open Settings → API.
  2. Click Create token, give it a name (for example Playwright CI) and choose scopes.
  3. Copy the secret: it is shown once.
  4. Store the secret in a secret manager or an environment variable.

Token scopes:

A token can be rotated (the old secret stops working immediately) or deleted. The number of active tokens is capped by the plan: start and solo — 1, team — 3, scale — 5.

Important

The full secret cannot be viewed again. If it is lost, rotate the token; the previous one stops working.

Limits and plans

Limits are counted per account: all tokens of the account share one counter. Windows are sliding — an event lives for 60 or 3600 seconds from the moment of the request.

PlanTokensRPMRPH
start 130600
solo (aliases: legacy)1601200
team (aliases: working)31203000
scale (aliases: advanced)52406000

An unknown plan gets the solo limits. The plan comes from the account licence; the numbers can be changed by the ORCHESTRATOR_API_PLAN_LIMITS setting without a code deploy, in which case this file and the docs are rebuilt.

Every response carries the rate-limit state headers:

HeaderDescription
X-Ratelimit-LimitRequests-per-minute limit of the account plan (RPM).
X-Ratelimit-Limit-HourRequests-per-hour limit of the account plan (RPH).
X-Ratelimit-RemainingRequests left in the current minute window, including the request that produced this response.
X-Ratelimit-Remaining-HourRequests left in the current hour window.
X-Ratelimit-ResetUnix timestamp (UTC, seconds) when a minute-window slot frees up.
Retry-AfterOnly on a 429 response: seconds to wait until the current window ends. Do not retry earlier.

Request costs:

RequestCost (RPM / RPH)Description
Any cloud API request, default1 / 1The cost unit is a request, not a profile.
Response with status 400, 409 or 4226 / 1Validation errors and conflicts cost more so that retry storms are not free.
Response with status 401, 403 or 4290 / 0A refusal returned by the server itself costs nothing.
DELETE /profiles and POST /profiles/trash_bin/restore1 / 1A batch of up to 100 profiles costs one request, not one hundred.

Working with limits:

  1. Read X-Ratelimit-Remaining before hitting a 429 and throttle proactively.
  2. On a 429 stop all requests for Retry-After seconds. Retrying earlier extends the restriction.
  3. Do not try to bypass the limit with extra tokens: the counter is per account, and the token count does not raise RPM.
  4. The limiter lives in orchestrator process memory: restarting the process resets the current window.

The complete error and code table is in the reference.

Errors and what to do

What you seeLikely causeWhat to do
401 unauthorizedToken missing, unknown or revokedCheck the header; create a new token if it was revoked
403 no_permissionThe token lacks the required scopeIssue a token with that scope or widen the existing one
403 account_suspended / license_expired / license_revokedThe account is disabled or the licence is not validContact the account administrator
403 account_requiredThe device is not attached to an accountReissue the token from a client attached to the account
403 license_missing / license_not_startedThe account has no licence or its period has not startedContact the account administrator
409 profile_existsThe profile title is takenChoose another title or update the existing profile
409 profile_in_useThe profile has a live leaseStop it locally or force-stop it
409 profile_deletedThe profile is in the trash binRestore it or use another record
409 trash_expiredThe 72-hour trash retention has expiredCreate the profile again
429 rate_limitedRPM or RPH exhaustedWait for Retry-After, then retry
503 unavailableServer or database unavailableRetry after a pause; contact support if it persists

422 bad_request means a schema error: the server repackages it into the common envelope. Branch on the code field, never on the msg text — the text may change.

Batch operations have "soft" refusals inside a successful response: DELETE /profiles always returns 200 and lists failed records in data.failed, while POST /profiles/force_stop answers 207 with failed_uuids on partial success. Always inspect those lists, not only the HTTP status.

Python example

python
import json
import os
import urllib.error
import urllib.request

BASE = "https://api.cloakctl.com/api/v2/automation"
TOKEN = os.environ["CLOAKCTL_API_TOKEN"]


def call(method, path, body=None):
    data = json.dumps(body).encode("utf-8") if body is not None else None
    request = urllib.request.Request(BASE + path, data=data, method=method)
    request.add_header("X-Octo-Api-Token", TOKEN)
    request.add_header("Content-Type", "application/json")
    try:
        with urllib.request.urlopen(request, timeout=30) as response:
            return json.load(response)
    except urllib.error.HTTPError as error:
        payload = json.load(error)
        raise SystemExit(f"HTTP {error.code} {payload['code']}: {payload['msg']}")


if __name__ == "__main__":
    subscription = call("GET", "/subscription")
    print(subscription["data"]["plan"], subscription["data"]["limits"])

Node.js example

javascript
const BASE = "https://api.cloakctl.com/api/v2/automation";
const TOKEN = process.env.CLOAKCTL_API_TOKEN;

async function main() {
  if (!TOKEN) {
    throw new Error("CLOAKCTL_API_TOKEN is not set");
  }
  const response = await fetch(`${BASE}/subscription`, {
    headers: { "X-Octo-Api-Token": TOKEN },
  });
  const payload = await response.json();
  if (!response.ok || !payload.success) {
    throw new Error(`HTTP ${response.status} ${payload.code}: ${payload.msg}`);
  }
  console.log(payload.data.plan, payload.data.limits);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

CDP automation

The sequence is the same for every framework:

  1. Create a profile with the cloud API (POST /profiles) or reuse an existing uuid.
  2. Start it with the local API: POST /api/profiles/start.
  3. Take ws_endpoint and debug_port from the response.
  4. Connect a CDP client to ws_endpoint.
  5. Stop the profile at the end: POST /api/profiles/stop (syncs) or POST /api/profiles/force_stop (accelerated).

Things worth knowing:

Playwright (Python)

python
import json
import os
import urllib.request

from playwright.sync_api import sync_playwright

LOCAL = "http://127.0.0.1:48900/api"
TOKEN = os.environ["CLOAKCTL_API_TOKEN"]
PROFILE_UUID = "prof_35ef8623"


def local(path, body):
    request = urllib.request.Request(
        LOCAL + path, data=json.dumps(body).encode("utf-8"), method="POST"
    )
    request.add_header("X-Octo-Api-Token", TOKEN)
    request.add_header("Content-Type", "application/json")
    with urllib.request.urlopen(request, timeout=180) as response:
        return json.load(response)


session = local("/profiles/start", {"uuid": PROFILE_UUID, "headless": True, "debug_port": True})
with sync_playwright() as playwright:
    browser = playwright.chromium.connect_over_cdp(session["ws_endpoint"])
    context = browser.contexts[0]
    page = context.pages[0] if context.pages else context.new_page()
    page.goto("https://example.com")
    print(page.title())
    browser.close()
local("/profiles/stop", {"uuid": PROFILE_UUID})

Puppeteer (Node.js)

javascript
const puppeteer = require("puppeteer");

// ws_endpoint comes from the POST /api/profiles/start response
const wsEndpoint = process.env.CLOAKCTL_WS_ENDPOINT;

async function main() {
  const browser = await puppeteer.connect({ browserWSEndpoint: wsEndpoint });
  const pages = await browser.pages();
  const page = pages.length > 0 ? pages[0] : await browser.newPage();
  await page.goto("https://example.com");
  console.log(await page.title());
  await browser.close();
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Selenium (Python)

Selenium does not accept a ws:// URL directly. Take debug_port from the start response and attach to the already running browser through debugger_address:

python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.debugger_address = "127.0.0.1:54739"  # debug_port from /api/profiles/start
driver = webdriver.Chrome(options=options)
driver.get("https://example.com")
print(driver.title)
driver.quit()

Note

For Selenium the Chromium driver version must match the profile kernel version. If start returned debug_port, the browser is already running — do not create a second browser instance.

Token security

  1. The secret is shown once. Store it in a secret manager; it must never appear in a repository or notes.
  2. One token per integration. A dedicated token per script: revoking one does not break the others.
  3. Least privilege. A read-only script does not need profiles_delete or proxies_edit.
  4. A token is not a password. Do not put it in URLs, do not log it, do not embed it in a client application that is distributed to users.
  5. HTTPS only. The cloud API is served over HTTPS; do not disable certificate verification.
  6. The local API listens on loopback only. Port 48900 is reachable from this machine only. Do not expose it through a proxy or on 0.0.0.0: a token that reaches another network grants account access.
  7. Proxy secrets. GET /proxies contains proxy logins and passwords. Grant this scope only to tokens that genuinely need it.
  8. Revocation. A revoked or rotated token stops working immediately; the local API caches the verdict for at most 60 seconds.

v1 limitations

The first version does not expose folders, teams and sub-accounts, proxy providers, cookie import, start pages, profile import/export/transfer, one-time profiles, cloud-side extension deletion, a fixed debugging port or mobile CDP on port 9222. The full list with explanations is in the compatibility table.

FAQ

Why is a profile id prof_… and not a 32-character hex like Octo? It is our own identifier. We do not imitate Octo's format: a script that expects hex needs one change where it stores or compares uuid.

Will my Octo script work unchanged? Partly: the X-Octo-Api-Token header, the response envelope and most routes match. Differences are listed in the compatibility table; the main ones are identifiers, the subscription shape and the local API.

My account has a single RPM limit but several tokens. What does that mean? All account tokens share one RPM/RPH counter. Splitting integrations across tokens does not increase the limit, but it simplifies revocation.

Can the local API be called from another machine or a container? No: by default it listens on 127.0.0.1:48900 and is reachable from this machine only. Do not publish it — it grants account access.

Why does starting a profile return 503 api.unavailable? The local API verifies the token on the server. Without connectivity the token cannot be verified, so the honest answer is 503. Restore connectivity and retry.

How do I stop a profile without losing data? The local POST /api/profiles/stop waits for synchronisation. force_stop is faster but does not guarantee unsynced data.

Where is the full field and response reference? In the reference: every route with parameters, body, response and error codes. Machine copies live in spec/endpoints.json and spec/limits.json.

How do I know the documentation is current? The build date is in the page footer and in version.json. Changes are listed in the changelog.

Next steps