REST API to create personal space
Asked by Robert Egan:

I would like to use the Confluence REST API to create a personal space for a user that is not me. However, the very straightforward JSON string of

```
-d '{"key":"~generic.user","name":"Generic User"}'
```

fails because of "Invalid space key". Obviously, both the tilde and the period are invalid, but I assumed that the _private option would account for that. Otherwise, why have a special URL just for personal spaces?

So, what am I doing wrong?


Answers:
author: Thiago Masutti
body: Hi [@Robert Egan](/t5/user/viewprofilepage/user-id/4276125)

You can use the legacy RPC API methods to create personal spaces.

There's addition information in this community post: <https://community.atlassian.com/t5/Confluence-questions/Confluence-administration-Create-personal-space-for-new-users/qaq-p/765650>

I hope that helps.

Kind regards,  
Thiago Masutti

comments: author: Robert Egan
body: Thanks, but I have decided to write this one off, as the scenario it addresses does not justify the effort required to achieve it.


author: Hardik Mehta
body: [@Thiago Masutti](/t5/user/viewprofilepage/user-id/1209618) I need REST API. can you please help me on it.


author: Winderson Souza
body: Hi Robert,

Per api documentation:
>
> ### Create private space {#toc-hId-1232355687}
>
> Creates a new space that is only visible to the creator. This method is the same as the [Create space](https://developer.atlassian.com/cloud/confluence/rest/api-group-space/#api-api-space-post) method with permissions set to the current user only.

I believe to achieve what you want to do, you need to create a space and set the permissions only to the user you want it to be the personal space, see the example on <https://developer.atlassian.com/cloud/confluence/rest/api-group-space/#api-api-space-post-example>.

Also note that the Key and Name parameters are how you want the space to be identified, so there can not be an auto-handling to it.

comments: author: Robert Egan
body: I have no idea how Confluence does it, but clearly they do not use their own API, because they can have tilde and periods in the space name. I have decided to write this one off, as the scenario it addresses does not justify the effort required to achieve it.


author: Hardik Mehta
body: <https://developer.atlassian.com/cloud/confluence/rest/api-group-space/#api-api-space-post-example> this link is not available.

I want to create persnal space using rest api


author: Joshua Sneed Contegix
body: Hi Robert,

I don't believe that administrators can create a personal spaces for a users. [This guide](https://confluence.atlassian.com/doc/create-your-personal-space-777010869.html) shows how a user can create one for themselves. Cheers!

comments: author: Robert Egan
body: So perhaps they should just remove that option from the REST API?

I have been tasked with testing changes to the "default personal space template". If the only personal space I can create is mine, it means I need to delete my existing personal space first. And I'd rather not do that.

In any other environment, I could create a "dummy" account, log into that account, and test it that way. But our system is "locked down" so that you cannot log into dummy accounts.

So my test plan was going to be, create the dummy account, create a personal space for it (without logging in, hence the REST API) and that navigating there by URL.


Tags: confluence-server

server