I can't update the ip with node

I have this code with node to update the ip and I can’t do it

const axios = require(‘axios’);

const email = ‘your-email’;
const apiKey = ‘your-api-key’;
const zoneId = ‘your-zone-id’;
const recordId = ‘your-record-id’;

async function updateDNSRecord() {
const response = await axios.get(“https://api.ipify.org?format=json”);
const json = response.data;
const url = https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records/${recordId};

try {
    const response = await axios({
        method: 'put',
        url: url,
        headers: {
            'Content-Type': 'application/json',
            'X-Auth-Email': email,
            'X-Auth-Key': apiKey,
        data: {
            type: 'A',
            name: 'subdomain',
            content: json.ip,
            ttl: 120
} catch (error) {


Can you share what error you are getting?

authentication error, I have created the token and the mail that I use for Cloudflare

1 Like

If you created an API Token, use the Authorization header, like Authorization: Bearer -token-
X-Auth-Key and X-Auth-Email are for your Global API Keys