Skip to content

digital-identity-platform-docs


digital-identity-platform-docs / supabase/functions/create_custom_domain

supabase/functions/create_custom_domain

Creates a custom domain record for an SGTM container and returns DNS configuration instructions.

Cloudflare Architecture Context

AttributeValue
Classification🔵 BACKEND-ONLY
PositionApp Backend (domain setup)
Receives Public TrafficNo (dashboard only)
Latency SensitiveNo
Safe to RetryNo (creates database record)
Failure BehaviorFail-closed with error message

Overview

This Edge Function provisions a new custom domain for a container by creating a database record and generating A record DNS instructions for the user to configure at their domain registrar.

Endpoint

POST /functions/v1/create_custom_domain

Authentication

Service role (internal) - uses SUPABASE_SERVICE_ROLE_KEY.

Behavior

  • Validates required fields (sgtm_container_id, host, client_id)
  • Checks plan's max_custom_domains limit before allowing creation
  • Generates A record DNS instructions pointing to static IP
  • Inserts domain record with "pending" status
  • Returns DNS instructions and created domain record

Tables Touched

  • sgtm_containers (read)
  • custom_domains (read/write)
  • v_sgtm_container_modules_effective (read for plan limits)

Notes

  • Domain starts in "pending" status until DNS is verified
  • User must configure A record at their registrar manually
  • Respects plan's max_custom_domains limit

Released under proprietary license.