Build a CRUD API Without Code

Build a complete REST API with database operations using Tensorify's visual editor. No Express, no Django, no boilerplate — just drag nodes, connect them, and deploy.

Uses: API Trigger, Switch, DB Find, DB Insert, DB Update, DB Delete, Return Time: ~15 minutes Template: CRUD API


What You'll Build

A REST API with four endpoints on a single path:

| Method | Action | Description | |---|---|---| | GET /items | Read | Fetch all items from the database | | POST /items | Create | Insert a new item | | PUT /items?id=123 | Update | Update an existing item by ID | | DELETE /items?id=123 | Delete | Remove an item by ID |

Prerequisites

  • A Tensorify workspace
  • A PostgreSQL database (or any supported database)
  • DATABASE_URL environment variable configured

Step 1: Start from the Template

The fastest way is to use the CRUD API template:

  1. Go to TemplatesAPIsCRUD API
  2. Click Use template

Or build from scratch following the steps below.

Step 2: Add the API Trigger

  1. Drag an API Trigger onto the canvas
  2. Configure:
    • Protocol: rest
    • Path: /items
    • Allowed Methods: GET, POST, PUT, DELETE
    • Auth Type: bearer-token (recommended for production)
    • Response Mode: use-workflow-response

Step 3: Route by HTTP Method

  1. Add a Switch node
  2. Set Condition to: {{ api_request.method }}
  3. Add cases: GET, POST, PUT, DELETE
  4. Set Match Mode to exact

Connect the API Trigger outputs to the Switch input.

Step 4: Wire Database Operations

GET — Fetch Items

  1. Add a DB Find node
  2. Configure:
    • Table: items
    • Columns: *
    • Limit: 50
  3. Connect Switch GET output → DB Find input

POST — Create Item

  1. Add a DB Insert node
  2. Configure:
    • Table: items
    • Data: {{ api_request.body }}
  3. Connect Switch POST output → DB Insert input

PUT — Update Item

  1. Add a DB Update node
  2. Configure:
    • Table: items
    • Data: {{ api_request.body }}
    • Where: id = '{{ api_request.query.id }}'
  3. Connect Switch PUT output → DB Update input

DELETE — Remove Item

  1. Add a DB Delete node
  2. Configure:
    • Table: items
    • Where: id = '{{ api_request.query.id }}'
  3. Connect Switch DELETE output → DB Delete input

Step 5: Add Return Nodes

Add a Return node after each database operation. Connect each DB node's result output to a Return node's input.

For the POST return, you can set the status code to 201 (Created).

Step 6: Add Environment Variables

Go to SettingsEnvironment Variables and add:

  • DATABASE_URL — your PostgreSQL connection string (e.g., postgresql://user:pass@host:5432/db)

Step 7: Deploy and Test

  1. Click Deploy and choose cloud or CLI execution
  2. Open the Playground to test each endpoint:
# Create an item
curl -X POST https://triggers.tensorify.io/h/YOUR_PATH/items \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Widget", "price": 9.99}'

# List items
curl https://triggers.tensorify.io/h/YOUR_PATH/items \
  -H "Authorization: Bearer YOUR_TOKEN"

# Update an item
curl -X PUT "https://triggers.tensorify.io/h/YOUR_PATH/items?id=1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Updated Widget", "price": 14.99}'

# Delete an item
curl -X DELETE "https://triggers.tensorify.io/h/YOUR_PATH/items?id=1" \
  -H "Authorization: Bearer YOUR_TOKEN"

Adding Validation

To validate incoming data before database operations, add a Code node between the Switch and the DB Insert/Update:

import json

body = json.loads(data)

if not body.get("name"):
    raise ValueError("name is required")
if not isinstance(body.get("price"), (int, float)):
    raise ValueError("price must be a number")

result = body

The AI Agent's error branch catches exceptions and can return appropriate error responses.

What's Next?

On this page