Is there an API available to invite users or guest to a workspace? Also can we create a workspace through REST API?

Is there an API available to invite users or guest to a workspace?

Hi, @Shamir.
We are working to connect with the proper subject matter expert and gather up-to-date information for you. Thank you for being so patient. :smiley:

Hi @Shamir,

Welcome to the Bluescape developer community!

Yes, there are multiple ways to add a visitor to a workspace as a collaborator via graphQL API. This is not currently publicly available for REST:

  1. As workspace Owner or Editor, add a new or existing visitor as a workspace collaborator
  2. Requesting access to a workspace as a visitor

As workspace Owner or Editor, add a new or existing visitor as a workspace collaborator
If your API is using a bearer token tied to a user that is the workspace owner or editor, you can create a new user and then use the userId and appropriate workspace role to add the visitor to the workspace.

You can query for the desired workspace role as shown here:

For example:

  1. Get the workspace editor role (or other workspace role as desired)
query getRolesFilter($RoleFilters:RoleFilters!){
    roles(filtering:$RoleFilters )
    {
        #return
        results{
            name
            id
            isCustom
            resourceType
        }
    }
}

variables:

{
    "RoleFilters": {
        "and":{
            "resourceType":{ "eq": "Workspace"},
            "name":{"eq":"Editor"}
        }
    }
}

sample response:

{
    "data": {
        "roles": {
            "results": [
                {
                    "name": "Editor",
                    "id": "yJVPsp641WAHsWyIvQK3",
                    "isCustom": false,
                    "resourceType": "Workspace"
                }
            ]
        }
    }
}
  1. Create a new user, or return the existing userId. A new user will have the status of “Invited”:
mutation createUser(
    #$roleId:String!, 
    $email:String!){
    createUser( input:{
        #applicationRoleId:$roleId
        email:$email
    })
    {
        id
        email
        invitationStatus
    }
}

variables, with editor roleId (from id in step 1):

{
    "roleId": "yJVPsp641WAHsWyIvQK3",
    "email":"newUser@foo.com"
}

sample response:

{
    "data": {
        "createUser": {
            "id": "DgiJwII-Vu7rE2Lne263",
            "email": "newUser@foo.com",
            "invitationStatus": "INVITED"
        }
    }
}
  1. Add the user as a collaborator to the workspace with appropriate roleId
mutation addNewWorkspaceCollaborator($workspaceId:String!, $userId:String!, $workspaceRoleId:String!){
    addWorkspaceCollaborator(workspaceId:$workspaceId, input:{
        id:$userId
        #add workspace collaborator Editor Role
        workspaceRoleId:$workspaceRoleId
    })
    {
        collaborator{
            ... on User{id email}
        }
        memberInfo{
            organizationRole{
                id
                name
                type
            }
        }
    }
}

variables:

{
    "workspaceId":"{{workspaceID}}",
    "userId":"bVQVwb0Iw7IU3XNeU2cA",
    "workspaceRoleId":"yJVPsp641WAHsWyIvQK3"
}

sample response:

{
    "data": {
        "addWorkspaceCollaborator": {
            "collaborator": {
                "id": "bVQVwb0Iw7IU3XNeU2cA",
                "email": "newUser@foo.com"
            },
            "memberInfo": {
                "organizationRole": {
                    "id": "63QObaBIA1WCwt3ZCLwM",
                    "name": "Visitor",
                    "type": "Visitor"
                }
            }
        }
    }
}

If the user is already verified their email, they will be shown as “Visitor”, if they are a new user they will be shown as “Invited Visitor”

Requesting access to a workspace as a visitor
If the bearer token is tied to a visitor and that user that wants access to the workspace, you can use the createWorkspaceAccessRequest API which will send a request to the workspace owner for approval.

mutation createMyWorkspaceAccessRequest($workspaceId:String!){
    createWorkspaceAccessRequest( workspaceId:$workspaceId){
        id
        status
        user{
            id
            email
        }
    }
}

The workspace owner will get a message like the following:

I hope this helps!

If you have any additional questions, please let me know.

Hi @Shamir,

Sorry i forgot to answer the 2nd part of your question regarding creating a workspace with REST API.

Yes - this it is possible to create a workspace with REST.

You can find the REST APIs for workspace management (ISAM) here:
https://client.apps.us.bluescape.com/docs/doc/isam

Sample curl command:

curl --location --request POST 'https://api.uat.alpha.dev.bluescape.io/v3/workspaces' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <yourBearerToken>' \
--data '{
    "name": "My REST workspace",
    "description": "Your description of the workspace",
    "isPublic": true,
    "organizationId":"2P-EiUhza9MZgrw2CJ2q"
}'

Thank you, @kkoechley for the answers. It really helped.