How to acquire a Netlify site ID for a sub-domain?

How to acquire a Netlify site ID for a sub-domain?

Here is the Netlify-configured model we are following:

Here is my Netlify instancs of the model production domain.
Here is the gulp specification.
As you see, we have commented playground

I need to replace ID: 'acead270-9404-4dde-81e4-aec0e6884869' with a new Netlify ID.

Based on advice in other posts, I now know that the sub-domain is identified like this: NAME: playground-challangerdeep.netlify.app

In contrast, the model site above uses: NAME: 'playground.amp.dev'

I would like to acquire the site ID using the Netlify API with a command such as curl -H "User-Agent: jaygray0919@gmail.com" -H "Authorization: nfp_WpgBNquUgqHqvooAHm5KkVaaHbRDxDFDcedd" https://api.netlify.com/api/v1/https://challangerdeep.netlify.app/
But I’ve been unsuccessful using that method.

If the API does not support assigning a sub-domain, I’ll use an online procedure in my Netlify console.

So my question: How to acquire a site ID that will identify a sub-domain that is related to the primary domain?

There isn’t a direct way to get a site ID from a website’s hostname. However, you could list all your sites with the API, find the first one that uses that hostname, and take the ID of that site.

Is this what you’re trying to achieve?

AFAIK, to build a sub-domain instance as a Netlify instance (see model example above) I need a unique ID for the sub-domain.
But I can’t find any method to generate a sub-domain ID (as opposed to generating an ID for a separate site).

Perhaps the answer is: generate an ID for a separate site using the sub-domain name for the site name.
But that feels wrong to me and don’t want to do that unless it’s my last resort.

I am looking at list all your sites with the API but I don’t see how to link the pages configured for the sub-domain to a specific Netlify instance that hosts the GitHub workflow build.

While I’m currently using a Netlify-generated domain name, my plan is to transfer domain names to Netlify. When building a sub-domain for a target domain, the target domain must be the base domain name. Example: customerName-myNetlifyHostedDomain.com I don’t see how the reference link would allow me to accomplish that.

What am I missing here?

Can you refer me to where you see that you need a unique ID? The terms “sub-domain instance” and “Netlify instance” are not terms that we use in the documentation.

To me, it seems like you’re trying to create multiple sites. The IDs are randomly generated and can’t be manually set. There is a name for the site, which you can see in the UI and in the API, and you can set a custom domain (top-level or subdomain) for it if you also create the appropriate DNS records. Both the UI and the API support setting the custom domain of a site.

Yes, see the third bullet in the original post.
That repo is our model, meaning that our content is different but the structure and organization is the same.
The second bullet linked the Netlify-instance sub-domain, generated as part of a single build.
In the model you can see how site IDs are associated with domains and sub-domains.

The model repo shows 3 sites (including 2 sub-domains). Only one sub-domain is active at this moment.

I’ve re-read your post and believe I better understand your advice. To paraphrase:

Generate an ID for a new site (using our planned sub-domain name) and use that ID in the gulp workflow.

If I’ve finally understood the correct process, then I will proceed per your advice.

1 Like

glad to hear you got it sorted.