Note the following:
- Each project supports a maximum of 50 backend functions.
- Backend functions have a maximum execution time of 5 minutes. Requests that exceed this limit are terminated.
Create functions
Create backend functions as TypeScript files in your project’s functions directory. By default the functions directory isbase44/functions/, but you can customize the path in your project configuration.
Each function lives in its own subdirectory with an entry.ts or entry.js file:
functions
<function-name>
entry.ts
functions/sendWelcomeEmail/entry.ts creates a function named sendWelcomeEmail. You can also nest functions in subdirectories for organization. functions/email/send/entry.ts creates a function named email/send.
Adding a configuration file
For advanced needs like custom function names or automations, add afunction.jsonc file:
functions
<function-name>
entry.ts
function.jsonc
entry.ts
The code file contains your function logic. Functions must use theDeno.serve() wrapper and return Response objects:
Multiple files per function
A function isn’t limited to a singleentry.ts. Split logic into multiple files within the function’s directory and import them with relative paths. Every .js, .ts, .json, and .jsonc file in the function directory is deployed with the function.
functions
process-order
entry.ts
validate.ts
types.ts
Share code between functions
To reuse code across functions, place it in ashared directory inside your base44/ folder.
The entire shared directory is bundled with every function, so each function is deployed with its own copy. This means:
- Any function can import from
sharedwith a relative path. - Different functions can end up running different versions of the same shared file. Changing a shared file and deploying a single function updates only that function’s copy. The others keep the old version until you redeploy them. To apply a shared change everywhere, run
base44 functions deploywith no arguments to redeploy every function at once.
base44
shared
response.ts
functions
greet
entry.ts
farewell
entry.ts
Test locally
Run your functions locally withbase44 dev to test changes without deploying. See Local development for details.
Deploy functions
Deploy functions withfunctions deploy or deploy to push all project resources at once. You can deploy specific functions by name with functions deploy <names...>, or use --force to remove remote functions not found locally.
To download deployed functions to your local project, use functions pull. To see what’s currently deployed, use functions list.
Call functions
Call backend functions from your frontend using the SDK, or via HTTP for webhooks and external integrations.Via the SDK
Usebase44.functions.invoke() to call functions from your frontend. The SDK handles authentication automatically, passing the current user’s credentials to your function.
Via HTTP
Each deployed function gets an HTTP endpoint at:- Webhooks: Receive callbacks from external services like Stripe or GitHub.
- External integrations: Allow other systems to interact with your app.
- Testing: Call functions directly with tools like cURL or Postman.
When calling functions via direct HTTP (like cURL or webhooks), there’s no
authenticated user context. Use
asServiceRole for all operations in these
cases.Use the SDK in functions
Inside your backend functions, you can access your app’s data, authentication, and integrations through the Base44 SDK. UsecreateClientFromRequest() to create a client from the incoming request.
The authentication context depends on how the function was called:
-
When called via the SDK from your frontend: The user’s authentication is passed through automatically. You can access the current user with
base44.auth.me()and perform operations with their permissions. To read or write data without entity access rules applying, useasServiceRole. -
When called via direct HTTP (cURL, webhooks, external services): There’s no authenticated user, so use
asServiceRolefor all operations.
Connect to third-party APIs
Backend functions are one of several ways to connect to third-party APIs. They’re ideal when you need full control over requests or want to store API keys securely as environment variables. Usesecrets set to configure environment variables from the CLI.
View logs
During local development, function output is printed directly to your terminal without needing thelogs command.
For deployed functions, view logs with the logs command. The logs include console output, errors, and timing information. You can filter by function name or time range. If you’re using an AI coding agent, the base44-troubleshooter skill can fetch and analyze these logs automatically.
TypeScript types
Generate TypeScript types from your function configurations to get type safety and autocomplete for function names in your SDK code. Learn more about dynamic types.See also
- Automations: Schedule functions or trigger them on database events
functionsmodule: SDK reference for invoking functionscreateClientFromRequest: Creating a client in backend functionsfunctions deploy: Deploy local functions to Base44functions pull: Download deployed functions to your local projectfunctions list: List all deployed functionsfunctions delete: Delete deployed functionslogs: View function logsexec: Test functions in isolation from standalone scripts