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

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;

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.


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: