Creating badges

To kick things off, let's set up a project in FL0 and create some badges. A badge is simply an image file that will be attached to a user's profile. Users will receive a badge when they accomplish a goal, such as reaching a new level.

Step 1: Create a new project

In FL0, a project is a container that holds all of the artifacts for a backend service, including flows, variables, and configuration. Projects are versioned independently of one another and can exist across multiple environments.

To create a project:

  1. Log in to FL0.
  2. Click Create a new project.
  3. In the Project Name field, enter R3wards.
  4. Select a hosting region.
  5. Click Save.

Then select the project to open it.

Step 2: Create a database table

By default, all projects have a built-in database. You can use this database to store and manage structured data across one or more tables.

In this case, we want to create a database table to store the project's badges. For each badge, we need to store the following attributes:

  • A unique identifier
  • A human readable name
  • The file path of an image file

To create a database table for the badges:

  1. In the Explorer pane, click Create new.

  2. Select New Table.

  3. Type badges.

  4. Tap the Return key.

  5. Switch to the Configuration tab.

  6. Create the following columns:

    NameData Type
  7. Click Save.


By default, all database tables have an Id column with a Data Type of Guid, so there's no need to create one yourself.

Step 3: Create an "API" flow

At the moment, the badges table is empty. To get some badges into the table, you need to create a flow that inserts a record.

A flow is a sequence of events that runs at a certain point in time, such as on a recurring schedule. You can use flows to create complex business logic by dragging, dropping, and connecting components within the flow editor.

There are three different types of flows, including:

  • API
  • Function
  • Scheduled

Each type of flow is triggered by a different type of event.

In this case, we want to create an API flow. This type of flow is triggered by sending an HTTP request to an endpoint hosted on FL0's servers.

To create an API flow:

  1. In the Explorer pane, click Create new.
  2. Select API.
  3. Type Insert badge.
  4. Tap the Return key.

After creating the flow, it automatically opens in the editor.

Step 4: Configure the "Start" component

All flows are made up of components.

Components are building blocks that perform some kind of action within a flow, such as retrieving data from a database or sending an HTTP request to a third-party API. It's these components — and the connections between them — that define the business logic of the flow.

By default, all flows have a Start component. This component defines the details of how the flow is triggered. For example, these are some of the configurable details of an API flow:

  • HTTP method
  • HTTP headers
  • Query string parameters

(The available options depend on the type of flow.)

To configure the Start component for the Insert badge flow:

  1. Open the Start component.
  2. From the Method dropdown, select POST.
  3. In the URL field, enter /insert-badge.
  4. Create a query string parameter called name.
  5. From the Input Type dropdown, select File.
  6. In the Accepted Content Types field, enter image/png.

Step 5: Save the badge's image file

Most components output data. Later steps in the flow can then access this data via dropdown menus:

After selecting some data from this menu, a syntax that resembles the following appears in the field:


This syntax is an example of an expression. It's evaluated at runtime and replaced the result of that evaluation. Expressions can reference both steps and variables, and can be manipulated with a variety of functions and operators.

Throughout this tutorial, all expressions are provided in full. You can simply copy these expressions into the relevant fields.

In this step, we can use expressions and the Save File component to save the badge's image file:

  1. Add a Save File component to the flow.
  2. Rename the component to saveBadgeImage.
  3. In the File Name field, enter Start.file.fileName.
  4. In the Content Type field, enter Start.file.contentType.
  5. In the Content (Base64 Encoded) field, enter Start.file.content.


You can use dot notation to access nested data (e.g. the properties of the file object).

Step 6: Insert the badge into the database

After downloading the badge's image file, the flow needs to insert the badge into the badges table. You can accomplish this with the Insert component.

To insert a badge into the badges table:

  1. Add an Insert component to the flow.

  2. From the Table dropdown, select badges.

  3. Configure the component with the following columns:


Step 7: Create the HTTP response

The last component in every API flow should be an End component. It's this component that defines the HTTP response of the flow's endpoint.

To create an HTTP response with the End component:

  1. Add an End component to the flow.
  2. From the Status Code dropdown, select 200 OK.
  3. From the Content Type dropdown, select application/json.
  4. In the Body field, enter

Based on this configuration, the response body contains the data of the newly created database record. The data of the record is available via the output of the Insert component.

This is what the complete flow looks like:

Step 8: Call the flow's endpoint

By default, FL0 automatically generates a Swagger (OpenAPI) specification for a project's API flows. You can access this specification via the Swagger icon in the sidebar.

The specification contains a list of URLs for triggering flows via HTTP requests.

To send a request to the Insert badge flow, run the following command via the command line:

curl \
--location \
--request POST '<insert-badge-flow-url>?name=alpha' \
--header 'Content-Type: image/png' \
--data-binary '@<file-path>'

But replace <insert-badge-flow-url> with the URL of the endpoint and <file-path> with the path of a PNG mage file.