How to create a space with permissions?

The api docs say that during creation space permissions can be set

https://developer.atlassian.com/cloud/confluence/rest/api-group-space/#api-api-space-get

The following payload is send to the endpoint:

   key: 'PluginDev5e331e319029c30ca0bca36e4',
   name: 'PluginDev_5e331e319029c30ca0bca36e',
   permissions: [
      {
        subjects: {
          group: {
            results: [
              { type: 'group', name: 'administrators' },
              { type: 'group', name: 'confluence-users' }
            ],
            size: 2
          }
        },
        operation: { operation: 'administer', targetType: 'space' },
        anonymousAccess: false,
        unlicensedAccess: false
      },
      {
        subjects: {
          group: {
            results: [ { type: 'group', name: 'administrators' } ],
            size: 1
          }
        },
        operation: { operation: 'read', targetType: 'space' },
        anonymousAccess: false,
        unlicensedAccess: false
      }
    ]
  }

As expected I get a space object in return verifying that a space got created. And when reattempting the command I get the error that a space with the key already exists, but no matter if I supply a user or group to the permission payload no one is able to access/see the created space.

{
  id: 163480027,
  key: 'PluginDev5e331e319029c30ca0bca36e4',
  name: 'PluginDev_5e331e319029c30ca0bca36e',
  description: {
    plain: { value: '', representation: 'plain', embeddedContent: [] },
    _expandable: { view: '' }
  },
  type: 'global',
  permissions: [],
  status: 'current',
  _expandable: {
    settings: '/rest/api/space/PluginDev5e331e319029c30ca0bca36e4/settings',
    metadata: '',
    operations: '',
    lookAndFeel: '/rest/api/settings/lookandfeel?spaceKey=PluginDev5e331e319029c30ca0bca36e4',
    icon: '',
    theme: '/rest/api/space/PluginDev5e331e319029c30ca0bca36e4/theme',
    history: '',
    homepage: '/rest/api/content/163480029'
  },
  _links: {
    context: '/wiki',
    self: 'https://obital.atlassian.net/wiki/rest/api/space/PluginDev5e331e319029c30ca0bca36e4',
    collection: '/rest/api/space',
    webui: '/spaces/PluginDev5e331e319029c30ca0bca36e4',
    base: 'https://obital.atlassian.net/wiki'
  }
}

Hi @Kilian.B trying to understand what you’re doing here.

You are calling POST /wiki/rest/api/space with the payload in the first code block. The space is being created.

You run the command again? You’re running the same exact space creation command? This is where you lose me.

Is it only after running the command again you can’t access the space you created via the API?

1 Like