Core Endpoints
| Method | Path | Purpose |
|---|
| POST | /api/workflow/generate | Accepts intake payloads or prompts and returns workflow JSON with metadata. |
| GET | /api/my-workflows | Lists workflows for the authenticated user and includes usage stats. |
| POST | /api/export-workflow | Marks a workflow as exported or triggers downstream delivery. |
| GET | /api/webhook/test/[workflowId] | Receives webhook payloads during testing and records analytics. |
Authentication
All routes expect a Supabase JWT. Client-side requests attach the token from supabase.auth.getSession(). Server-to-server tasks can use SUPABASE_SERVICE_ROLE_KEY but never expose it to the browser.
Example Request & Response
Request:
POST /api/workflow/generate
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json
{
"userInput": {
"businessSnapshot": {
"industry": "ecommerce",
"companySize": "50-200",
"currentTools": ["Shopify", "Stripe", "Slack"]
},
"workflowDescription": "When a Stripe payment succeeds, create a customer record in HubSpot and notify the sales team in Slack"
},
"outputFormat": "n8n"
}Success Response (200):
{
"success": true,
"workflow": {
"name": "Stripe Payment to HubSpot & Slack",
"nodes": [...],
"connections": {...}
},
"meta": {
"outputFormat": "n8n",
"nodeCount": 7,
"processingTime": "12.3s"
}
}Error Response (401 Unauthorized):
{
"error": "Authentication required",
"message": "Please sign in to generate workflows"
}Error Response (422 Validation Error):
{
"error": "Validation failed",
"message": "workflowDescription is required",
"details": {
"field": "userInput.workflowDescription",
"issue": "missing_required_field"
}
}