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

  1. 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.
  2. Create an API token at dash.cloudflare.com/profile/api-tokens (the "Edit zone DNS" template covers DNS; add Cache Purge to purge).
  3. Fill in the environment, pick it in the environment menu and send the first request.

Environment variables

VariableWhat it is
cloudflareApiTokensecretAPI token.
zoneIdFilled by "List zones" (the first zone); or copy it from the zone Overview.
domainThe zone's domain, for new records.

Requests

Account

  • GET
    Verify the token /user/tokens/verify

    Whether the token is active.

  • GET
    List zones /zones

    Your zones; saves the first as zoneId.

DNS and cache

  • GET
    List DNS records /zones/{{zoneId}}/dns_records

    Every record in the zone.

  • POST
    Create a DNS record /zones/{{zoneId}}/dns_records

    An A record (ttl 1 means automatic).

  • POST
    Purge everything /zones/{{zoneId}}/purge_cache

    Clears the whole cache of the zone.