Skip to content

Cloudflare

API

Remove

1
2
3
4
5
6
7
8
9
#!/usr/bin/env sh

# export CF_Key=....
# export CF_Email=...

curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$CF_Zone/dns_records/$1" \
     -H "X-Auth-Email: $CF_Email" \
     -H "X-Auth-Key: $CF_Key" \
     -H "Content-Type: application/json" 

List

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#!/usr/bin/env sh

# export CF_Key=....
# export CF_Email=...
# export CF_Zone=...


curl -X GET "https://api.cloudflare.com/client/v4/zones/$CF_Zone/dns_records?type=A,SRV" \
     -H "X-Auth-Email: $CF_Email" \
     -H "X-Auth-Key: $CF_Key" \
     -H "Content-Type: application/json" \
     -s | jq -r '.result[] | [.id,.name,.type,.content] |@tsv'  

Add

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/usr/bin/env sh

# export CF_Key=....
# export CF_Email=...


curl -X POST "https://api.cloudflare.com/client/v4/zones/$CF_Zone/dns_records" \
     -H "X-Auth-Email: $CF_Email" \
     -H "X-Auth-Key: $CF_Key" \
     -H "Content-Type: application/json" \
     --data "{\"type\":\"A\",\"name\":\"$1\",\"content\":\"$2\",\"ttl\":120,\"priority\":10,\"proxied\":false}"

Last update: April 12, 2020