Adding Custom Domain With API

Hello,
I am trying to add a custom domain using render API.
There are two things I’m not sure of.

  1. What my serviced is - I assumed its in the URL, something like this - srv-ceerma33rgb3r0ohtdu5
  2. Can I test this on localhost or must it be from my domain?

from this docs - Add custom domain this is what the code looks like using vanilla javascript.
Any help would be much appreciated.

const options = {
  method: 'POST',
  headers: {accept: 'application/json', 'content-type': 'application/json'},
  body: JSON.stringify({name: 'themedulla.com'})
};

fetch('https://api.render.com/v1/services/srv-ceerma14reb3r0ohuqu0/custom-domains', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Hey Zino,

That’s precisely correct for service ID, the easiest place to see it is in the dashboard when viewing a service - it will always begin with srv- like you have there.

Regarding whether you can use the API call from localhost, that doesn’t matter, it’s a POST request to our API so if you’ve got the correct details then it will work.

I hope that’s useful

Regards,

John B

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.