n8n Integration
n8n Integration
Section titled “n8n Integration”You can call the AutoVio REST API from n8n to automate video creation workflows (e.g. on webhook, schedule, or form submission).
Prerequisites
Section titled “Prerequisites”- AutoVio is running (backend on
http://localhost:3001or your base URL). - You have an API token with the required scopes (see Authentication).
Create an API token
Section titled “Create an API token”Use the UI or call POST /api/tokens to create a token:
{ "name": "n8n workflow", "scopes": ["projects:read", "projects:write", "works:read", "works:write", "ai:analyze", "ai:generate"], "expiresInDays": 90}Use the returned token in the Authorization header:
Authorization: Bearer <token>Example flow – create project and work
Section titled “Example flow – create project and work”In n8n, you typically use HTTP Request nodes to call the API.
1. Create project (HTTP Request)
Section titled “1. Create project (HTTP Request)”- Method:
POST - URL:
{{ $env.AUTOVIO_BASE_URL }}/api/projects - Headers:
Authorization: Bearer {{ $env.AUTOVIO_API_TOKEN }}Content-Type: application/json
- Body (JSON):
{ "name": "n8n Demo Project", "styleGuide": { "tone": "professional", "tempo": "medium" }}Store the response id (e.g. using n8n expressions) as projectId.
2. Create work (HTTP Request)
Section titled “2. Create work (HTTP Request)”- Method:
POST - URL:
{{ $env.AUTOVIO_BASE_URL }}/api/projects/{{ $json.projectId }}/works - Headers: same as above.
- Body (JSON):
{ "name": "n8n Demo Work", "mode": "content_remix", "productName": "EcoBottle", "sceneCount": 5, "videoDuration": 30}Store the workId from the response for later steps.
Example flow – generate scenario and scenes
Section titled “Example flow – generate scenario and scenes”1. Generate scenario for work
Section titled “1. Generate scenario for work”Call POST /api/projects/:projectId/works/:workId/scenario with headers:
Authorization: Bearer <token>x-llm-provider,x-model-id,x-api-keyas described in AI Endpoints.
This updates work.scenes and returns the generated scenes.
2. Generate image+video per scene
Section titled “2. Generate image+video per scene”For each sceneIndex (0-based), call:
POST /api/projects/:projectId/works/:workId/generate/scene/:sceneIndex
with:
Authorization: Bearer <token>x-api-keyand provider headers for image/video.
The response includes imageUrl and videoUrl for that scene.
- Use n8n environment variables (
$env.AUTOVIO_BASE_URL,$env.AUTOVIO_API_TOKEN) so you don’t hardcode secrets in nodes. - Use Set and Function nodes to map incoming data (e.g. webhook payload) into product name, description, or target audience before calling the API.