All examples
Tutorial7 min read

Deploy a Node.js REST API with OpenClaw

Step-by-step guide to deploying a Node.js REST API using OpenClaw. Express, Fastify, and Hono frameworks covered.

This guide walks through building and deploying a Node.js REST API with OpenClaw. We use Express but the pattern applies to Fastify, Hono, or any Node.js framework.

The API Code

// src/index.ts
import express from 'express'
const app = express()
app.use(express.json())

app.get('/health', (req, res) => {
  res.json({ status: 'ok', timestamp: new Date().toISOString() })
})

app.post('/chat', async (req, res) => {
  const { message, userId } = req.body
  // Call OpenClaw AI here
  const response = await openClaw.chat(message, { userId })
  res.json({ response })
})

const port = process.env.PORT || 3000
app.listen(port, () => console.log(`Server running on port ${port}`))

OpenClaw Config

Create openclaw.json:

{
  "channels": { "telegram": { "enabled": true } },
  "models": {
    "gpt-4o-mini": { "provider": "openai", "apiKey": "${OPENAI_API_KEY}" }
  }
}

Deploy

fly launch --no-deploy
fly secrets set OPENAI_API_KEY=sk-...
fly secrets set TELEGRAM_BOT_TOKEN=...
fly deploy

Test

fly ssh console -C "curl localhost:3000/health"

Skip the self-hosting

Deploy OpenClaw in under a minute

No servers. No SSH. No terminal. Pick a model, connect Telegram, and go.

Deploy free with Testflight