Controllers

Last updated on March 24, 2026.

Controllers are reusable blocks of logic that handle specific tasks within your Instance. You can call a Controller from multiple pages or API endpoints, keeping your code consistent and easier to maintain. Instead of duplicating logic across your Instance, you define it once in a Controller and reference it wherever it is needed.

This article discusses the following topics:

  • What Controllers do
  • Creating a Controller
  • Calling a Controller

What Controllers do

A Controller receives input, processes it according to the logic you define, and returns an output. Common uses include:

  • Validating incoming data before it is saved
  • Running a calculation or transformation on a value
  • Querying data and returning a structured result
  • Enforcing business rules consistently across your Instance

Creating a Controller

To create a Controller:

  1. Navigate to API from the main menu.
  2. Select Controllers.
  3. Select CREATE CONTROLLER.
  4. Fill out the form.
  5. Select CREATE.

The input requirements for creating a Controller are as follows:

Input LabelTypeRequiredDescription
Controller NameInput FieldYesA descriptive name for your Controller.
BodyCode EditorYesThe logic the Controller executes when called.

Calling a Controller

Important: Breaking Change in v5.2.1

As of v5.2.1, the method for calling a Controller changed. Controllers must now be called using the function approach. The previous include method is no longer supported. If your Instance uses Controllers created before this update, you must update your code to use the function approach.

To call a Controller, use the function tag and reference the Controller by name. The function call passes any required input values and receives the Controller's output in return.

Example using the function approach:

{% function result = 'modules/my_module/my_controller', param1: value1, param2: value2 %}

The result of the Controller is available in the result variable after the function call completes.

Note

The include method previously used to call Controllers is no longer supported as of v5.2.1. Replace any {% include %} Controller calls with {% function %} calls.

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.