feat: add POST /api/video/render endpoint
SI
9mo ago+707+707+012345678901234567890123456789-4-4-0123456789
Summary
Adds a POST /api/video/render endpoint that triggers a server-side video render as a Trigger.dev background task. Returns a run ID that can be polled via the existing GET /api/tasks/runs endpoint.
What Changed
New Files (10 files, 686 lines)
| File | Purpose |
|---|---|
app/api/video/render/route.ts | Route handler (POST + OPTIONS) |
lib/render/renderVideoHandler.ts | Handler: auth → validate → trigger → respond |
lib/render/validateRenderVideoBody.ts | Zod schema + validation function |
lib/trigger/triggerRenderVideo.ts | Triggers render-video task on Trigger.dev |
lib/mcp/tools/render/registerRenderVideoTool.ts | MCP tool sharing triggerRenderVideo |
lib/mcp/tools/render/index.ts | Render tool registration group |
Modified Files
| File | Change |
|---|---|
lib/mcp/tools/index.ts | Register render tools |
Tests (18 passing)
| File | Tests |
|---|---|
lib/render/__tests__/validateRenderVideoBody.test.ts | 11 tests (valid inputs, defaults, error cases) |
lib/render/__tests__/renderVideoHandler.test.ts | 5 tests (auth, validation, trigger, error) |
lib/trigger/__tests__/triggerRenderVideo.test.ts | 2 tests (trigger payload, handle return) |
Architecture
Follows the exact same pattern as POST /api/sandboxes/setup:
POST /api/video/render
→ validateAuthContext (x-api-key or Bearer)
→ validateRenderVideoBody (Zod)
→ triggerRenderVideo (Trigger.dev)
→ { status: "processing", runId }
GET /api/tasks/runs?runId=xxx ← existing endpoint
→ { status: "complete", data: { videoUrl } }
DRY
The MCP tool (render_video) and REST endpoint both call the same triggerRenderVideo function.
Next Steps (PR 2)
- Trigger.dev
renderVideoTaskimplementation (in tasks repo) - Remotion
SocialPostcomposition added to remotion submodule - Upload to Supabase storage after render
Related
- Docs PR: Added
POST /api/video/renderto OpenAPI spec + Mintlify docs
Summary by CodeRabbit
-
New Features
- Added a video rendering API with customizable parameters (resolution, frame rate, duration, codec) and background processing with run ID tracking.
- Authentication supported via API keys and Bearer tokens for secure render requests.
- Improved request validation with clear error responses and consistent CORS handling.
-
Documentation
- Added API docs describing request/response formats and authentication expectations.