Skip to main content

Overview

Cabina uses Supabase Edge Functions (Deno runtime) for serverless backend operations:
  • cabina-vision - AI image generation pipeline
  • mercadopago-payment - Payment processing and webhooks
Edge Functions run on Deno Deploy with global distribution for low latency.

Function Endpoints

Base URL

https://<project-ref>.supabase.co/functions/v1/
Example:
https://elesttjfwfhvzdvldytn.supabase.co/functions/v1/cabina-vision

Authentication

Edge Functions require the Supabase anon key in the request header:
Authorization: Bearer <SUPABASE_ANON_KEY>
apikey: <SUPABASE_ANON_KEY>
JavaScript Example:
import { supabase } from './supabaseClient';

const { data, error } = await supabase.functions.invoke('cabina-vision', {
  body: { user_photo: base64Image, model_id: 'pb_a' }
});

Common Headers

All edge functions support CORS and expect:
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: authorization, x-client-info, apikey, content-type

Error Handling

All functions return JSON responses with consistent error structure:
{
  "error": true,
  "success": false,
  "message": "Detailed error message"
}
Success Response:
{
  "success": true,
  "data": { ... }
}

Rate Limiting

Edge Functions are subject to:
  • Supabase plan limits (free tier: 500K invocations/month)
  • Individual function timeout: 150 seconds
  • Max payload size: 10MB
Monitor usage in Supabase Dashboard → Edge Functions → Metrics.

Deployment

supabase functions deploy

Function Details

cabina-vision

AI image generation pipeline

mercadopago-payment

Payment processing and webhooks

Logs & Debugging

View Logs

# Stream live logs
supabase functions logs cabina-vision --tail

# View recent logs
supabase functions logs cabina-vision --limit 100

Local Development

# Serve functions locally
supabase functions serve

# Serve specific function
supabase functions serve cabina-vision --env-file .env.local
Test locally:
curl -i --location --request POST 'http://localhost:54321/functions/v1/cabina-vision' \
  --header 'Authorization: Bearer <ANON_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{"user_photo":"data:image/png;base64,...","model_id":"pb_a"}'

Next Steps

cabina-vision API

Complete AI generation API reference

Payment Webhook

Mercado Pago integration details

Build docs developers (and LLMs) love