Fastn
PlatformConnectivityFlowsLearn
  • Getting Started
    • Welcome to Fastn
    • How Fastn Works
  • Your First Automation
  • Customer-Facing Integrations
    • Introduction to Embedded Integrations
    • Custom Webhooks: Automatic Triggers
    • Configuring the Embedded Experience
  • Building Workflows
    • Flow Setup Essentials
    • Designing a Workflow
    • Using Templates
  • Connecting Apps
    • Connector Types & Setup
    • Managing & Using Connectors
  • Data & Storage
    • Connecting External Databases
    • Connect to the Fastn DB
  • Workspaces & Multitenancy Framework
    • Workspace Management
    • MCP - Secure AI Integration and Data Access
  • UCL - Seamless Multi-Tenant Integration
  • Analytics & Monitoring
  • Tutorials
    • Create a Google Doc and Share it to Slack - using Fastn UCL
    • Connect Fastn UCL to Cursor and access data from Notion
    • Connect Fastn UCL to Cursor and Automate Task Assignment in Jira
    • Setting Up HubSpot Integration in Your Platform
    • CRUD APIs for a TODO App
  • Additional Resources
    • FAQs
Powered by GitBook
On this page
  • Part I - Create a Task​
  • Part II - Read Tasks​
  • Part III - Update a Task​
  • Part IV - Delete a Task​
  • Part V - Integrating APIs in your App​
  1. Tutorials

CRUD APIs for a TODO App

In this guide, we are going to build CRUD (create, read, update and delete) APIs for a TODO list that are going interact with the fastn internal database to manage tasks.

PreviousSetting Up HubSpot Integration in Your PlatformNextFAQs

Last updated 3 days ago

Part I - Create a Task

Building a createTask flow

  • To start off, go to the "Flows" page from the navigation menu on the left. Add a new Flow.

  • Name your flow "createTask" and create it as an API.

  • In the "Flow Configuration" step, add a new model.

  • Set the new model "newTask" as the input.

  • Defining a model will setup the input schema for the createTask API. This API will take in a task title and create a new task with that title.

  • Drag and drop a database element and name it "CreateTask".

  • Set it up with the following query.

CREATE TABLE IF NOT EXISTS tasks (
   id varchar(255) primary key,
   title varchar(255) not null
);
INSERT INTO tasks VALUES (gen_random_uuid(), '{{input.title}}');
  • This query will create a table for tasks with each task having the fields id and title as attributes.

  • It will then insert a new task with the title passed in the input and a random uuid as the id.

  • Add a "Success" response and have it return a message like "New Task Created".

  • We can test the create task flow using the "Debugger".

  • This will create a new task in the database. To see the tasks, navigate to the "Databases" page and select fastn DB.

  • Select the "tasks" table.

  • Here you can see all the current tasks present in the table and filter data as needed.

  • Create a new API flow and name it "getTask".

  • Go to the Flow Configuration step and add a new model. Name it "taskById". Set it as the input model.

  • Add a database step with the following query.

SELECT * FROM tasks WHERE id = '{{input.id}}';
  • We can test this flow in the "Debugger".

  • Create a new API flow and name it "getTasks".

  • We don't need a specific model here. So we can add the database step with the following query.

SELECT * FROM tasks
  • We can test this flow in the "Debugger".

  • Create a new API flow and name it "updateTask".

  • Go to the "Flow Configuration" step and add a new model. Name it "updateTask". Set it as the input model.

  • Add a database step with the following query.

UPDATE tasks

SET description = '{{input.title}}'
WHERE id = '{{input.id}}';
  • Add a "Success" response with an appropriate message.

  • We can test this flow in the "Debugger".

  • Create a new API flow and name it "deleteTask".

  • Go to the "Flow Configuration" step and set the "taskById" model we created before as the input model.

  • Add a database step with the following query.

DELETE FROM tasks WHERE id = '{{input.id}}';
  • Add a "Success" response with an appropriate message.

  • We can test this flow in the "Debugger".

  • After completing the setup in Parts I to IV, we should have the following flows.

  • To integrate a flow as an API. Go to a flow and click on "Deploy".

  • Once a flow is deployed, click on "Embed this Flow".

  • Use "Generate API Key" to create new API key with access to desired flows. Note: If you have already generated an API key with permissions for multiple flows it can be reused in the "x-fastn-api-key" header.

  • Once the API key is generated the auto-generated code will be updated. Select the desired programming language or copy the cURL request and integrate in your app or use it with an API tool like Postman.

Congratulations! Now you know how to integrate APIs in an application and interact with the fastn database

Create a task in the database

Part II - Read Tasks

Building a getTask API

Building a getTasks API

Part III - Update a Task

Building an updateTask API

Part IV - Delete a Task

Building a deleteTask API

Part V - Integrating APIs in your App

​
​
​
​
​
​
​
​
​
​
​