Skip to content

IoT / Camera Proxy

Backflow can act as a secure proxy for IP cameras, enabling remote access, multi-camera dashboards, and AI-powered video analysis — all behind tenant authentication and RBAC.

Supported Camera Types

TypeProtocolFeatures
RTSPReal-Time Streaming ProtocolHLS transcoding, snapshots via FFmpeg
HTTPHTTP/HTTPSSnapshot proxy, basic auth forwarding
MJPEGMotion JPEG over HTTPStream relay
ONVIFOpen Network Video InterfaceDevice management (planned)

Quick Start

1. Register a Camera

bash
curl -X POST https://api.backflow.dev/tenant/iot \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Front Door",
    "type": "rtsp",
    "connectionUrl": "rtsp://192.168.1.100:554",
    "credentials": { "username": "admin", "password": "cam123" },
    "streamPath": "/stream1"
  }'

Credentials are encrypted at rest and never returned in API responses.

2. Capture a Snapshot

bash
# Raw JPEG (for display)
curl -H "Authorization: Bearer $TOKEN" \
  https://api.backflow.dev/tenant/iot/front-door/snapshot \
  --output snapshot.jpg

# Base64 JSON (for workflows)
curl -H "Authorization: Bearer $TOKEN" \
  https://api.backflow.dev/tenant/iot/front-door/snapshot?format=base64

3. Start Live Streaming (RTSP only)

bash
# Start HLS transcoding
curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://api.backflow.dev/tenant/iot/front-door/stream/start

# Play in browser via HLS.js
# URL: https://api.backflow.dev/tenant/iot/front-door/stream.m3u8

# Stop streaming
curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://api.backflow.dev/tenant/iot/front-door/stream/stop

Streams auto-stop after 5 minutes of no viewer activity.

AI Vision Integration

Camera snapshots integrate directly with Backflow workflows for AI analysis.

Direct Vision (llm_call)

Pass the snapshot URL in the images array of an llm_call step:

json
{
  "action": "llm_call",
  "params": {
    "prompt": "Describe what you see in this camera feed. Flag any security concerns.",
    "model": "gpt-4-vision",
    "provider": "openai"
  },
  "images": [
    {
      "url": "https://api.backflow.dev/tenant/iot/front-door/snapshot",
      "detail": "high"
    }
  ]
}

Chained Workflow (api_call → llm_call)

Fetch the snapshot as base64 in one step, then analyze in another:

json
{
  "steps": [
    {
      "id": "capture",
      "action": "api_call",
      "params": {
        "endpoint": "/tenant/iot/front-door/snapshot?format=base64",
        "method": "GET"
      }
    },
    {
      "id": "analyze",
      "action": "llm_call",
      "params": {
        "prompt": "Count the number of people visible. Return JSON: { count: number }",
        "model": "claude-sonnet-4-5-20250929"
      },
      "files": [
        {
          "data": "{{capture.data}}",
          "mimeType": "image/jpeg",
          "filename": "snapshot.jpg"
        }
      ]
    }
  ]
}

API Reference

MethodEndpointDescription
GET/tenant/iotList all cameras
POST/tenant/iotRegister a camera
GET/tenant/iot/:idGet camera details
PUT/tenant/iot/:idUpdate camera
DELETE/tenant/iot/:idDelete camera
GET/tenant/iot/:id/snapshotCapture JPEG snapshot
GET/tenant/iot/:id/snapshot?format=base64Snapshot as base64 JSON
POST/tenant/iot/:id/stream/startStart HLS transcoding
POST/tenant/iot/:id/stream/stopStop transcoding
GET/tenant/iot/:id/stream/statusStream status
GET/tenant/iot/:id/stream.m3u8HLS playlist
GET/tenant/iot/:id/stream/:segmentHLS segment

Requirements

  • FFmpeg must be installed on the server for RTSP streaming and RTSP snapshots
  • HTTP camera snapshots work without FFmpeg
  • Cameras must be network-accessible from the Backflow server
  • Pro plan or higher required

Security

  • Camera credentials are double-encrypted via the tenant secrets system
  • All endpoints require a valid tenant JWT
  • Credentials are never returned in API responses
  • RBAC resource type: iot — configure per-role access in tenant RBAC settings
  • Idle streams auto-cleanup prevents resource leaks

Backflow - Configuration-driven API framework