API (v4) Creating New Project Within Group

How do I create a new project within a group using the API?

I can successfully create a project for my user:

curl --request POST --header 'Private-Token: MY_TOKEN' --header "Content-Type: application/json" --data '{"name":"my-cool-project"}' https://gitlab.com/api/v4/projects

I can read projects for my group using:

curl --request GET --header 'Private-Token: MY_TOKEN' https://gitlab.com/api/v4/groups/my-cool-group/projects

However, I can’t use a POST method to create a project within my group:

curl --request POST --header 'Private-Token: MY_TOKEN' --header "Content-Type: application/json" --data '{"name":"my-cool-project"}' https://gitlab.com/api/v4/groups/my-cool-group/projects

this results in:

{"error":"404 Not Found"}

The API docs don’t even seem to discuss creating a project within a group (though it does discuss moving it):
https://docs.gitlab.com/ee/api/groups.html

I figured it out. You need to use the projects API - and pass the group via its namespace id:

i.e.

curl --request POST --header 'Private-Token: MY_TOKEN' --header "Content-Type: application/json" --data '{"name":"my-cool-project","namespace_id":"0123456"}' https://gitlab.com/api/v4/projects

The clue here was in the docs for that parameter: “namespace_id: Namespace for the new project (defaults to the current user’s namespace)

Not sure if there’s a way to do this using the group name - but the id can always be retrieved via the API.