Templates · Infrastructure
Cloudflare API collection template
Zones, DNS records and cache purges with the Cloudflare API v4.
What's inside
Verify a token, list zones, read and create DNS records and purge the cache of a zone with the Cloudflare API.
5 requests in 2 folders · Base URL https://api.cloudflare.com/client/v4 · Bearer token
Set it up
- Open Cloudflare API in Requestarium (or in the app: Import, Start from a template) and import it. You get the collection and a "Cloudflare API" environment.
- Create an API token at dash.cloudflare.com/profile/api-tokens (the "Edit zone DNS" template covers DNS; add Cache Purge to purge).
- Fill in the environment, pick it in the environment menu and send the first request.
Environment variables
| Variable | What it is |
|---|---|
cloudflareApiTokensecret | API token. |
zoneId | Filled by "List zones" (the first zone); or copy it from the zone Overview. |
domain | The zone's domain, for new records. |
Requests
Account
- GETVerify the token
/user/tokens/verifyWhether the token is active.
- GETList zones
/zonesYour zones; saves the first as zoneId.
DNS and cache
- GETList DNS records
/zones/{{zoneId}}/dns_recordsEvery record in the zone.
- POSTCreate a DNS record
/zones/{{zoneId}}/dns_recordsAn A record (ttl 1 means automatic).
- POSTPurge everything
/zones/{{zoneId}}/purge_cacheClears the whole cache of the zone.