Skip to main content

createClient(config): Base44Client
Creates a Base44 client. This is the main entry point for the Base44 SDK. It creates a client that provides access to the SDK’s modules, such as entities, auth, and functions. Typically, you don’t need to call this function because Base44 creates the client for you. You can then import and use the client to make API calls. The client takes care of managing authentication for you. The client supports three authentication modes:
  • Anonymous: Access modules anonymously without authentication using base44.moduleName. Operations are scoped to public data and permissions.
  • User authentication: Access modules with user-level permissions using base44.moduleName. Operations are scoped to the authenticated user’s data and permissions.
  • Service role authentication: Access modules with elevated permissions using base44.asServiceRole.moduleName. Operations can access data across all users. Can only be used in the backend. Typically, you create a client with service role authentication using the createClientFromRequest() function in your backend functions.
For example, when using the entities module:
  • Anonymous: Can only read public data.
  • User authentication: Can access the current user’s data.
  • Service role authentication: Can access all data that admins can access.
Most modules are available in all three modes, but with different permission levels. However, some modules are only available in specific authentication modes.

Parameters

config
CreateClientConfig
required
Configuration object for the client.
appId
string
required
The Base44 app ID.You can find the appId in the browser URL when you’re in the app editor. It’s the string between /apps/ and /editor/.
token
string
User authentication token. Used to authenticate as a specific user.
serviceToken
string
Service role authentication token. Use this in the backend when you need elevated permissions to access data across all users or perform admin operations. This token should be kept secret and never exposed in the app’s frontend. Typically, you get this token from a request to a backend function using createClientFromRequest().
options
CreateClientOptions
Additional client options.
onError
(error: Error) => void
Optional error handler that will be called whenever an API error occurs.

Returns

Base44Client The Base44 client instance. Provides access to all SDK modules for interacting with the app. A configured Base44 client instance with access to all SDK modules.
entities
EntitiesModule
required
Entities module for CRUD operations on your data models.
integrations
IntegrationsModule
required
Integrations module for calling pre-built integration endpoints.
auth
AuthModule
required
Auth module for user authentication and management.
functions
FunctionsModule
required
Functions module for invoking custom backend functions.
agents
AgentsModule
required
Agents module for managing AI agent conversations.
appLogs
AppLogsModule
required
App logs module for tracking app usage.
cleanup
() => void
required
Cleanup function to disconnect WebSocket connections. Call when you’re done with the client.
asServiceRole
object
required
Provides access to supported modules with elevated permissions.Service role authentication provides elevated permissions for backend operations. Unlike user authentication, which is scoped to a specific user’s permissions, service role authentication has access to data and operations across all users.
entities
EntitiesModule
required
Entities module with elevated permissions.
integrations
IntegrationsModule
required
Integrations module with elevated permissions.
connectors
ConnectorsModule
required
Connectors module for OAuth token retrieval.
functions
FunctionsModule
required
Functions module with elevated permissions.
agents
AgentsModule
required
Agents module with elevated permissions.
appLogs
AppLogsModule
required
App logs module with elevated permissions.
cleanup
() => void
required
Cleanup function to disconnect WebSocket connections.

Example

import { createClient } from '@base44/sdk';

const base44 = createClient({
  appId: 'my-app-id'
});

// Use the client to access your data
const products = await base44.entities.Products.list();