Appearance
Intro to Functions
A Function in WeWeb is a flow of logic that you can create once, and then reuse across different parts of the Data & API tab, such as in API Endpoints, Event Triggers, or even within other Functions.
Think of it as a custom task or calculator that can process some data, do something useful, and send back the result.
You might use Functions when you have logic you need in several places, like processing order totals, transforming text, or sending custom emails. By building a Function once, you avoid repeating the same logic in multiple workflows.
Why to use Functions
Functions help keep your logic organized and easy to manage. They’re especially helpful when you want to:
- Avoid repeating yourselfReuse shared logic across API Endpoints, triggers, and Functions
- Make updates easierChange logic once and propagate everywhere it’s used
- Improve reliabilityKeep behavior consistent across flows to reduce mistakes
- Clean up complex workflowsMove detailed calculations/checks into Functions
By organizing your backend logic into Functions, you'll save time and make your app easier to maintain as it grows.
FUNCTIONS & PROJECT WORKFLOWS
If you have used Project Workflows in the Interface tab, then you can think of Functions as basically Project Workflows that you can use in the Data & API tab.
Like Project Workflows, Functions allow you to create reusable logic that you can then use elsewhere. The only difference is that Functions can be used in the Data & API tab, whereas Project Workflows cannot.
Example use cases
These are just a few examples of logic you may want to put in a Function, but essentially anything repetitive or easily broken down into steps can be put into a Function.
This helps keep your logic tidy, lets you reuse your work, and makes your project easier to manage:
Calculate totals
Calculate an order summary (subtotal, taxes, total) from a list of items.
Example use: call this in a create-checkout API Endpoint before creating an order.
Format or clean data
Standardize text, strip unwanted characters, or convert values.
Example use: use in an update-customer API Endpoint, or in the On after sign up Event Trigger to normalize names.
Checking conditions
Reusable checks like verifying a discount code or blocking blacklisted emails.
Example use: run in an apply-discount API Endpoint, or in the On before sign up Event Trigger to reject invalid emails.
Send custom emails
Build a templated email body with dynamic values.
Example use: use in the On password reset requested Event Trigger to compose the message, or in a send-invoice API Endpoint.
Making your Function's logic reusable
There are three core parts to a Function:
Input parameters
Input parameters allow dynamic values to be passed into your Functions, so the values can then be used in the logic of the Function. You add and manage them from the Parameters panel.
For example, if you had a Function to clean a name, you may have a name input parameter for the Function.
Logic
The logic is where you create the core logic of your Function.
To make your logic dynamic, you can use the values that have been passed into the inputs.
In the example of a Function to clean a name, you may have logic set up to take a word and clean it. Then, in the logic you would pass in the value of the name input parameter as the word you want to be cleaned.
This would allow your Function to be adaptable, and in this example, able to be used anytime you wish to clean a name.
Response
The response is where you can return the essential data that is needed from the Function.
In the example of the Function to clean a name, you would likely want the Function to return the cleaned name. This way, you could call this Function in something like a create_customer API Endpoint, get back the cleaned name, and then create a record for the customer using the cleaned name.
Creating a Function
Go to
Data & API→Backend Workflows→Functionsand click+ Add Functionto create a new FunctionDefine the
Input Parametersfor dynamic values that can be passed to the FunctionAdd actions for the logic
Return a result using
Send response
Using a Function
With a Function created, you can then use the Functions in:
- API Endpoints — Learn more →
- Middleware — Learn more →
- Event Triggers — Learn more →
- Other Functions
You will find the Function in the Add an action menu under the Functions folder:
With the Function action added, you will be able to configure what you wish to pass for its input parameters:
And after the Function runs, you will have access to the response and can use it in following actions:

