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.
| Surface | Base URL | Authentication |
|---|---|---|
| Cloud API v2 | https://api.cloakctl.com/api/v2/automation | Token header |
| Local API | http://127.0.0.1:48900/api | The 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:
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
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
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
- Open Settings → API.
- Click Create token, give it a name (for example
Playwright CI) and choose scopes. - Copy the secret: it is shown once.
- Store the secret in a secret manager or an environment variable.
Token scopes:
- Profile access — always "All profiles" in v1.
- Action access — read, create, edit, delete profiles, profile passwords.
- Administrative actions — tags, proxies, templates, audit log.
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.
| Plan | Tokens | RPM | RPH |
|---|---|---|---|
start | 1 | 30 | 600 |
solo (aliases: legacy) | 1 | 60 | 1200 |
team (aliases: working) | 3 | 120 | 3000 |
scale (aliases: advanced) | 5 | 240 | 6000 |
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:
| Header | Description |
|---|---|
X-Ratelimit-Limit | Requests-per-minute limit of the account plan (RPM). |
X-Ratelimit-Limit-Hour | Requests-per-hour limit of the account plan (RPH). |
X-Ratelimit-Remaining | Requests left in the current minute window, including the request that produced this response. |
X-Ratelimit-Remaining-Hour | Requests left in the current hour window. |
X-Ratelimit-Reset | Unix timestamp (UTC, seconds) when a minute-window slot frees up. |
Retry-After | Only on a 429 response: seconds to wait until the current window ends. Do not retry earlier. |
Request costs:
| Request | Cost (RPM / RPH) | Description |
|---|---|---|
| Any cloud API request, default | 1 / 1 | The cost unit is a request, not a profile. |
| Response with status 400, 409 or 422 | 6 / 1 | Validation errors and conflicts cost more so that retry storms are not free. |
| Response with status 401, 403 or 429 | 0 / 0 | A refusal returned by the server itself costs nothing. |
| DELETE /profiles and POST /profiles/trash_bin/restore | 1 / 1 | A batch of up to 100 profiles costs one request, not one hundred. |
Working with limits:
- Read
X-Ratelimit-Remainingbefore hitting a 429 and throttle proactively. - On a 429 stop all requests for
Retry-Afterseconds. Retrying earlier extends the restriction. - Do not try to bypass the limit with extra tokens: the counter is per account, and the token count does not raise RPM.
- 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 see | Likely cause | What to do |
|---|---|---|
401 unauthorized | Token missing, unknown or revoked | Check the header; create a new token if it was revoked |
403 no_permission | The token lacks the required scope | Issue a token with that scope or widen the existing one |
403 account_suspended / license_expired / license_revoked | The account is disabled or the licence is not valid | Contact the account administrator |
403 account_required | The device is not attached to an account | Reissue the token from a client attached to the account |
403 license_missing / license_not_started | The account has no licence or its period has not started | Contact the account administrator |
409 profile_exists | The profile title is taken | Choose another title or update the existing profile |
409 profile_in_use | The profile has a live lease | Stop it locally or force-stop it |
409 profile_deleted | The profile is in the trash bin | Restore it or use another record |
409 trash_expired | The 72-hour trash retention has expired | Create the profile again |
429 rate_limited | RPM or RPH exhausted | Wait for Retry-After, then retry |
503 unavailable | Server or database unavailable | Retry 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
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
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:
- Create a profile with the cloud API (
POST /profiles) or reuse an existinguuid. - Start it with the local API:
POST /api/profiles/start. - Take
ws_endpointanddebug_portfrom the response. - Connect a CDP client to
ws_endpoint. - Stop the profile at the end:
POST /api/profiles/stop(syncs) orPOST /api/profiles/force_stop(accelerated).
Things worth knowing:
ws_endpointis returned for a headed profile too, not only forheadless: true.- A fixed debugging port is not supported: a positive number in
debug_portreturns 400debug_port.not_supported. The sealed-profile guard requires the literal--remote-debugging-port=0, so a free port is always chosen. - The profile is the browser context: do not create a new context, work with
browser.contexts[0]. - A cloud
force_stopdoes not close the browser window on the operator machine. The localPOST /api/profiles/force_stopcloses the session itself, but accelerated and without a guarantee for unsynced data.
Playwright (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)
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:
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
- The secret is shown once. Store it in a secret manager; it must never appear in a repository or notes.
- One token per integration. A dedicated token per script: revoking one does not break the others.
- Least privilege. A read-only script does not need
profiles_deleteorproxies_edit. - 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.
- HTTPS only. The cloud API is served over HTTPS; do not disable certificate verification.
- The local API listens on loopback only. Port
48900is reachable from this machine only. Do not expose it through a proxy or on0.0.0.0: a token that reaches another network grants account access. - Proxy secrets.
GET /proxiescontains proxy logins and passwords. Grant this scope only to tokens that genuinely need it. - 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
- API reference — all routes, fields and codes.
- Octo compatibility — what ports and what does not.
- Changelog — versions and dates.