Netlify API for adding DNS record

I’m using the js library, but the documentation gives no indication on how to add a DNS record using configureDNSForSite

According to GitHub:

Every open-api method has the following signature:

#### `promise(response) = client.operationId([params], [opts])`

However within the API I can see things like DNS Zones, and DNS Records. Does configureDNSForSite expect a zone or a record? There are ID fields, do I put an ID I’d like there or is that automatically generated if sent as null. Running this example gives me nothing on result.records where the DNS entries for a site are located meaning it failed. I’m also perplexed as to why an API call that fails returns with an object instead of a failure message.


  const result = await client.configureDNSForSite({ site_id: siteid }, {
    id: 'foobarfoobarfoobar',
    hostname: '',
    type: 'A',
    value: '',
    ttl: 300,
    priority: 0
  console.log(result) // gives me the generic object
  console.log(result.records) // is `undefined`

But where do I put the actual data for the DNS record I want to create under that site id? I have hundreds of records to create and I don’t really fancy doing those by hand.

I’d suggest the workflow mentioned in this article:

This will allow you to see what a valid payload for a DNS record creation looks like (by setting one up in the UI and snooping on what is sent), and you can adapt from there :slight_smile:

I Confirm this is a bug with configureDNSForSite() in the JS API

By the way, the netlify ui doesn’t use the same API for this. It uses an undocumented POST /dns_zones/{slug_ie_site_com}/dns_records which throws the following error when used: undefined method `end_with?’ for nil:NilClass

Edit: the endpoint POST /dns_zones/{slug_ie_site_com}/dns_records actually works using access token. It’s just not documented yet.

Would you mind filing a bug about your discovery here?

And yes, the latter was what I was suggesting you try :slight_smile:

The following issue might be related to this problem, although this is not completely clear at the moment yet:

After some debugging, this problem does not seem related to our js-client but a potential bug in our API: