Unable to create domain Record "API Error: Name can not be just a TLD"

Posted March 17, 2020 686 views
DigitalOcean API and CLI (doctl)

I want to create sub-domains using NodeJS. I used the following Node.JS script but while I ran it I got the above error.

const express = require("express");
const router = express.Router();

var DigitalOceanAPI = require('doapi');
var api = new DigitalOceanAPI({token: 'my_token'});"/register", function (req, res, next)
  var name =;
  var type = req.body.type;
  var data =;
  var domain_name = req.body.domain_name;

    return res.status(400).send("name is empty");

    return res.status(400).send("type is empty");

    return res.status(400).send("data is empty");

    api.domainRecordNew(domain_name, {
        type : req.body.type, 
        name :,
        data :,
        }).then(function (droplets)


module.exports = router;

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


It sounds like that you are not using the correct endpoint.

You have to use this endpoint:

And you have to pass the following information:

  "type": "A",
  "name": "subdomain",
  "data": "",
  "priority": null,
  "port": null,
  "ttl": 1800,
  "weight": null,
  "flags": null,
  "tag": null

For more information you can take a look at the official documentation on how to create a new DNS record here: