R2 DNS record

I haven’t found in documentation a way to create a record for R2 by an API, is this provided by Cloudflare ?

Try this:

curl -vX POST "https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/r2/buckets/BUCKET_NAME/custom_domains" \
     -H "X-Auth-Email: YOUR_EMAIL" \
     -H "X-Auth-Key: API_KEY" \
     --data '{"domain":"subdomain.example.com","zoneId":"ZONE_ID","zoneName":"example.com"}'

I think there’s one more step, which is to allow access on that hostname, but I’ve not looked into that yet.

UPDATE: It looks like the Allow part is dashboard-only. As none of this is not documented in the API, this is probably as close as you’re going to get for now.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.