POST /api/notify-signup
POST /api/notify-signup
Register email for product availability notifications (“Notify Me” feature).
Request
Method
POST
Headers
| Header | Value |
|---|---|
| Content-Type | application/json |
Body
{
"email": "user@example.com",
"productSlug": "oxi-one-mk2"
}
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
email | string | Yes | User’s email address |
productSlug | string | Yes | Product identifier (must exist in product data) |
Response
Success (200)
{
"success": true,
"message": "登録完了"
}
Validation Error (400)
{
"success": false,
"error": "入力内容に問題があります",
"details": [{ "field": "email", "message": "有効なメールアドレスを入力してください" }]
}
Product Not Found (400)
{
"success": false,
"error": "指定された商品が見つかりません"
}
Server Error (500)
{
"success": false,
"error": "サーバーエラーが発生しました"
}
Example
cURL
curl -X POST https://takazudomodular.com/api/notify-signup \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "productSlug": "oxi-one-mk2"}'
JavaScript (fetch)
const response = await fetch('/api/notify-signup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'user@example.com',
productSlug: 'oxi-one-mk2',
}),
});
const data = await response.json();
if (data.success) {
console.log('Signup successful:', data.message);
} else {
console.error('Signup failed:', data.error);
}
Implementation Details
Source File
netlify/functions/notify-signup.ts
Behavior
- Validates email format
- Validates productSlug format (lowercase alphanumeric with hyphens)
- Checks for duplicate subscriptions (case-insensitive email)
- Normalizes email to lowercase
- Stores subscription in Netlify Blobs
- Sends notifications in parallel (non-blocking, failures don’t affect response):
- Slack (restock channel): Full details (product, email, timestamp) for shop management
- Discord (public channel): Product name + URL only (no private info) — customers can see trending products
- Auto-reply email: Confirmation email to the user via Resend
- Returns success response
Email Normalization
Emails are normalized to lowercase before storage and duplicate checking. This means User@Example.com and user@example.com are treated as the same email.
Duplicate Handling (Silent Success)
If the same email is already subscribed to notifications for a product, the API returns success without creating a duplicate record:
{
"success": true,
"message": "登録完了"
}
:::info Why Silent Success? Users may not remember if they’ve already signed up. Returning an error for duplicates creates confusion - all they want is to receive the notification. Silent success provides a better user experience: the user is assured they’ll be notified, regardless of whether they’re a new or existing subscriber. :::
Related
- POST /api/reservation - Full product reservation
- Webhook Notifications - Slack and Discord integration details
- Email Service - Resend email configuration