Docs
Contents

Web (user Session)

SDK for browser / mobile frontends: calls project features as a user Session. The Client SDK currently has only one language surface, JavaScript (Web), with npm coordinates agentbase-web-sdk@2.12.0 (installation see ../integration.md). This page covers selection, initialization, auth mounting, the error model, and the feature surface mapping; feature details live in the feature-axis docs.

How to choose among the three SDK types

What you are writingWhich SDKCredentialsnpm package
Browser / mobile frontend; end users operatetheir owndataClient SDK (this page)User Session (Cookie, sent automatically)agentbase-web-sdk
Node backend / Worker / CLI, reading and writing all data as the projectServer SDK (java / python / go pages of the same name also exist)Project API Keyagentbase-node-sdk
Creating projects / issuing Keys / platform registration / organization and billing governance automationConsole SDK (java / python / go pages of the same name also exist)Console Session or short-lived JWTagentbase-console-sdk

Only the user Session belongs in the frontend; the API Key and all secrets must stay server-side only.

Initialization: setEndpoint + setProject

import { Client, Account, TablesDB } from 'agentbase-web-sdk';

const client = new Client()
    .setEndpoint('https://<host>/v1')     // Environment spec see ../environment.md
    .setProject('<PROJECT_ID>');          // App project ID, not 'console'

export const account = new Account(client);
export const tablesDB = new TablesDB(client);

Get started in 5 minutes (browser)

  1. Install: npm install agentbase-web-sdk@2.12.0 --save-exact.

  2. Initialize with the code above and register your Web domain under the project's Overview → Platforms (otherwise CORS 403; seePlatform registration).

  3. Register and log in to obtain a user Session:

import { ID, Query } from 'agentbase-web-sdk';

await account.create({ userId: ID.unique(), email, password, name });  // Register once only
await account.createEmailPasswordSession({ email, password });
const me = await account.get();   // Throws 401 = not logged in / session expired; handle as not logged in
  1. Read and write data as the user (subject to row-level permissions, seePermission model):

const rows = await tablesDB.listRows('app-db', 'tasks', [Query.equal('done', false)]);

For complete, runnable examples of each feature, see ../examples/javascript.md.

Auth mounting (where the user Session comes from)

MethodMounting callNotes
Email/Passwordaccount.create() Register + account.createEmailPasswordSession()Session lands in a Cookie and is sent automatically afterwards
OAuth 2.0account.createOAuth2Session({ provider, success, failure })Browser redirect; Provider / callback configuration see ../authentication.md
Magic URL / PhonecreateMagicURLToken / createPhoneToken → createSession / updatePhoneSessionCallback page takes userId + secret
Anonymousaccount.createAnonymousSession()Guest identity, can be converted to a full account without data loss
Custom TokenServer-side users.createToken → account.createSession({ userId, secret })Your own account system
JWT (outbound)account.createJWT()Handed to a trusted backend for calls on its behalf; not a frontend mounting method

Session recovery has three layers: Cookie (a_session_<projectId>) → x-appwrite-session header → x-fallback-cookies (localStorage). In cross-origin scenarios such as <img> where headers cannot be set, none of them work; use a Blob URL or File Token (../storage.md). Session management see ../profile.md.

Error model

Feature surface mapping table (client-available surface)

Feature domainClient SDK serviceDetails and boundaries
Account authentication (full spectrum + MFA)Account../authentication.md
Account profile / sessions / preferencesAccount../profile.md
Current account quota limitsAccount.getQuotaLimits() / updateQuotaLimits() / deleteQuotaLimits() / listLimitsProjects(); account-level only, excludes project quota or /limits governance../limits.md
Database row read/write (under user Session, permission-constrained)TablesDB / Databases (legacy doc surface)../databases.md, ../permissions.md
Query constructionQuery../databases.md
Object storage (upload / download / preview URL)Storage../storage.md
Function triggering (requires execute permission)Functions../functions.md
Teams (your own teams and members)Teams../teams.md
Realtime subscriptionsRealtime + Channel (Channel.tablesdb(db).table(t).row(r), Channel.files(), account channels)Subscribe to row / file / account changes; subscribe(...) returns a handle close(); channels are constructors, not function strings
Organization project governance (Owner)Projects (listInactiveByOrganization and 4 methods)../project-governance.md; requires Owner Session + setOrganization
Memory data planeMemoryThe user's own authorized memory read/write; the management plane is not on the client
LLM / AI data planeLlmGateway, AiGateway, KnowledgeBasesEnd-user data plane subset; must not hold Gateway Keys / Provider credentials
OthersAvatars, Locale, GraphqlGeneral utilities and query surface

Client boundaries (unavailable surface)

UnavailableReason / alternative
User management (users.list, editing others' profiles, labels)Management-plane only; use the Server SDK (../users.md)
File Token issuance (Tokens)Requires an API Key; issue short-lived links via a Function / backend
Platform registration / OAuth Provider configuration / API Key managementConsole Session surface or management API Key (../overview.md)
Granting rows / files to othersClient SDK hasRole constraint; proxy through a Function (../permissions.md)
Organization management, billing, organization KeysConsole SDK / Console UI (../organization.md)
Bucket / table schema baseline configurationBaselines are pushed from the server; the client only consumes

Usage notes and boundaries

Example Guide