Guide: Build a REST API Endpoint

Build a workflow that acts as a REST API endpoint — it receives a request, calls an external service, and returns a structured JSON response synchronously to the caller.

What you will build:

API Endpoint (POST) → HTTP Request (fetch data) → Transform → Return

Time: ~10 minutes

Prerequisites:

  • Tensorify account with a workspace
  • CLI installed: npm install -g @tensorify.io/cli

Step 1: Create the Workflow

  1. Go to app.tensorify.io → dashboard
  2. Click New Workflow and name it user-lookup-api
  3. Click Create

Step 2: Add an API Endpoint Trigger

Drag an API Endpoint node onto the canvas. In its settings:

  • Path: /users/lookup
  • Allowed Methods: POST
  • Auth Type: api-key
  • API Key Name: X-API-Key
  • Secret: a random string (e.g., openssl rand -hex 16)
  • Response Mode: use-workflow-response

Because responseMode is use-workflow-response, you must connect a Return node by the end of this guide or test calls will hang.

Step 3: Add an HTTP Request Node

This node will look up a user from a public API. For this example, we use jsonplaceholder.typicode.com as a stand-in for your real user service.

Drag an HTTP Request node onto the canvas. Connect the API Endpoint's POST output to HTTP Request's body input.

In its settings:

  • Method: GET
  • URL: https://jsonplaceholder.typicode.com/users/{{ api_request.body.userId }}

The URL uses a {{ }} binding to inject the userId field from the incoming request body.

Step 4: Add a Transform Node

Drag a Transform node and connect HTTP Request's response to its input.

In the template, shape the response to only return what the caller needs:

{
  "id": "{{ http_request.data.id }}",
  "name": "{{ http_request.data.name }}",
  "email": "{{ http_request.data.email }}",
  "company": "{{ http_request.data.company.name }}",
  "found": true
}

Step 5: Add a Return Node

Drag a Return node onto the canvas. Connect Transform's result to Return's input.

The caller will receive the transformed object as the JSON response body.

Step 6: Test Locally

export TENSORIFY_API_KEY="your_key_here"
tensorify watch user-lookup-api-workflow-id

In the API Endpoint node settings, set a mock payload:

{ "userId": 1 }

And a mock header:

{ "X-API-Key": "your-secret" }

Click Test → select the Return node → click Run to Selected.

The canvas will show the transformed user object in the Return node's output panel.

Step 7: Deploy

  1. Click Deploy in the toolbar
  2. Note your endpoint URL — something like https://triggers.tensorify.io/your-workspace/users/lookup
  3. Set execution mode to CLI or Managed

If using CLI mode:

tensorify run user-lookup-api-workflow-id

Step 8: Call It

curl -X POST https://triggers.tensorify.io/your-workspace/users/lookup \
  -H "X-API-Key: your-secret" \
  -H "Content-Type: application/json" \
  -d '{"userId": 3}'

Expected response:

{
  "id": 3,
  "name": "Clementine Bauch",
  "email": "[email protected]",
  "company": "Romaguera-Jacobson",
  "found": true
}

What You Learned

  • How to configure an API Endpoint trigger with API key authentication
  • How to use {{ }} bindings in the HTTP Request URL to pass request data dynamically
  • How to use Transform to shape the external API response
  • How to use Return to send a synchronous JSON response back to the caller

Next Steps

On this page