Cloudflare API bindings.

  • ::cloudflare::zones and ::cloudflare::dns — zones and DNS records
  • ::cloudflare::cache — cache purge by URL, tag, host, prefix, or everything
  • ::cloudflare::kv — Workers KV namespaces, keys, and values
  • ::cloudflare::workers — Worker scripts (module upload) and routes
  • ::cloudflare::r2 — R2 buckets (objects go through aws-s3)
  • ::cloudflare::d1 — D1 databases and SQL queries
  • ::cloudflare::pages — Pages projects and deployments
  • ::cloudflare::turnstile — Turnstile token verification (siteverify)
  • ::cloudflare::api — auth, errors, pagination, and raw calls

Setup — context variables:

  • cloudflare.token — an API token scoped to what you touch (or the legacy cloudflare.api.key + cloudflare.email Global API Key pair)
  • cloudflare.account.id — for account-scoped APIs (KV, Workers, R2, D1, Pages)
  • cloudflare.turnstile.secret — for Turnstile verification

Any of these can also come per call, in the trailing opts Map of an API-calling function (see ::cloudflare::api).

Quick start

::zones ::cloudflare::zones
::dns ::cloudflare::dns
::cache ::cloudflare::cache

zone ::zones/find-zone("example.com")
::dns/create-dns-record(zone.id, {type: "A", name: "api", content: "203.0.113.7", proxied: true})
::cache/purge-urls(zone.id, ["https://example.com/pricing"])

Values

BASE_URL

BASE_URL: Str "https://api.cloudflare.com/client/v4"