Skip to main content

Overview

The User API provides operations for managing user accounts, profiles, settings, and authentication in AFFiNE.

Queries

Get Current User

Retrieve the authenticated user’s profile and settings.
query GetCurrentUser {
  currentUser {
    id
    name
    email
    emailVerified
    avatarUrl
    hasPassword
    createdAt
    disabled
    features
    settings {
      receiveInvitationEmail
      receiveCommentEmail
      receiveMentionEmail
    }
    quota {
      name
      blobLimit
      storageQuota
      usedStorageQuota
      memberLimit
      copilotActionLimit
      historyPeriod
      humanReadable {
        storageQuota
        usedStorageQuota
        blobLimit
        memberLimit
      }
    }
  }
}

Get User by Email

Retrieve a user’s public information by email address.
query GetUserByEmail($email: String!) {
  user(email: $email) {
    ... on UserType {
      id
      name
      email
      avatarUrl
      emailVerified
    }
    ... on LimitedUserType {
      email
      hasPassword
    }
  }
}
email
String!
required
The email address to search for
For privacy, this query only returns user information if you share a workspace with them.

Get Public User by ID

Retrieve a user’s public profile information by user ID.
query GetPublicUser($id: String!) {
  publicUserById(id: $id) {
    id
    name
    avatarUrl
  }
}

Mutations

Update Profile

Update the authenticated user’s profile information.
mutation UpdateProfile($input: UpdateUserInput!) {
  updateProfile(input: $input) {
    id
    name
  }
}
input
UpdateUserInput!
required

Upload Avatar

Upload a new avatar image for the authenticated user.
mutation UploadAvatar($avatar: Upload!) {
  uploadAvatar(avatar: $avatar) {
    id
    avatarUrl
  }
}
avatar
Upload!
required
Image file to upload (max 5MB, will be resized to 512x512 WebP)
Supported formats: JPEG, PNG, GIF, WebP. Images are automatically processed and converted to WebP format.

Remove Avatar

Remove the authenticated user’s avatar image.
mutation RemoveAvatar {
  removeAvatar {
    success
  }
}

Update Settings

Update user notification and preference settings.
mutation UpdateSettings($input: UpdateUserSettingsInput!) {
  updateSettings(input: $input)
}
input
UpdateUserSettingsInput!
required

Delete Account

Permanently delete the authenticated user’s account.
mutation DeleteAccount {
  deleteAccount {
    success
  }
}
This action is irreversible. All user data, workspaces owned, and documents will be permanently deleted.

Access Tokens

Generate Access Token

Create a new API access token for programmatic access.
mutation GenerateAccessToken($input: GenerateAccessTokenInput!) {
  generateUserAccessToken(input: $input) {
    id
    name
    token
    createdAt
    expiresAt
  }
}
input
GenerateAccessTokenInput!
required
The token value is only shown once during creation. Store it securely.

Revoke Access Token

Revoke an API access token.
mutation RevokeAccessToken($id: String!) {
  revokeUserAccessToken(id: $id)
}

Type Definitions

UserType

id
ID!
Unique user identifier
name
String!
User’s display name
email
String!
User’s email address
emailVerified
Boolean!
Whether the email has been verified
avatarUrl
String
URL to the user’s avatar image
hasPassword
Boolean
Whether the user has set a password
createdAt
DateTime
Account creation timestamp
disabled
Boolean!
Whether the account is disabled
features
[FeatureType!]!
Array of enabled feature flags
settings
UserSettingsType!
User notification and preference settings
quota
UserQuotaType!
User storage and usage quotas
subscriptions
[SubscriptionType!]!
Active subscriptions

PublicUserType

Limited public information about a user.
id
String!
User ID
name
String!
Display name
avatarUrl
String
Avatar image URL

UserSettingsType

receiveInvitationEmail
Boolean!
Receive workspace invitation emails
receiveCommentEmail
Boolean!
Receive comment notification emails
receiveMentionEmail
Boolean!
Receive mention notification emails

UserQuotaType

name
String!
Quota plan name (e.g., “Free”, “Pro”)
storageQuota
SafeInt!
Total storage quota in bytes
usedStorageQuota
SafeInt!
Used storage in bytes
blobLimit
SafeInt!
Maximum single file size in bytes
memberLimit
Int!
Maximum workspace members
copilotActionLimit
Int
AI action quota limit
historyPeriod
SafeInt!
Document history retention period in milliseconds

FeatureType Enum

Available feature flags:
  • FreePlan - Free tier access
  • ProPlan - Pro tier access
  • TeamPlan - Team tier access
  • LifetimeProPlan - Lifetime pro access
  • EarlyAccess - Early access features
  • AIEarlyAccess - AI early access
  • UnlimitedCopilot - Unlimited AI actions
  • UnlimitedWorkspace - Unlimited workspaces
  • Admin - Admin privileges

Error Handling

{
  "errors": [{
    "message": "USER_NOT_FOUND",
    "extensions": {
      "code": "USER_NOT_FOUND"
    }
  }]
}
The requested user does not exist.