Skip to main content
This page is part of an AI coding agent skill and is written for agents, not humans. For the human-readable Base44 docs, see the developer documentation.

Functions Module

Invoke custom backend functions via base44.functions.

Contents

Methods

invoke

  • functionName: Name of the backend function
  • data: Optional object of parameters (sent as JSON, or multipart if contains File objects)
  • Returns the RAW axios response — the JSON your function returned lives on .data, not on the top-level object. The resolved value is { data, status, headers, … }.
  • Throws on a non-2xx response. The error body is at err.response.data.

fetch

Low-level method that performs a direct HTTP request to a backend function path and returns the native Response object. Use when you need streaming responses, custom HTTP methods, or raw response access.
  • path: Function path (e.g., /streaming_demo or /my-function/endpoint)
  • init: Optional native fetch options (RequestInit)
  • Returns: Native Response object

Invoking Functions

From Frontend

Streaming Response (using fetch)

Custom HTTP Methods (using fetch)

With File Upload

With Service Role (Backend)

Via REST API (curl)

Functions can be called via HTTP POST to your app domain:

Writing Backend Functions

Backend functions are HTTP handlers. Each one must export default an async function that takes a Request and returns a Response.

Function Directory Structure

A backend function is a folder under base44/functions/ with an entry.ts or entry.js file:
The function name is the path from base44/functions/ to the folder containing entry.ts. For example, base44/functions/process-order/entry.ts deploys as process-order, and base44/functions/orders/process/entry.ts deploys as orders/process. For complete setup and deployment instructions, see functions-create.md in base44-cli.

Basic Structure

With Service Role Access

Using Secrets

Read secrets with secrets.get() from the base44:runtime module. BASE44_APP_ID is pre-populated; configure the rest in app settings.

Post-Response Work

To finish work after the response is sent, hand the promise to waitUntil() from base44:runtime:

Error Handling

Setup Requirements

  1. Enable Backend Functions in app settings (requires appropriate plan)
  2. Create function files in base44/functions/
  3. Configure secrets via app dashboard for API keys

Authentication Modes

Inside the function, use createClientFromRequest(req) to get a client that inherits the caller’s auth context.

Type Definitions

How to get typed function names: The Base44 CLI can generate an augmentation of FunctionNameRegistry from your project. For how to run it, use the base44-cli skill.