Skip to main content

POST /webhooks/send-onboarding-email

Handles Notion database automation webhooks to send onboarding emails via Loops.

Purpose

This webhook is triggered by Notion automations when a CRM card’s status changes to β€œSend Email”. It:
  1. Receives the webhook payload from Notion
  2. Extracts the email address
  3. Sends an onboarding email via Loops transactional API

Architecture

Notion Payload Structure

The webhook expects a Notion automation payload with this structure:
{
  "data": {
    "properties": {
      "Email": {
        "title": [
          {
            "text": {
              "content": "[email protected]"
            }
          }
        ]
      }
    }
  }
}

Environment Variables

VariableDescription
LOOPS_API_KEYLoops API authentication key
LOOPS_TRANSACTIONAL_IDID of the transactional email template

Loops Integration

The endpoint sends a transactional email via Loops:
  • Uses the configured transactional template
  • Automatically adds recipient to audience
  • Timeout: 10 seconds

Response

Success (200)

{
  "success": true,
  "message": "Onboarding email sent to [email protected]"
}

Error (400/500)

{
  "detail": "Error message"
}

Code Location

src/app/webhooks/notion_webhook/routes.py