# Source: https://gitbook.com/docs/developers/gitbook-api/api-reference/spaces/space-users.md

# Space users

Give your collaborators the right level of access for specific spaces. This endpoint makes it simple to add, remove, or update space members individually.

## POST /spaces/{spaceId}/permissions

> Invite a user or a team to a space

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"space-users","description":"Give your collaborators the right level of access for specific spaces. This endpoint makes it simple to add, remove, or update space members individually.\n"},{"name":"space-teams","description":"Assign entire teams to your spaces and streamline the process of granting or revoking access at scale, without dealing with individual user roles.\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"spaceId":{"name":"spaceId","in":"path","required":true,"description":"The unique id of the space","schema":{"type":"string"}}},"responses":{"NotFoundError":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[404]},"message":{"type":"string"}},"required":["code","message"]}}}}}}},"schemas":{"InviteUsersAndTeams":{"type":"object","properties":{"role":{"description":"Role to set.","$ref":"#/components/schemas/MemberRoleOrGuest"}},"anyOf":[{"type":"object","properties":{"teams":{"type":"array","minItems":1,"items":{"type":"string","description":"The ID of the team to be invited"}}},"required":["teams"]},{"type":"object","properties":{"users":{"type":"array","minItems":1,"items":{"type":"string","description":"The ID of the user to be invited"}}},"required":["users"]}],"required":["role"]},"MemberRoleOrGuest":{"description":"The role of a member in an organization, null for guests","oneOf":[{"$ref":"#/components/schemas/MemberRole"},{"type":"string","nullable":true,"enum":[null]}]},"MemberRole":{"type":"string","description":"\"The role of a member in an organization.\n\"admin\": Can administrate the content: create, delete spaces, ...\n\"create\": Can create content.\n\"review\": Can review content.\n\"edit\": Can edit the content (live or change requests).\n\"comment\": Can access the content and its discussions.\n\"read\": Can access the content, but cannot update it in any way.\n","enum":["admin","create","edit","review","comment","read"]}}},"paths":{"/spaces/{spaceId}/permissions":{"post":{"operationId":"inviteToSpace","summary":"Invite a user or a team to a space","tags":["space-users","space-teams"],"parameters":[{"$ref":"#/components/parameters/spaceId"}],"responses":{"204":{"description":"OK"},"404":{"description":"No team or user with the provided Id","$ref":"#/components/responses/NotFoundError"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteUsersAndTeams"}}}}}}}}
```

## GET /spaces/{spaceId}/permissions/users

> List space user permissions

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"space-users","description":"Give your collaborators the right level of access for specific spaces. This endpoint makes it simple to add, remove, or update space members individually.\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"spaceId":{"name":"spaceId","in":"path","required":true,"description":"The unique id of the space","schema":{"type":"string"}},"listPage":{"name":"page","in":"query","description":"Identifier of the page results to fetch.","schema":{"type":"string"}},"listLimit":{"name":"limit","in":"query","description":"The number of results per page","schema":{"type":"number","minimum":0,"maximum":1000}}},"schemas":{"List":{"type":"object","properties":{"next":{"type":"object","properties":{"page":{"type":"string","description":"Unique identifier to query the next results page"}},"required":["page"]},"count":{"type":"number","description":"Total count of objects in the list"}}},"UserContentPermission":{"type":"object","description":"Permission of a user in a content.","properties":{"permission":{"$ref":"#/components/schemas/MemberRole"},"user":{"$ref":"#/components/schemas/User"}},"required":["permission","user"]},"MemberRole":{"type":"string","description":"\"The role of a member in an organization.\n\"admin\": Can administrate the content: create, delete spaces, ...\n\"create\": Can create content.\n\"review\": Can review content.\n\"edit\": Can edit the content (live or change requests).\n\"comment\": Can access the content and its discussions.\n\"read\": Can access the content, but cannot update it in any way.\n","enum":["admin","create","edit","review","comment","read"]},"User":{"type":"object","properties":{"object":{"type":"string","description":"Type of Object, always equals to \"user\"","enum":["user"]},"id":{"type":"string","description":"Unique identifier for the user"},"displayName":{"type":"string","description":"Full name for the user"},"email":{"type":"string","description":"Email address of the user"},"photoURL":{"type":"string","description":"URL of the user's profile picture"},"urls":{"type":"object","description":"URLs associated with the object","properties":{"location":{"type":"string","description":"URL of the user in the API","format":"uri"}},"required":["location"]}},"required":["object","id","displayName","urls"]}},"responses":{"NotFoundError":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[404]},"message":{"type":"string"}},"required":["code","message"]}}}}}}}},"paths":{"/spaces/{spaceId}/permissions/users":{"get":{"operationId":"listUserPermissionsInSpace","summary":"List space user permissions","tags":["space-users"],"parameters":[{"$ref":"#/components/parameters/spaceId"},{"$ref":"#/components/parameters/listPage"},{"$ref":"#/components/parameters/listLimit"}],"responses":{"200":{"description":"Listing of users who have been added to a space.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/List"},{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/UserContentPermission"}}}}]}}}},"404":{"description":"No space was found with the given Id","$ref":"#/components/responses/NotFoundError"}}}}}}
```

## DELETE /spaces/{spaceId}/permissions/users/{userId}

> Remove a space user

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"space-users","description":"Give your collaborators the right level of access for specific spaces. This endpoint makes it simple to add, remove, or update space members individually.\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"spaceId":{"name":"spaceId","in":"path","required":true,"description":"The unique id of the space","schema":{"type":"string"}},"userId":{"name":"userId","in":"path","required":true,"description":"The unique ID of the User","schema":{"type":"string"}}}},"paths":{"/spaces/{spaceId}/permissions/users/{userId}":{"delete":{"operationId":"removeUserFromSpace","summary":"Remove a space user","tags":["space-users"],"parameters":[{"$ref":"#/components/parameters/spaceId"},{"$ref":"#/components/parameters/userId"}],"responses":{"204":{"description":"The user was not found in the space"},"205":{"description":"The user has been removed from the space"}}}}}}
```

## PATCH /spaces/{spaceId}/permissions/users/{userId}

> Update space user permissions

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"space-users","description":"Give your collaborators the right level of access for specific spaces. This endpoint makes it simple to add, remove, or update space members individually.\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"spaceId":{"name":"spaceId","in":"path","required":true,"description":"The unique id of the space","schema":{"type":"string"}},"userId":{"name":"userId","in":"path","required":true,"description":"The unique ID of the User","schema":{"type":"string"}}},"schemas":{"MemberRoleOrGuest":{"description":"The role of a member in an organization, null for guests","oneOf":[{"$ref":"#/components/schemas/MemberRole"},{"type":"string","nullable":true,"enum":[null]}]},"MemberRole":{"type":"string","description":"\"The role of a member in an organization.\n\"admin\": Can administrate the content: create, delete spaces, ...\n\"create\": Can create content.\n\"review\": Can review content.\n\"edit\": Can edit the content (live or change requests).\n\"comment\": Can access the content and its discussions.\n\"read\": Can access the content, but cannot update it in any way.\n","enum":["admin","create","edit","review","comment","read"]}},"responses":{"NotFoundError":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[404]},"message":{"type":"string"}},"required":["code","message"]}}}}}}}},"paths":{"/spaces/{spaceId}/permissions/users/{userId}":{"patch":{"operationId":"updateUserPermissionInSpace","summary":"Update space user permissions","tags":["space-users"],"parameters":[{"$ref":"#/components/parameters/spaceId"},{"$ref":"#/components/parameters/userId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"role":{"$ref":"#/components/schemas/MemberRoleOrGuest"}}}}}},"responses":{"204":{"description":"User permission was updated"},"404":{"description":"No user found with the given ID","$ref":"#/components/responses/NotFoundError"}}}}}}
```

## GET /spaces/{spaceId}/permissions/aggregate

> List all space users permissions

```json
{"openapi":"3.0.3","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"space-users","description":"Give your collaborators the right level of access for specific spaces. This endpoint makes it simple to add, remove, or update space members individually.\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"user":[]}],"components":{"securitySchemes":{"user":{"type":"http","scheme":"bearer"}},"parameters":{"spaceId":{"name":"spaceId","in":"path","required":true,"description":"The unique id of the space","schema":{"type":"string"}},"listPage":{"name":"page","in":"query","description":"Identifier of the page results to fetch.","schema":{"type":"string"}},"listLimit":{"name":"limit","in":"query","description":"The number of results per page","schema":{"type":"number","minimum":0,"maximum":1000}}},"schemas":{"MemberRole":{"type":"string","description":"\"The role of a member in an organization.\n\"admin\": Can administrate the content: create, delete spaces, ...\n\"create\": Can create content.\n\"review\": Can review content.\n\"edit\": Can edit the content (live or change requests).\n\"comment\": Can access the content and its discussions.\n\"read\": Can access the content, but cannot update it in any way.\n","enum":["admin","create","edit","review","comment","read"]},"List":{"type":"object","properties":{"next":{"type":"object","properties":{"page":{"type":"string","description":"Unique identifier to query the next results page"}},"required":["page"]},"count":{"type":"number","description":"Total count of objects in the list"}}},"UserContentPermission":{"type":"object","description":"Permission of a user in a content.","properties":{"permission":{"$ref":"#/components/schemas/MemberRole"},"user":{"$ref":"#/components/schemas/User"}},"required":["permission","user"]},"User":{"type":"object","properties":{"object":{"type":"string","description":"Type of Object, always equals to \"user\"","enum":["user"]},"id":{"type":"string","description":"Unique identifier for the user"},"displayName":{"type":"string","description":"Full name for the user"},"email":{"type":"string","description":"Email address of the user"},"photoURL":{"type":"string","description":"URL of the user's profile picture"},"urls":{"type":"object","description":"URLs associated with the object","properties":{"location":{"type":"string","description":"URL of the user in the API","format":"uri"}},"required":["location"]}},"required":["object","id","displayName","urls"]}}},"paths":{"/spaces/{spaceId}/permissions/aggregate":{"get":{"operationId":"listPermissionsAggregateInSpace","summary":"List all space users permissions","tags":["space-users"],"parameters":[{"$ref":"#/components/parameters/spaceId"},{"$ref":"#/components/parameters/listPage"},{"$ref":"#/components/parameters/listLimit"},{"name":"role","in":"query","description":"If defined, only members with this role will be returned.","schema":{"$ref":"#/components/schemas/MemberRole"}}],"responses":{"200":{"description":"Listing of users who can access the space.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/List"},{"type":"object","required":["items"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/UserContentPermission"}}}}]}}}}}}}}}
```