Cloudflare API Tokens

Generate a Cloudflare Token for DNS edits. I recommend 1 token per function/service so that the impact of one token/service will not affect another.

You also may need to know/record your account ID/Zone ID. information on that can be found here - Cloudflare.

Information to Collect

Name Source Example Collected/Decided Value
$Domain Hosted at Cloudflare acme.com
$DomainNameARec webapp1
$CloudflareAuthorizationAPIToken Create here 4VeN19XUo81a7XXXXXXXXXXXXXXXUOO1fj
$CloudflareZoneID curl "https://api.cloudflare.com/client/v4/zones" -H "Authorization: Bearer $CloudflareAuthorizationAPIToken " \| jq -r '.result.[0].id' 684f1d0fXXXXXXXXXXXXXXXXXXXX8fc

Web UI

  1. login to Cloudflare Dashboard
  2. Configure the token with a name, set the permissions to DNS Zone Edit. Specify the specific domain you wish to grant permisisons to
  3. Click Continue to Summary -> Create Token
  4. Be sure to copy the token and save it in your password manager. Once this page is closed, this API token cannot be recovered.


    Cloudflare API Tokens

CLI

curl https://api.cloudflare.com/client/v4/zones/$CloudflareZoneID/dns_records \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CloudflareAuthorizationAPIToken" \
    -d '{
          "name": "$DomainNameARec",
          "ttl": 3600,
          "type": "A",
          "comment": "script put",
          "content": "1.1.1.1",
          "proxied": false
        }'
Scroll to Top