Support Forums

Create site with cli and custom domain

Hi, I try to deploy a manual build to a subdomain, when the corresponding commit is a tag.
I build on GitLab and deploying with the netlify-cli works if I create the site before. However I haven’t found out how to deploy to a sub-domain (just like a branch deploy would work).

Alternatively I tried to create a new site for each tag using

netlify api createSite --data '{"custom_domain" : "branchname.subdomain.mene.dev", "name": "branchname.subdomain"}'

The new site is created, but it seems the custom_domain is ignored.
I also tried updateSite but again no effect.

Any idea how to solve this?

Hi @Mene,

That’s unusual, since it’s the same thing our API does and how we do it from app.netlify.com. Can you try making the api call directly without using the cli and see if that works as expected? You can find details on https://open-api.netlify.com/#operation/createSite .

Having the same issue with Netlify cli. Using the JS API client solves the issue though https://github.com/netlify/js-client

Hi @Mene

I know this post is old, but it is still open and unresolved and I landed here with the same issue. It was resolved here.

You need to nest the custom domain and name in body:

netlify api createSite -d '{ "body": { "custom_domain": "my-site.my-domain.com", "name": "my-site.my-domain.com" } }'

I just thought I would tidy this up in case other people land here.