Using the CloudFlare API with NodeJS and superagent


I am trying to understand how the request for the Cloudflare NPM package should be configured so that I can add a record to the DNS Zone: GitHub - cloudflare/node-cloudflare: Node.js API for Client API

Maybe I am a bit sleepy now but here is what I am trying after settign up the correct email and Global API key:

Here is what I am trying:

cf.zones.add(zoneID, ‘{“type”: “A”, “name”: “”, “content”: “”, “ttl”: 120, “proxied”: false }’).then(function (resp) {
return resp.result.status;

And the result:

(node:3208) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Cloudflare: Unknown arguments (ZONE_ID_HIDDEN_FROM_COMMUNITY,{“type”: “A”, “name”: “”,
“content”: “”, “ttl”: 120, “proxied”: false }). Did you mean to pass an options object? (on API request to POST zones/)

Note: I am testing the API from a local machine.
Note2: The requests for the work without any issues, just can’t seem to understand how this one works.

Thank you.


You should use cf.dnsRecord(zoneId, {“type”: “A”, “name”: “”, “content”: “”, “ttl”: 120, “proxied”: false });

please note that the record shouldn’t be a string but a JSON object

Sorry not dnsRecord but dnsRecords

1 Like