Home
Support Forums

Create / update site with a given name

I try to create a new site with a post request using: POST https://api.netlify.com/api/v1/sites
with body:

{
    "name": "whateversitename"
}

I get a new site, but with a random name.

If I try to update the site using: PATCH https://api.netlify.com/api/v1/sites/<site-id>

with body:

{
    "name": "whateversitename"
}

And I get a 200 back, but not a name change.

I even tried with body:

{
    "name": "whateversitename",
    "url": "http://whateversitename.netlify.app",
    "admin_url": "https://app.netlify.com/sites/whateversitename",
    "ssl_url": "https://whateversitename.netlify.app"
}

but nothing happens!

How can I rename a site using the API, or directly create a correctly named site?

Hey @svdoever! :wave:t2:

Try a PUT instead of a PATCH :slight_smile: should work for updating the site name.

Not sure you can specify a name on new site creation though, I think the plumbing may be made to assign a random name at the onset.

Hope that helps!


Jon