Takazudo Modular Docs

Type to search...

to open search from anywhere

POST /api/admin-notify-status

POST /api/admin-notify-status

Update the status of a notify subscription.

Request

Method

POST

Headers

HeaderValue
AuthorizationBearer {ADMIN_API_TOKEN}
Content-Typeapplication/json

Body

{
  "id": "ntf_1706889600000-a1b2c3",
  "productSlug": "oxi-one-mk2",
  "status": "notified"
}

Parameters

FieldTypeRequiredDescription
idstringYesSubscription ID to update
productSlugstringYesProduct slug (used for blob key lookup)
statusstringYesNew status: pending, notified, unsubscribed

Response

Success (200)

{
  "success": true,
  "subscription": {
    "id": "ntf_1706889600000-a1b2c3",
    "email": "user@example.com",
    "productSlug": "oxi-one-mk2",
    "status": "notified",
    "createdAt": "2024-02-02T10:00:00.000Z",
    "notifiedAt": "2024-02-05T14:30:00.000Z"
  }
}

Status Transitions

FromToSide Effects
pendingnotifiedSets notifiedAt to current timestamp
pendingunsubscribedNone
notifiedpendingClears notifiedAt (sets to null)
AnyAnyStatus is updated

Not Found (404)

{
  "success": false,
  "error": "Subscription not found"
}

Validation Error (400)

{
  "success": false,
  "error": "Missing required fields: id, productSlug, status"
}

Unauthorized (401)

{
  "success": false,
  "error": "Unauthorized"
}

Example

cURL

# Mark as notified
curl -X POST https://takazudomodular.com/api/admin-notify-status \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "ntf_1706889600000-a1b2c3",
    "productSlug": "oxi-one-mk2",
    "status": "notified"
  }'

# Reset to pending
curl -X POST https://takazudomodular.com/api/admin-notify-status \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "ntf_1706889600000-a1b2c3",
    "productSlug": "oxi-one-mk2",
    "status": "pending"
  }'

JavaScript (fetch)

const response = await fetch('/api/admin-notify-status', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${ADMIN_API_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    id: 'ntf_1706889600000-a1b2c3',
    productSlug: 'oxi-one-mk2',
    status: 'notified',
  }),
});

const data = await response.json();

if (data.success) {
  console.log('Updated subscription:', data.subscription);
}

Implementation Details

Source File

netlify/functions/admin-notify-status.ts

Behavior

  1. Validates Bearer token authentication
  2. Validates required fields (id, productSlug, status)
  3. Fetches existing subscription from Netlify Blobs
  4. Updates status field
  5. Handles notifiedAt timestamp:
  • Sets to current time when status becomes notified
  • Clears (sets to null) when status becomes pending
  1. Saves updated subscription
  2. Returns the updated subscription object

Storage Key

Subscriptions are stored with the key format: notify/{productSlug}/{id}