Takazudo Modular Docs

Type to search...

to open search from anywhere

POST /api/notify-signup

POST /api/notify-signup

Register email for product availability notifications (“Notify Me” feature).

Request

Method

POST

Headers

HeaderValue
Content-Typeapplication/json

Body

{
  "email": "user@example.com",
  "productSlug": "oxi-one-mk2"
}

Parameters

FieldTypeRequiredDescription
emailstringYesUser’s email address
productSlugstringYesProduct 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

  1. Validates email format
  2. Validates productSlug format (lowercase alphanumeric with hyphens)
  3. Checks for duplicate subscriptions (case-insensitive email)
  4. Normalizes email to lowercase
  5. Stores subscription in Netlify Blobs
  6. 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
  1. 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. :::