Access the Cloudflare API with managed authentication. Read accounts, zones, DNS records, Workers, KV, D1, R2, and analytics; manage DNS records, purge caches, and deploy Workers. All access runs through the Maton gateway and the maton CLI.
Permissions
Suggested read access
In the Console, Read limits the connection to these 351 read-only endpoints, plus deny rules for any write endpoint a broader rule would otherwise match. Endpoints Maton has found to return credentials, start jobs, or spend credits are left out; a few reads that can change state or return a secret depending on their parameters stay in, and their descriptions say how. It is a suggestion: the saved rules are exactly the ones you see, and you can change them with Custom. See Access policy.
Reference
Paths start with client/v4/, as in Cloudflare's API reference: https://api.cloudflare.com/client/v4/zones becomes /cloudflare/client/v4/zones.
Accounts and Tokens
List Accounts
maton api '/cloudflare/client/v4/accounts?per_page=20'Response:
{
"result": [
{
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"name": "Acme Corp",
"type": "standard",
"settings": {"enforce_twofactor": false, "abuse_contact_email": null},
"created_on": "2025-05-24T02:16:40.167596Z"
}
],
"result_info": {"page": 1, "per_page": 20, "total_pages": 1, "count": 1, "total_count": 1},
"success": true,
"errors": [],
"messages": []
}Most account-level paths take the account id: client/v4/accounts/{account_id}/....
Verify the Token
# User API token
maton api '/cloudflare/client/v4/user/tokens/verify'
# Account API token
maton api '/cloudflare/client/v4/accounts/{account_id}/tokens/verify'Response:
{
"result": {"id": "d44f0c90765b025558ba066abe5a3d3e", "status": "active"},
"success": true,
"errors": [],
"messages": [{"code": 10000, "message": "This API Token is valid and active", "type": null}]
}Each kind of token verifies only on its own endpoint; the other one returns 401 with code 1000 ("Invalid API Token").
Get the User
maton api '/cloudflare/client/v4/user'
maton api '/cloudflare/client/v4/memberships'User API tokens only. An account API token gets 403 code 9109 on user and 400 code 9106 on memberships.
Zones
List Zones
maton api '/cloudflare/client/v4/zones?name=example.com'Query parameters: name, status (initializing, pending, active, moved), account.id, page, per_page (5-50), order, direction.
Response:
{
"result": [
{
"id": "023e105f4ecef8ad9ca31a8372d0c353",
"name": "example.com",
"status": "active",
"paused": false,
"type": "full",
"name_servers": ["bob.ns.cloudflare.com", "lola.ns.cloudflare.com"],
"account": {"id": "01a7362d577a6c3019a474fd6f485823", "name": "Acme Corp"},
"plan": {"name": "Free Website"}
}
],
"result_info": {"page": 1, "per_page": 20, "total_pages": 1, "count": 1, "total_count": 1},
"success": true,
"errors": [],
"messages": []
}Get a Zone and Its Settings
maton api '/cloudflare/client/v4/zones/{zone_id}'
maton api '/cloudflare/client/v4/zones/{zone_id}/settings'
maton api '/cloudflare/client/v4/zones/{zone_id}/settings/ssl'PATCH client/v4/zones/{zone_id}/settings/{setting_id} with {"value": ...} changes one setting (for example ssl, always_use_https, min_tls_version, development_mode).
DNS Records
List DNS Records
maton api '/cloudflare/client/v4/zones/{zone_id}/dns_records?type=A&per_page=100'Query parameters: type, name (exact, or name.contains=, name.startswith=), content, proxied, comment, tag, page, per_page (default 100).
Response:
{
"result": [
{
"id": "372e67954025e0ba6aaa6d586b9e0b59",
"name": "www.example.com",
"type": "A",
"content": "198.51.100.4",
"proxied": true,
"ttl": 1,
"comment": null,
"tags": [],
"created_on": "2026-01-10T05:20:00.12345Z",
"modified_on": "2026-01-10T05:20:00.12345Z"
}
],
"result_info": {"page": 1, "per_page": 100, "total_pages": 1, "count": 1, "total_count": 1},
"success": true,
"errors": [],
"messages": []
}GET .../dns_records/export returns the zone as a BIND file.
Create a DNS Record
maton api '/cloudflare/client/v4/zones/{zone_id}/dns_records' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"type": "CNAME", "name": "docs", "content": "example.netlify.app", "proxied": false, "ttl": 3600, "comment": "Docs site"}
JSONBody fields: type (A, AAAA, CNAME, MX, TXT, SRV, CAA, NS, and others), name (relative or fully qualified), content, ttl (seconds, or 1 for automatic), proxied (orange cloud; A, AAAA, and CNAME only), priority (MX), comment, tags. Returns the new record in result.
Update or Delete a DNS Record
maton api '/cloudflare/client/v4/zones/{zone_id}/dns_records/{record_id}' -X PATCH -H 'Content-Type: application/json' --input - <<'JSON'
{"content": "198.51.100.7"}
JSON
maton api '/cloudflare/client/v4/zones/{zone_id}/dns_records/{record_id}' -X DELETEPATCH changes only the fields sent; PUT replaces the record. POST .../dns_records/batch applies deletes, patches, puts, and posts in one call.
Cache
Purge the Cache
maton api '/cloudflare/client/v4/zones/{zone_id}/purge_cache' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"files": ["https://www.example.com/styles.css", "https://www.example.com/app.js"]}
JSONSend one of files (URLs), tags, hosts, prefixes, or {"purge_everything": true}. Returns {"result": {"id": "{zone_id}"}}.
Workers
List Workers
maton api '/cloudflare/client/v4/accounts/{account_id}/workers/scripts'Each entry has id (the script name), created_on, modified_on, handlers, and usage_model. GET .../workers/scripts/{script_name}/settings returns bindings and compatibility settings, and .../deployments the deployment history.
Deploy a Worker
PUT client/v4/accounts/{account_id}/workers/scripts/{script_name} takes multipart/form-data: a metadata part (JSON with main_module, compatibility_date, bindings) and one part per module file. DELETE on the same path removes the Worker.
Workers KV
List Namespaces and Keys
maton api '/cloudflare/client/v4/accounts/{account_id}/storage/kv/namespaces'
maton api '/cloudflare/client/v4/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys?prefix=user:'Keys are listed with name, expiration, and metadata, up to 1,000 per page; the next page's cursor is in result_info.cursor.
Read and Write Values
maton api '/cloudflare/client/v4/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}'
maton api '/cloudflare/client/v4/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk' -X PUT -H 'Content-Type: application/json' --input - <<'JSON'
[{"key": "user:42", "value": "{\"plan\":\"pro\"}", "expiration_ttl": 86400}]
JSONA value read returns the raw stored bytes, not the JSON envelope. POST .../namespaces with {"title": "..."} creates a namespace; DELETE .../namespaces/{namespace_id} deletes it with all its keys.
D1
List Databases
maton api '/cloudflare/client/v4/accounts/{account_id}/d1/database'Query a Database
maton api '/cloudflare/client/v4/accounts/{account_id}/d1/database/{database_id}/query' -X POST -H 'Content-Type: application/json' --input - <<'JSON'
{"sql": "SELECT id, email FROM users WHERE plan = ?1 LIMIT 10", "params": ["pro"]}
JSONResponse:
{
"result": [
{
"results": [{"id": 1, "email": "alex@example.com"}],
"success": true,
"meta": {"duration": 0.21, "rows_read": 1, "rows_written": 0, "changes": 0}
}
],
"success": true,
"errors": [],
"messages": []
}Several statements separated by ; return one result entry each. The query endpoint runs any SQL, including writes, so it counts as a write endpoint.
R2 and Pages
maton api '/cloudflare/client/v4/accounts/{account_id}/r2/buckets'
maton api '/cloudflare/client/v4/accounts/{account_id}/pages/projects'
maton api '/cloudflare/client/v4/accounts/{account_id}/pages/projects/{project_name}/deployments'The Cloudflare API manages R2 buckets (create, CORS, lifecycle, custom domains), not their objects; objects use R2's S3-compatible endpoint with separate R2 credentials.
Analytics
POST client/v4/graphql is Cloudflare's GraphQL Analytics API ({"query": "...", "variables": {...}}). It needs the token's Analytics read permission; without it, the response is 200 with errors[].extensions.code authz. It isn't part of the published REST schema, so the Console's read suggestion doesn't include it.
Notes
-
Connection. The connection holds a Cloudflare API token, sent as
Authorization: Bearer. Two kinds work:- a user API token, created at My Profile → API Tokens (https://dash.cloudflare.com/profile/api-tokens), which acts as that user and can span several accounts;
- an account API token, created at Manage Account → Account API Tokens, owned by the account rather than a person.
The token's permissions and resources (accounts, zones) are chosen when it is created; calls outside them fail. The Global API key and Origin CA key aren't supported. The connection's metadata names the first account the token can reach (
account_id,account_name), read fromclient/v4/accounts. -
Account API tokens can't call user endpoints (
user,user/tokens/verify,memberships). Cloudflare doesn't yet accept them for Page Rules, Registrar, Turnstile, Super Bot Fight Mode, Zero Trust Client Platform, and Intel. -
Responses use one envelope:
success,errors(each withcodeandmessage),messages,result, and on listsresult_info. -
Pagination:
pageandper_page, with totals inresult_info(page,per_page,count,total_count,total_pages). Some newer lists (KV keys, R2) use acursorinstead. -
Errors: a missing permission is
401or403with code10000("Authentication error"); a deleted or invalid token is403code9109or400code6003; validation errors are400with specific codes (for example81057, a DNS record that already exists). Rate limit: 1,200 requests per five minutes per user, with429andRetry-Afterbeyond it. -
Read suggestion: Cloudflare publishes about 1,900 read endpoints, more than an access policy can list, so the Console's Read suggestion allows each product's reads with one wildcard rule (such as
GET client/v4/accounts/{id}/workers/**) and denies the reads that return credentials: tunnel and WARP connector tokens, Turnstile secrets, TSIG keys, Stream live input keys, Logpush and packet capture destinations, image signing keys, Zaraz configuration, origin TLS client certificates' keys, browser rendering DevTools sessions, and Access application and identity provider settings. New read endpoints Cloudflare adds under a covered product are allowed too. -
Deleting or rolling the token in Cloudflare breaks the connection; reauthorize it with a new token.