Skip to main content

Overview

The Workspace API provides operations for managing AFFiNE workspaces, including creation, configuration, member management, and permissions.

Queries

Get All Workspaces

Retrieve all accessible workspaces for the current user.
query GetWorkspaces {
  workspaces {
    id
    public
    createdAt
    memberCount
    owner {
      id
      name
      email
    }
    permissions {
      Workspace_Read
      Workspace_Settings_Update
      Workspace_Users_Manage
    }
  }
}
workspaces
[WorkspaceType!]!
Returns array of workspaces accessible to the authenticated user

Get Workspace by ID

Retrieve a specific workspace by its ID.
query GetWorkspace($id: String!) {
  workspace(id: $id) {
    id
    public
    createdAt
    initialized
    team
    role
    enableAi
    enableSharing
    enableDocEmbedding
    enableUrlPreview
    quota {
      name
      storageQuota
      usedStorageQuota
      memberLimit
      memberCount
      humanReadable {
        storageQuota
        usedStorageQuota
        memberLimit
      }
    }
  }
}
id
String!
required
The workspace ID to retrieve

Mutations

Create Workspace

Create a new workspace for the authenticated user.
mutation CreateWorkspace {
  createWorkspace {
    id
    public
    createdAt
    role
    permissions {
      Workspace_Read
      Workspace_Settings_Update
      Workspace_Delete
    }
  }
}
createWorkspace
WorkspaceType!
The newly created workspace object

Update Workspace

Update workspace settings and configuration.
mutation UpdateWorkspace($input: UpdateWorkspaceInput!) {
  updateWorkspace(input: $input) {
    id
    public
    enableAi
    enableSharing
    enableDocEmbedding
    enableUrlPreview
  }
}
input
UpdateWorkspaceInput!
required

Delete Workspace

Permanently delete a workspace. Requires workspace owner or admin permissions.
mutation DeleteWorkspace($id: String!) {
  deleteWorkspace(id: $id)
}
id
String!
required
The workspace ID to delete

Member Management

Invite Members

Invite users to a workspace by email addresses.
mutation InviteMembers($workspaceId: String!, $emails: [String!]!) {
  inviteMembers(workspaceId: $workspaceId, emails: $emails) {
    email
    inviteId
    error
  }
}
workspaceId
String!
required
The workspace ID to invite users to
emails
[String!]!
required
Array of email addresses to invite (max 512)

Grant Member Role

Update a workspace member’s role/permission level.
mutation GrantMember($workspaceId: String!, $userId: String!, $permission: Permission!) {
  grantMember(workspaceId: $workspaceId, userId: $userId, permission: $permission)
}
permission
Permission!
required
The role to grant. Values: Owner, Admin, Collaborator, External

Revoke Member

Remove a user from a workspace.
mutation RevokeMember($workspaceId: String!, $userId: String!) {
  revokeMember(workspaceId: $workspaceId, userId: $userId)
}

Leave Workspace

Remove yourself from a workspace.
mutation LeaveWorkspace($workspaceId: String!) {
  leaveWorkspace(workspaceId: $workspaceId)
}
Workspace owners cannot leave their own workspace. Transfer ownership first or delete the workspace.

Type Definitions

WorkspaceType

id
ID!
Unique workspace identifier
public
Boolean!
Whether the workspace is publicly accessible
createdAt
DateTime!
Workspace creation timestamp
initialized
Boolean!
Whether the workspace has been initialized with content
team
Boolean!
Whether this is a team workspace
role
Permission!
Current user’s role in the workspace
memberCount
Int!
Total number of workspace members
owner
UserType!
Workspace owner user object
permissions
WorkspacePermissions!
Map of permission flags for current user
quota
WorkspaceQuotaType!
Workspace storage and member quotas

Permission Enum

  • Owner - Full control including workspace deletion
  • Admin - Administrative access, manage members and settings
  • Collaborator - Can create and edit documents
  • External - Limited read-only access

WorkspacePermissions

Boolean flags indicating available actions:
  • Workspace_Read - Can read workspace content
  • Workspace_Settings_Update - Can update workspace settings
  • Workspace_Delete - Can delete the workspace
  • Workspace_Users_Manage - Can manage workspace members
  • Workspace_Users_Read - Can view member list
  • Workspace_Blobs_Read - Can read blob storage
  • Workspace_Blobs_Write - Can write to blob storage
  • Workspace_CreateDoc - Can create new documents
  • Workspace_Sync - Can sync workspace data
  • Workspace_Copilot - Can use AI features

Error Handling

{
  "errors": [{
    "message": "SPACE_NOT_FOUND",
    "extensions": {
      "code": "SPACE_NOT_FOUND",
      "spaceId": "workspace-id"
    }
  }]
}
The requested workspace does not exist or you don’t have access.