title: How do you create a project in a specific group via GitLab API?
body: <p>I tried to use GitLab API to create a new project. This worked, but this is in my user space:</p>
  <pre class="lang-sh prettyprint-override"><code>        curl \
              --header &quot;Authorization: Bearer ${GITLAB_API_TOKEN}&quot; \
              --request POST \
              &quot;https://gitlab.com/api/v4/projects/?name=$test-proj&quot;
  </code></pre>
  <p>But I wanted to do it under a specific group with group_id &lt;group_id&gt; (I blanked it here). The most sensible approach that occured to me was:</p>
  <pre class="lang-sh prettyprint-override"><code>        curl \
              --header &quot;Authorization: Bearer ${GITLAB_API_TOKEN}&quot; \
              --request POST \
              &quot;https://gitlab.com/api/v4/groups/&lt;group_id&gt;/projects/?name=test-proj
  </code></pre>
  <p>But this did not work. Are there any suggestions on how I could achieve this?</p>
  <p>I consulted the following references</p>
  <ul>
  <li><a href="https://forum.gitlab.com/t/create-a-new-project-in-a-group-using-api/1552" rel="noreferrer">https://forum.gitlab.com/t/create-a-new-project-in-a-group-using-api/1552</a></li>
  <li><a href="https://docs.gitlab.com/ee/api/projects.html#create-project" rel="noreferrer">https://docs.gitlab.com/ee/api/projects.html#create-project</a></li>
  </ul>
  <p>The GitLab documentation mentions the <code>path</code> or <code>namespace_id</code> attribute (although I would actually be in search of a <code>group_id</code> attribute). I am not sure about <code>path</code> and how to specify that. I tried - without success - to retrieve the <code>namespace_id</code> via</p>
  <pre class="lang-sh prettyprint-override"><code>curl --header &quot;PRIVATE-TOKEN: ${GITLAB_API_TOKEN}&quot; &quot;https://gitlab.example.com/api/v4/namespaces&quot;
  </code></pre>
  <p>It is well possible that I might not have the rights to do the required operation. Therefore a reference to an official (GitLab) documentation together with a test curl command that works would be very helpful to me - thank you!</p>