-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateRecord.js
More file actions
37 lines (32 loc) · 953 Bytes
/
createRecord.js
File metadata and controls
37 lines (32 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var request = require('request');
//Required
const ZONE_ID = "";
const USER_EMAIL = "";
const AUTH_KEY = "";
//DNS Data
const TYPE = ""; //valid values: A, AAAA, CNAME, HTTPS, TXT, SRV, LOC, MX, NS, CERT, DNSKEY, DS, NAPTR, SMIMEA, SSHFP, SVCB, TLSA, URI
const NAME = ""; //max length: 255
const CONTENT = "";
const TTL = 1; //Must be between 60 and 86400, or 1 for 'automatic'
const PROXIED = true; //true or false
//Code
var options = {
'method': 'POST',
'url': `https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records`,
'headers': {
'X-Auth-Email': USER_EMAIL,
'X-Auth-Key': AUTH_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"type": TYPE,
"name": NAME,
"content": CONTENT,
"ttl": TTL,
"proxied": PROXIED
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});