Skip to main content

POST /api/onboarding-v2

End-to-end automation entry point for new companies. Invoked when the onboarding form at my.reformer.la/onboarding completes. The endpoint pulls everything from Supabase, ensures the account/member records exist, and then executes the full automation cascade via services/automation-orchestrator.js.

Request

Content-Type: application/json

{
"email": "client@example.com",
"companyName": "Client Co",
"companyUrl": "https://client.co",
"phone": "+1-555-111-2222",
"location": "Los Angeles, CA",
"timezone": "America/Los_Angeles",
"plan": "growth",
"metadata": {
"referrer": "landing-page"
}
}

Accepted aliases:

  • company_name, company, businessName
  • company_url, website, domain
  • phone_number
  • city_state, city
  • time_zone

Required fields: email, companyName

Response

Success (200)

{
"success": true,
"accountId": "uuid",
"portalSlug": "client-co",
"integrations": {
"clickup": "success",
"dropbox": "success",
"resend": "success",
"slack": "success",
"close": "success"
}
}

Failure (4xx/5xx)

400 Missing required fields
500 Internal error (integration failures reported individually)

Workflow

  1. Member lookup / create
    • Query Supabase-backed members table.
    • If missing, create accounts + members entries with status='provisioning'.
  2. Company metadata update
    • Update accounts with latest contact info.
  3. Ensure Supabase integration record
    • Creates integration row with generated webhook secret.
  4. Portal slug assignment
    • Calls ensurePortalSlug to maintain unique dashboard URLs.
  5. Automation orchestrator
    • Creates ClickUp project structure (services/clickup-service.js).
    • Creates Dropbox folder tree at /Reformer General/Reformer Clients Folder/{normalized-slug} with all 10 subdirectories.
    • Stores Dropbox link in members.dropbox_link for client portal access.
    • Sends Resend onboarding emails (primary email service).
    • Posts Slack notifications.
    • Updates Close CRM lead record.
    • (Future) triggers analytics setup and additional integrations.

Enhanced Onboarding API

The /api/onboarding/enhanced endpoint includes additional steps:

  1. Account Creation - Creates account and member records
  2. Dropbox Folder Creation (Step 1.5) - Creates standardized folder structure
  3. PageSpeed Analysis - Analyzes client website performance
  4. Content Scraping - Scrapes website content for analysis
  5. CSV Upload - Uploads scraped content to Dropbox
  6. Close CRM Update - Updates CRM with client information
  7. Slack Notification - Notifies team of new client

Dropbox Folder Structure:

  • Path: /Reformer General/Reformer Clients Folder/{normalized-slug}
  • Automatically creates 10 standardized subdirectories
  • Generates shared link and stores in members.dropbox_link
  • Link is available in client portal after onboarding completes

If any integration fails, the endpoint returns success: false with the error details, and the orchestrator logs the failure for follow-up.

Required Environment Variables

  • DATABASE_URL – Supabase Postgres connection.
  • CLICKUP_* – All ClickUp space/list IDs and API key.
  • DROPBOX_ACCESS_TOKEN
  • SLACK_WEBHOOK_URL
  • RESEND_API_KEY (primary email service).
  • CLOSE_API_KEY
  • CURSOR_API_KEY (if automation triggers Cloud Agents).

Confirm all variables are set in Render before enabling production runs. See reformer-platform/ENV-TEMPLATE.md.

Testing

  • Trigger manually with curl:
curl -X POST https://reformer-platform.onrender.com/api/onboarding-v2 \
-H "Content-Type: application/json" \
-d '{"email":"test+onboarding@reformer.la","companyName":"Test Co"}'
  • Verify ClickUp folder under Client Projects space.
  • Confirm Dropbox folder (/Clients/test-co).
  • Check Slack #engineering (or dedicated channel) for notifications.
  • Inspect Supabase accounts, members, integrations tables.

Automated regression tests are planned for the orchestrator; for now, rerun this endpoint with staging credentials when significant integration code changes.***