API Documentation

This directory contains per-function deep docs for Supabase Edge Function APIs.

๐Ÿ“‘ Looking for the master list? See api-master-reference.md โ€” single page covering all 68 edge functions + MIVAA Python endpoints (auth models, categories, call patterns). Start there if you're integrating; come here for endpoint details.

Overview

All APIs are implemented as Supabase Edge Functions running on Deno and are accessible via:

Base URL: https://bgbavxtjlbvgplozizxu.supabase.co/functions/v1/

Available APIs

Core Business APIs

Email API

Email sending, domain verification, and analytics using AWS SES.

Messaging API

Multi-channel messaging (SMS, WhatsApp) using Twilio.

CRM Contacts API

Contact management for CRM system.

CRM Users API

User account and profile management.

CRM Companies API

Company records management.

Quotes API

Quote requests and proposal management.

Pricing API (NEW โ€” 2026-04)

Admin-only API for sourcing, composing, and committing prices from the "Pricing" Knowledge Base category. Covers: category setup, ingesting price docs, AI-mode lookup via price_lookup agent tool, quick-pick direct search, commit flow, and audit trail.

Recommendations API

Collaborative filtering recommendations and interaction tracking.

AI & Agent APIs

Agent Chat API

Unified multi-agent AI system powered by LangChain.js and Claude.

MIVAA Gateway API

Gateway to Python backend services (RAG, search, AI services).

Processing APIs

PDF Batch Process API

Batch processing of PDF documents.

Scrape Session Manager API

Web scraping session control and management.

XML Import Orchestrator API

Intelligent XML file imports with AI-powered field mapping.

Automation APIs

Price Monitoring Cron API

Scheduled price monitoring from competitor sources.

Flow Engine API

Visual workflow automation โ€” execute, test, and event-trigger flows.

AI Generation APIs

Interior Video Generation API

Multi-model AI video generation for interior design.

Virtual Staging API

Transform empty room photos into furnished renders.

Gemini Interior Generation API

Gemini-powered interior image generation with 4 modes.

Region Edit API

Masked inpainting โ€” regenerate a painted zone in a room image.

VR World Generation

Generate 3D Gaussian Splat worlds from interior images via WorldLabs Marble.

PBR Maps (AR)

Generate PBR texture maps for AR preview rendering.

AI Re-rank API

Claude-powered search result re-ordering for improved relevance.

Knowledge Base APIs

KB Embedding Generation

Voyage AI 1024D embedding generation for Knowledge Base documents.

Pinterest Integration

Pinterest OAuth

Pinterest account linking with board/pin access.

Pinterest Import

Import pins into moodboards (works pre-OAuth via oEmbed).

SEO Pipeline (admin/owner only)

Complete SEO content generation pipeline โ€” 5 functions, all POST + JWT.

Function Purpose
seo-research DataForSEO keyword research (6 parallel API calls)
seo-plan Article structure + meta tags + FAQ schema
seo-write Full article via Claude Sonnet
seo-analyze 15+ SEO quality checks, auto-fix via Gemini
seo-pipeline Orchestrator: research โ†’ plan โ†’ write โ†’ analyze

Surfaced to the kai agent as sub-agent tools (admin-gated).

Social Media APIs

Late.dev Social API

Social media OAuth, publishing, analytics, and content generation.

Payment APIs

CRM Stripe API

Subscriptions and credit purchases via Stripe.

Stripe Webhooks API

Stripe webhook event handling for subscriptions and payments.

Background Processing APIs

Background Agent Runner

Universal executor for all background agent types.

SLIG Inference

SigLIP2 visual embedding generation.

Cron / Scheduled Functions (service-role only)

Not user-callable. pg_cron invokes these on a schedule. No auth header from frontend โ€” they use SUPABASE_SERVICE_ROLE_KEY.

Function Schedule Purpose
agent-scheduler-cron 1 min Dispatch background agents whose cron is due
auto-recovery-cron 5 min Re-dispatch stuck runs (>8 min no heartbeat, <3 attempts)
job-cleanup-cron weekly Purge old jobs, logs, stale progress
flow-scheduler-cron 1 min Run due scheduled flows
ai-pricing-updater weekly Sync AI model pricing into ai_model_pricing
campaign-processor 1 min Email campaign dispatcher (Resend, 8/min)
check-material-alerts daily Run saved searches + email subscribers
scheduled-import-runner 5 min Run due XML imports
messaging-processor 1 min SMS/WhatsApp batch sender (Twilio, 10/batch)

Admin / Maintenance

Platform Reset

Wipe derived data while preserving accounts/KB/CRM/prompts.

Health Check

Aggregated health status across AI providers + MIVAA + external APIs.

Field Templates

Reusable field-mapping templates for XML/scraping imports.

Suggest Fields

AI-suggested field mappings from HTML analysis.

Authentication

Most APIs require authentication via Supabase Auth:

Authorization: Bearer <supabase_access_token>

Getting an Access Token

import { supabase } from '@/integrations/supabase/client';

const { data: { session } } = await supabase.auth.getSession();
const accessToken = session?.access_token;

Using the API

// Using Supabase client (recommended)
const { data, error } = await supabase.functions.invoke('email-api', {
  body: {
    action: 'send',
    to: 'user@example.com',
    subject: 'Hello',
    html: '<p>Hello World</p>'
  }
});

// Using fetch
const response = await fetch(
  'https://bgbavxtjlbvgplozizxu.supabase.co/functions/v1/email-api',
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      action: 'send',
      to: 'user@example.com',
      subject: 'Hello',
      html: '<p>Hello World</p>'
    })
  }
);

Error Handling

All APIs return errors in a consistent format:

{
  success: false,
  error: string,
  code?: string,
  details?: object
}

Common HTTP Status Codes

Rate Limiting

Default rate limits apply to all APIs:

CORS

All APIs support CORS with the following headers:

Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: authorization, x-client-info, apikey, content-type
Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, PATCH

Related Documentation

Support

For API support or questions: