clx

Sign inDashboard

clx management API

Everything the clx.cx app does goes through these endpoints: connect a Cloudflare account, install the clx-edge worker into it, add sites and take their counter snippet, make short links with rules and QR codes, read reports. An agent setting clx up for a person starts at clx for AI agents.

The same contract, machine-readable: openapi.yaml · openapi.json (OpenAPI 3.1.0). This page as markdown: /api.md, or Accept: text/markdown.

Conventions

You and your API keys

GET /v1/me

The caller — user, plan, limits, current use

Sign-up, e-mail confirmation and password reset are not part of /v1: they live under /auth with the page session (docs/spec.md §9). Until email_confirmed, POST /v1/accounts answers email_unconfirmed.

Answers:

  • 200 OK — user: object, plan: one of free, api, limits: object, use: object, via: one of session, key, telegram, telegram: object | null

PATCH /v1/me

Set the user's language (page session only; also the Telegram bot's /lang)

The app after sign-in and every e-mail of clx speak it; sign-up sets it to the language of the page signed up from.

Body (JSON):

  • locale (required): one of en, ru

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Set — locale: one of en, ru

DELETE /v1/me

Delete the account (page session only, with the password)

Every connected Cloudflare account is disconnected first (clx-edge, its database and routes removed where the token still can — what could not be is listed in left, the working tokens to revoke in revoke_tokens); then the totals go at once, and the user with the keys, sites and links. Refused with balance_not_empty while money is on the balance or the partner wallet, or a payment, refund or payout is open, a referral's deposit is under 90 days old or has no commission yet, or a referral's refund is open (docs/spec.md §18); the journal is kept for accounting without the address.

Body (JSON):

  • password (required): string

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Deleted — ok: boolean, left: array of string, revoke_tokens: array of string

DELETE /v1/me/telegram

Unlink the Telegram linked to the account (page session only)

The Telegram bot (docs/spec.md §17) acts for the account it is linked to; this ends the link. A password reset ends it too.

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Unlinked — ok: boolean

GET /v1/keys

API keys (page session only)

Answers:

  • 200 OK — keys: array of Key

POST /v1/keys

Issue an API key (page session only; 1 on the free plan, 5 on api — limit_reached over it); the key is in this answer only

Body (JSON):

  • scopes (required): array of one of accounts, sites, links, reports, billing
  • allow_accounts: array of string, ^[0-9a-f]{32}$
  • allow_ips: array of string

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 201 Issued — key is shown once
  • 409 key_already_issued — a replay of the same Idempotency-Key

PATCH /v1/keys/{id}

Change an API key's allow lists in place (page session only); the key itself stays

A field left out stays as it is; null lifts the limit — every Cloudflare account of the user, those connected later too, or every IP.

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Body (JSON):

  • allow_accounts: array of string, ^[0-9a-f]{32}$ | null — At most the plan's Cloudflare accounts
  • allow_ips: array of string | null, up to 20

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 The key as it is now — Key

DELETE /v1/keys/{id}

Revoke an API key (page session only)

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Revoked

Cloudflare accounts

GET /v1/accounts

Connected Cloudflare accounts (scope accounts or sites)

Answers:

  • 200 OK — accounts: array of Account

POST /v1/accounts

Connect a Cloudflare account with a bootstrap token (scope accounts)

The bootstrap token (Account Settings — Read + Account API Tokens — Edit, which the API names Write; one day) is used within this request and deleted; it is never stored. The account then goes on to the install of clx-edge (§4) — poll GET for its state: installing, then ready once the script, its database and cron are in place (seconds; the worker's own confirmation may follow minutes later, or never — then error.warnings says not_confirmed), or connected with an error.

Body (JSON):

  • cf_account_id (required): string, ^[0-9a-f]{32}$
  • bootstrap_token (required): string

Takes an Idempotency-Key header — required with an API key.

Answers:

GET /v1/accounts/{id}

One connected account (scope accounts or sites), with its latest operation and link host

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Answers:

DELETE /v1/accounts/{id}

Disconnect (scope accounts) — delete clx-edge and its database, then the record

The answer names the working token to revoke in Cloudflare (it cannot delete itself), and in left whatever clx could not delete — the token is revoked, a right is missing, or the worker was changed outside clx — for the user to remove by hand.

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Disconnected — ok: boolean, revoke_token: string | null, left: array of string

GET /v1/accounts/{id}/zones

The account's zones (scope accounts or sites) — to pick a site's or link host's zone from

Read live from Cloudflare with the working token, sorted by name; at most 1,000, truncated past that. A host is still checked against its zone when it is added.

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Answers:

  • 200 OK — zones: array of object, truncated: boolean

POST /v1/accounts/{id}/install

Install clx-edge again (scope accounts) — after a failed install, or to reinstall

The recorded database is kept; the worker gets a new key (the previous one is accepted for a day). A clx-edge worker or database clx did not create is never touched (name_taken), nor a worker changed outside clx (resource_drift). Poll GET for the state.

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Takes an Idempotency-Key header — required with an API key.

Answers:

POST /v1/accounts/{id}/token

Renew the working token with a new bootstrap token (scope accounts)

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Body (JSON):

  • bootstrap_token (required): string

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Renewed

Sites

GET /v1/sites

Sites (scope sites); account_id narrows to one account

Parameters:

  • account_id (query): string

Answers:

  • 200 OK — sites: array of Site

POST /v1/sites

Add a site (scope sites) — the zone is found in the account, the route made, the config synced

The account must be ready. The answer carries the snippet at once; config turns synced once the worker has the site (seconds), and the counter answers from then on.

With collector_host it is an external site — one not on Cloudflare (Pro only, docs/spec.md §5): its host must be in no zone of the account (invalid_request), the route is made on collector_host, a host of the account's zones that already answers through Cloudflare (clx makes no DNS record) and is no link host. Its snippet sends a CORS request to that host, so a page whose CSP limits connect-src (or script-src, for the tag) must allow it. limit_reached (limit 0) on free; update_required while the account's clx-edge predates external sites; operation_in_progress while another operation holds the account.

Body (JSON):

  • account_id (required): string
  • host (required): string — example.com or a subdomain of a zone in that account; with collector_host, a host in none
  • collector_host: string — makes an external site: a host of a zone in that account, other than host
  • excluded_paths: array of string, ^/, up to 50

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 202 Added — site: Site

GET /v1/sites/{id}

One site (scope sites)

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Answers:

  • 200 OK — site: Site

PATCH /v1/sites/{id}

Change the excluded paths (scope sites)

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Body (JSON):

  • excluded_paths: array of string, ^/, up to 50

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Changed — site: Site

DELETE /v1/sites/{id}

Remove the site's routes (scope sites); the site stays as deleted, its totals with it

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Deleted — site: Site

POST /v1/sites/{id}/rotate

A new path, names and snippet (scope sites); the old path is counted for 30 more days

An external site keeps its path for life (invalid_request).

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 200 Rotated — site: Site

POST /v1/link-hosts

Add a link host (scope links) — one per site if wished; clx makes it a custom domain of clx-edge

{site_id} makes <label>.<site host> (a leading www. dropped) with a random label of 3 characters; {account_id, host} takes a host you name, in one of the account's zones. The account must be ready. clx makes the host a Workers Custom Domain of clx-edge: Cloudflare creates its DNS record and certificate, so you create no record. A host that already has a DNS record is never taken over: a random label is tried again with another, a named host ends conflict (dns_record_exists). Answers 202; poll GET until state is active and config is synced (usually seconds). Up to the plan's site limit per user. An external site has no zone for {site_id} (invalid_request), and a site's host or collector host cannot be a link host.

Body (JSON):

  • site_id: string — the site to make a host for; alone
  • account_id: string — with host
  • host: string — with account_id: a host of a zone in that account, such as k7q.example.com

Takes an Idempotency-Key header — required with an API key.

Answers:

POST /v1/links

Add a short link (scope links) on one of the account's link hosts

A click is a 302 to the first matching rule's URL, else url; it is counted as a view of the link, with source qr when the address carries ?q (the QR code's) — or as a bot when the client is one (curl, a script, a crawler: it is redirected all the same, by a rule with its category if there is one), in the report's bots breakdown and not among the destinations. config turns synced once the worker has the link (seconds).

Body (JSON):

  • link_host_id (required): string — the link host it lives on (POST /v1/link-hosts)
  • code: string, ^[A-Za-z0-9_-]{3,32}$ — a random 6 characters when not given
  • url (required): string (uri) — https:// only, up to 2048 characters, not on a link host of the account
  • rules: array of Rule, up to 10

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 201 Added — link: Link

Reports

GET /v1/sites/{id}/report

Totals and series of the site (scope reports); with breakdowns=1 also the top pages, sources, countries, devices, browsers, OS and bots

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$
  • period (query): one of today, 7d, 30d
  • breakdowns (query): one of 1 — read the breakdowns from the account's database (cached 5 minutes)

Answers:

Balance and Pro

GET /v1/billing

The balance, Pro and the last 50 journal rows (scope billing)

Money is integer micro-USD (1 USD = 1,000,000). Pro — the api plan — is $9 per 30 days, charged by the UTC day from the balance (docs/spec.md §18).

Answers:

POST /v1/billing/invoices

A crypto top-up (scope billing)

Whole dollars, 9 to 1,000, in one of four coins; at most 3 pending whose hour has not run out (invoice_limit). The answer has the address and the exact amount to send, fees included, for an hour; what arrives is credited, partial payments go to an operator. Needs a confirmed e-mail. payments_unavailable when the processor is not set up or did not answer. Telegram Stars are paid in the bot (/pay), not here.

Body (JSON):

  • usd (required): integer, 9–1000
  • coin (required): one of USDT_TRC20, USDT_BSC, USDT_ERC20, USDC_ERC20

Takes an Idempotency-Key header — required with an API key.

Answers:

GET /v1/billing/invoices/{id}

A top-up and its state (scope billing)

Parameters:

  • id (path, required): string, ^[A-Za-z0-9_-]{1,64}$

Answers:

POST /v1/billing/refunds

Ask for a refund of a top-up (page session only)

A credited top-up under 90 days old, one open request per top-up (refund_open). An operator makes it: at most what that top-up brought in less what was refunded from it, and never more than the balance. Crypto goes, less the network fee, to address — yours, on the network the top-up came by (Tron for USDT_TRC20, an 0x address for the others); Stars go back whole, in Telegram, with no address.

Body (JSON):

  • invoice_id (required): string
  • address: string

Takes an Idempotency-Key header — required with an API key.

Answers:

POST /v1/billing/pro

Switch Pro on or off (scope billing)

On needs a confirmed e-mail and at least $9 on the balance (insufficient_balance), and charges today; a day is charged once, however often Pro is switched. Off ends Pro after today (or at its first unpaid day, which is then not owed); the account returns to free and what is beyond its limits is paused, not deleted.

Body (JSON):

  • on (required): boolean

Takes an Idempotency-Key header — required with an API key.

Answers:

Partners

GET /v1/partner

The partner program — your code, links, referrals and wallet (scope billing)

Every user is a partner (docs/spec.md §19): 30% of each credited top-up of the people you referred, for life, one level, held 30 days. Your links: https://clx.cx/?ref=CODE and the bot's start=ref_CODE. Money is integer micro-USD; the wallet's available sum leaves out commissions still held, and a refund of a referral's top-up takes its share back (clawback), which may take the wallet below zero.

Answers:

POST /v1/partner/transfer

Move money from the partner wallet to your clx balance (page session only)

At most what is available; needs a confirmed e-mail and an Idempotency-Key (insufficient_balance when the wallet does not have it).

Body (JSON):

  • usd (required): number — dollars, at most cents

Takes an Idempotency-Key header — required with an API key.

Answers:

POST /v1/partner/payouts

Ask for a payout in USDT TRC-20 (page session only)

From $20, to a Tron address, at most what is available; its money is reserved at once and an operator sends it by hand, or refuses it and the money returns. Needs a confirmed e-mail and an Idempotency-Key.

Body (JSON):

  • usd (required): number, 20–100000 — dollars, at most cents
  • address (required): string — a USDT TRC-20 (Tron) address

Takes an Idempotency-Key header — required with an API key.

Answers:

  • 201 Asked — object

Objects

Key

  • id: string
  • prefix: string
  • scopes: array of one of accounts, sites, links, reports, billing
  • allow_accounts: array of string | null
  • allow_ips: array of string | null
  • created_at: string (date-time)
  • last_used: string (date) | null
  • paused_at: string (date-time) | null — set while the key is beyond the free plan's limits (docs/spec.md §18): it is refused until Pro is on again

Account

  • id: string
  • cf_account_id: string
  • name: string
  • state: one of pending, bootstrap_lost, connected, installing, ready, permission_error, revoked, resource_drift, no_connection — pending — the connect is running, or stopped on a passing failure (5xx other than token_rights_mismatch, token_check_failed, permission_catalog, which end it) and waits for the same request again (same Idempotency-Key); bootstrap_lost — a connect left pending for an hour, or one that died before clx stored its working token: revoke the token its error names and connect again; connected — token ready, clx-edge not installed; installing — the install runs; ready — installed and serving, go on (the worker confirms itself on its first cron: meanwhile operation shows the install at step selfcheck, for up to 15 minutes, and if no confirmation comes error.warnings says not_confirmed — nothing to wait for either way); no_connection — installed, but no push from the worker for 26 hours (sites can still be added; its next push makes it ready again)
  • token: object | null
    • name: string — clx-<operation id>
    • expires_at: string (date-time)
  • error: object | null — code and details, or warnings such as bootstrap_not_deleted
  • edge: object | null — The installed clx-edge, from its upload on (the worker's own confirmation is not needed)
    • bundle: string — sha256 of the bundle
    • up_to_date: boolean
    • schema: integer
    • installed_at: string (date-time)
  • push: object | null — The worker's own report from its last push of totals (hourly)
    • at: string (date-time)
    • bundle: string — sha256 of the bundle the worker runs
    • schema: integer | null
    • queue: integer — queue parts and final days waiting to be sent
    • error: string | null — the worker's last error
    • dropped: object — items dropped unsent, by reason: budget, invalid, unknown_target, too_old, busy, expired
  • advice: object | null — When to move this Cloudflare account to Workers Paid, from its measured use over the last 7 complete UTC days; on an account already on Workers Paid (paid), only the current size of clx-edge; recomputed daily, null until first computed
    • level: one of ok, watch, upgrade_soon, over — the worst metric: over — a limit was reached (or the database is at backpressure, 400 MB); upgrade_soon — busiest day ≥ 80% or the limit within 7 days; watch — ≥ 60% or within 30 days
    • metric: one of requests, writes, reads, size, or null
    • metrics: object — requests, writes, reads — per day for the whole account, against 100,000 / 100,000 / 5,000,000; size — clx-edge now, against 500 MB (on Workers Paid against 400 MB, where the worker stops keeping details)
    • unavailable: array of one of analytics, size — what could not be read — not guessed
    • suggest: one of shorter_hourly_retention — size alone is the problem
    • paid: one of true — the account is on Workers Paid (read from its entitlements): requests, writes and reads are not judged — no daily limit stops them — only size is, and no e-mail is sent
    • at: string (date-time)
  • operation: object | null — The latest operation on the account (GET /v1/accounts/{id} only)
    • kind: one of connect, renew, install, update, disconnect
    • state: one of running, done, failed
    • step: string
    • error: object | null
    • updated_at: string (date-time)
  • link_hosts: array of LinkHost — The account's link hosts (GET /v1/accounts/{id} only)
  • paused_at: string (date-time) | null — set while the account is beyond the free plan's limits (docs/spec.md §18): its sites and links are withdrawn from the worker, nothing new can be added
  • created_at: string (date-time)

LinkHost

  • id: string
  • account_id: string
  • site_id: string | null — the site it was made for; null for a host the user named
  • host: string — k7q.example.com — a random 3-character label under the site's host, or the named host
  • state: one of pending, active, conflict, deleted — pending — its custom domain is being made (the cron retries); active — Cloudflare made it, with its DNS record and certificate; conflict — see error
  • config: one of pending, synced — whether the worker has it yet; short links answer once active and synced
  • error: object | null
  • created_at: string (date-time)

Rule

Matches when the visitor's country is in countries (if given), their device in devices (if given) and, if bots is given, the visitor is a bot of one of those categories (by its User-Agent). At least one of the three. A rule with bots never takes a browser; a rule without it takes bots too, so put a bots rule above the others. A bots rule needs a clx-edge that knows it: on an older one the request is refused with update_required. A rule that one rule above it takes every visitor of (each of its conditions absent or holding all of this one's, both devices counting as none) would never be used: the list is refused with 409 rule_unreachable, details {field: "rules[j]", shadowed_by: i} — say DE above "search bots in DE", or any rule twice. Rules covered only by several above together are let through.

  • countries: array of string, ^[A-Z]{2}$, up to 250
  • devices: array of one of mobile, desktop
  • bots: array of one of search, ai_training, monitoring, ad_review, social_preview, headless, other — bot categories, as the bots breakdown of a report names them
  • url (required): string (uri) — https:// only, up to 2048 characters, not on a link host of the account

Site

  • id: string
  • account_id: string
  • host: string
  • kind: one of zone, external — zone — the host is in a zone of the account and the counter answers on it; external — a site not on Cloudflare (Pro), counted on collector_host (docs/spec.md §5)
  • collector_host: string | null — an external site's: the host of the account's zones its beacons go to; null for zone
  • state: one of route_pending, active, route_conflict, deleted — route_pending — the route is still to be made (the cron retries); route_conflict — another worker holds the pattern, see error
  • path: string — the per-site path the counter answers under, e.g. /lumora or /kavi/tesomu
  • snippet: object | null — Embed one of the two at build time; stable until rotate (an external site is never rotated)
    • inline: string — <script>…</script>, under 600 bytes for a zone site; an external site's also names its collector host
    • script_tag: string — <script src="/<path>/<s>.js"> with defer (the order of the attributes varies by site); an external site's src is https://<collector_host>/<path>/<s>.js
  • excluded_paths: array of string
  • config: one of pending, synced — whether the worker has this version of the site yet
  • paused_at: string (date-time) | null — set while the site is beyond the free plan's limits (docs/spec.md §18): it is not counted and cannot be changed
  • retiring: array of object — old paths still counted after a rotation
  • error: object | null
  • created_at: string (date-time)
  • views_7d: array of integer, up to 7 — views of each of the last 7 closed UTC days, oldest first (GET /v1/sites only, and only with the reports scope)
  • views_today: integer — today's views so far, as of the last hour the worker sent (GET /v1/sites only, and only with the reports scope)
  • counted: boolean — whether the counter has counted a view of this site yet (GET /v1/sites only, and only with the reports scope)

Top

the top 10 by count; "(other)" holds what went over the detail caps

array of object, up to 10 — each with key, n

Report

  • period: one of today, 7d, 30d
  • from: string (date) — first UTC day
  • to: string (date) — last UTC day — today
  • as_of: string (date-time) | null — today is counted up to this moment. A site: the end of the latest closed hour the worker sent (hours arrive up to an hour late), null before its first push. A link: the moment of the live read of the account's database
  • totals: object
    • views: integer
    • bots: integer
    • visitors: integer — the sum of daily unique visitors
  • series: array of object — today — one point per hour up to as_of; 7d/30d — one per day (with visitors)
  • incomplete: boolean — today's hours were refused over the account's write budget; daily totals stay exact
  • breakdowns: object | null — only with breakdowns=1; read from the account's own database, null when unavailable
    • pages: Top
    • sources: Top
    • countries: Top
    • devices: Top
    • browsers: Top
    • os: Top
    • bots: Top
    • flows: array of object, up to 200 — a link only: clicks by source and destination together, the top 200 by count. to is where the clicks were sent: the matched rule's conditions and URL, AT,DE;mobile>https://… (sorted; past 40 countries the first 40 and +N#<fingerprint of the whole list>), or >https://… for the main URL (the first 512 characters, also the keys of a link's pages); "" for clicks counted by a worker that did not record it yet, "(other)" for what went over the detail caps
  • unavailable: one of not_installed, cloudflare, rate_limited — why breakdowns (and a link's today) are not there: the worker is not installed or the token is gone; Cloudflare failed or took over 5 s; over 30 reads of the account databases a minute for this clx user (each cached 5 minutes)

Billing

  • balance_micro_usd: integer
  • pro: object
    • on: boolean — Pro is on — paid, or given by an operator
    • given: boolean — given by an operator: never charged
    • since: string (date) | null — the first day of the open period
    • paid_through: string (date) | null — the last day of the unbroken run of paid days
    • grace_until: string (date-time) | null — a day is unpaid: Pro works until then; still unpaid, the account returns to free
    • price_micro_usd: integer — 9,000,000 — per 30 days
    • day_micro_usd: integer — 300,000 — what a day costs
  • journal: array of object — the last 50 rows, newest first
  • invoices: array of object — the last 10 top-ups, newest first
  • refunds: array of Refund — the last 10 refund requests, newest first

Partner

  • code: string — your partner code
  • links: object
    • site: string — clx.cx with ?ref=
    • bot: string | null — the Telegram bot with start=ref_
  • rate_bp: integer — the commission, basis points (3000 = 30%)
  • hold_days: integer
  • payout_min_micro_usd: integer
  • referrals: integer — accounts made with your code
  • wallet: object
    • total_micro_usd: integer
    • available_micro_usd: integer — may be below zero after a clawback
    • held_micro_usd: integer
  • journal: array of object — the last 50 rows, newest first
  • payouts: array of object — the last 10, newest first

Refund

  • id: string
  • invoice_id: string — the top-up refunded
  • rail: one of crypto, stars
  • address: string | null — where crypto goes; null for Stars
  • status: one of requested, pending, done, declined — pending: taken from the balance, on its way
  • amount_micro_usd: integer | null — taken from the balance, once an operator made it; crypto is sent less the network fee
  • txid: string | null — the crypto transfer, once sent
  • created_at: string (date-time)
  • settled_at: string (date-time) | null

Invoice

  • id: string
  • rail: one of crypto, stars
  • usd_micro_usd: integer — the nominal; what is credited is what arrived
  • coin: string — USDT_TRC20, USDT_BSC, USDT_ERC20, USDC_ERC20; XTR for Stars
  • coin_label: string
  • stars: integer | null
  • status: one of pending, paid, expired, review, void — expired may still turn paid if crypto comes late (checked for 30 days); review waits for an operator
  • address: string | null — where to send, while pending — null when the processor gave no whole quote: use pay_url
  • amount: string | null — the exact amount of the coin to send, fees included, while pending
  • pay_url: string | null — the processor's own payment page, while pending
  • created_at: string (date-time)
  • expires_at: string (date-time)
  • paid_at: string (date-time) | null