Skip to main content
Send transactional emails for user verification and notifications using the Resend email service.

Endpoint

POST /api/email

Authentication

This endpoint requires the RESEND_TOKEN environment variable to be configured on the server.
This is an internal endpoint typically called by the signup flow. Production applications should add authentication and rate limiting.

Request

Body parameters

email
string
required
The recipient’s email address
subject
string
required
The email subject line
url
string
required
The verification URL to include in the email (typically contains the verification token)

Response

Success response

message
string
Success message: “Email sent”
data
object
Response data from Resend API containing the email ID
Status code: 200 OK

Error responses

error
string
Error description
message
object
Additional error details from Resend (when applicable)
Status codes: 400 Bad Request

Examples

Send verification email

curl -X POST https://your-domain.com/api/email \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "subject": "Verify your Noteverse account",
    "url": "https://your-domain.com/verify?token=abc123"
  }'

Success response

{
  "message": "Email sent",
  "data": {
    "id": "re_abc123xyz"
  }
}

Error responses

Missing email

{
  "error": "Email is required"
}

Missing verification URL

{
  "error": "Verification ID is required"
}

Resend API error

{
  "error": "Error sending email",
  "message": {
    "statusCode": 422,
    "message": "Invalid email address"
  }
}

Email template

The verification email uses a custom React Email template (VerificationEmail) that includes:
  • Noteverse branding
  • Clear call-to-action button
  • Verification URL link
  • Professional styling
The email is rendered using @react-email/render before being sent through Resend.

Implementation details

// From src/app/api/email/route.ts:31-36
const response = await resend.emails.send({
  from: 'Noteverse <noteverse@falah.in>',
  to: [email],
  subject: subject,
  html: emailHtml,
})
  • Sender: Noteverse <noteverse@falah.in>
  • Service: Resend email API
  • Format: HTML rendered from React components
  • Runtime: Next.js API route
Configure your Resend account and verify the sender domain before using this endpoint in production.

Use cases

  • Email verification: Send verification links to new users after signup
  • Password reset: Send password reset links (requires additional implementation)
  • Notifications: Send important account notifications

Security considerations

This endpoint does not verify the caller’s identity. In production:
  • Add authentication to prevent abuse
  • Implement rate limiting per email address
  • Validate email addresses before sending
  • Use environment-specific sender addresses

See also

Signup endpoint

See how signup triggers verification emails

Verify endpoint

Complete the verification flow

Environment variables

Configure RESEND_TOKEN

Authentication

Learn about the full auth flow

Build docs developers (and LLMs) love