This file provides practical examples for using the email notification system.
curl -X POST http://localhost:3001/api/email/config \
-H "Content-Type: application/json" \
-d '{
"enabled": "true",
"smtp_host": "smtp.gmail.com",
"smtp_port": "587",
"smtp_secure": "false",
"smtp_user": "[email protected]",
"smtp_password": "your-app-password",
"from_address": "[email protected]",
"from_name": "Tattoo Workshop Studio",
"reminders_enabled": "true"
}'Important for Gmail:
- You must create an App Password
- Regular Gmail password won't work
- Enable 2-factor authentication first
curl -X POST http://localhost:3001/api/email/test \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]"}'Expected response:
{"success": true}First, create a customer:
curl -X POST http://localhost:3001/api/customers \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "[email protected]",
"phone": "555-1234",
"address": "123 Main St",
"notes": "First time customer"
}'Then create an appointment (this automatically sends a confirmation email):
curl -X POST http://localhost:3001/api/appointments \
-H "Content-Type: application/json" \
-d '{
"customer_id": 1,
"artist_name": "Mike Smith",
"appointment_date": "2025-10-20T14:00:00",
"duration": 120,
"notes": "Sleeve design consultation"
}'curl -X PUT http://localhost:3001/api/appointments/1 \
-H "Content-Type: application/json" \
-d '{
"artist_name": "Mike Smith",
"appointment_date": "2025-10-25T15:00:00",
"duration": 120,
"status": "scheduled",
"notes": "Sleeve design consultation - rescheduled"
}'This will send a rescheduling email showing both old and new dates.
curl -X PUT http://localhost:3001/api/appointments/1 \
-H "Content-Type: application/json" \
-d '{
"artist_name": "Mike Smith",
"appointment_date": "2025-10-25T15:00:00",
"duration": 120,
"status": "cancelled",
"notes": "Customer request"
}'curl http://localhost:3001/api/email/notifications | jq '.'This shows all sent emails with:
- Customer information
- Email type (confirmation, reminder_24h, reminder_1week, cancellation, rescheduled)
- Recipient email
- Status (sent)
- Timestamp
Get current template:
curl http://localhost:3001/api/email/templates/appointment_confirmation | jq '.'Update template:
curl -X PUT http://localhost:3001/api/email/templates/appointment_confirmation \
-H "Content-Type: application/json" \
-d '{
"subject": "Your Tattoo Appointment is Confirmed! 🎨",
"body": "<!DOCTYPE html><html>...custom HTML...</html>"
}'curl -X POST http://localhost:3001/api/email/config \
-H "Content-Type: application/json" \
-d '{
"enabled": "true",
"smtp_host": "smtp.sendgrid.net",
"smtp_port": "587",
"smtp_secure": "false",
"smtp_user": "apikey",
"smtp_password": "SG.your-sendgrid-api-key",
"from_address": "[email protected]",
"from_name": "Tattoo Workshop",
"reminders_enabled": "true"
}'curl -X POST http://localhost:3001/api/email/config \
-H "Content-Type: application/json" \
-d '{
"enabled": "false",
"reminders_enabled": "false"
}'curl http://localhost:3001/api/email/config | jq '.'Note: Password is never returned for security.
Here's a complete test workflow:
#!/bin/bash
# 1. Configure email
curl -X POST http://localhost:3001/api/email/config \
-H "Content-Type: application/json" \
-d '{
"enabled": "true",
"smtp_host": "smtp.gmail.com",
"smtp_port": "587",
"smtp_secure": "false",
"smtp_user": "[email protected]",
"smtp_password": "your-app-password",
"from_address": "[email protected]",
"from_name": "Test Studio",
"reminders_enabled": "true"
}'
# 2. Test email
curl -X POST http://localhost:3001/api/email/test \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]"}'
# 3. Create customer
curl -X POST http://localhost:3001/api/customers \
-H "Content-Type: application/json" \
-d '{
"name": "Test Customer",
"email": "[email protected]",
"phone": "555-0000"
}'
# 4. Create appointment (sends confirmation)
curl -X POST http://localhost:3001/api/appointments \
-H "Content-Type: application/json" \
-d '{
"customer_id": 1,
"artist_name": "Test Artist",
"appointment_date": "2025-10-20T14:00:00",
"duration": 60,
"notes": "Test appointment"
}'
# 5. Check notification log
curl http://localhost:3001/api/email/notifications# View notification log
curl http://localhost:3001/api/email/notifications | jq '.[] | {type: .type, recipient: .recipient, status: .status, sent_at: .sent_at}'# Get current config
curl http://localhost:3001/api/email/config | jq '.'
# Check specific setting
curl http://localhost:3001/api/email/config | jq '.enabled'# Send to specific address
curl -X POST http://localhost:3001/api/email/test \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]"}'Use these variables in your custom templates:
For confirmations:
{{customer_name}}{{appointment_date}}{{appointment_time}}{{artist_name}}{{duration}}{{notes}}
For reminders:
- Same as confirmations, plus:
{{reminder_period}}- "24 hours" or "1 week"
For rescheduling:
{{customer_name}}{{old_appointment_date}}{{old_appointment_time}}{{new_appointment_date}}{{new_appointment_time}}{{artist_name}}
For cancellations:
{{customer_name}}{{appointment_date}}{{appointment_time}}{{artist_name}}