Takazudo Modular Docs

Type to search...

to open search from anywhere

Admin Notify Archive

Admin Notify Archive

Bulk archive notify subscriptions. Archived records retain their original status but are excluded from the main list.

Endpoint

POST /api/admin/notify/archive

Authentication

Requires Bearer token authentication.

Authorization: Bearer <ADMIN_API_TOKEN>

Request

Headers

HeaderRequiredValue
Content-TypeYesapplication/json
AuthorizationYesBearer <token>

Body

interface AdminBulkArchiveRequest {
  ids: Array<{
    id: string;         // Subscription ID
    productSlug: string; // Product slug for the subscription
  }>;
}

Example Request

curl -X POST https://preview--takazudomodular.netlify.app/api/admin/notify/archive \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ADMIN_API_TOKEN" \
  -d '{
    "ids": [
      { "id": "mock-sub-001", "productSlug": "n32b-slim" },
      { "id": "mock-sub-002", "productSlug": "n32b-slim" }
    ]
  }'

Response

Success Response (200)

interface AdminBulkArchiveResponse {
  success: true;
  archivedCount: number;       // Number of successfully archived subscriptions
  archivedIds: string[];       // IDs that were successfully archived
  errors?: Array<{             // Optional: any errors that occurred
    id: string;
    error: string;
  }>;
}

Example Success Response

{
  "success": true,
  "archivedCount": 2,
  "archivedIds": ["mock-sub-001", "mock-sub-002"]
}

Partial Success Response

When some items fail to archive:

{
  "success": true,
  "archivedCount": 1,
  "archivedIds": ["mock-sub-001"],
  "errors": [
    { "id": "mock-sub-999", "error": "Subscription not found" }
  ]
}

Error Responses

Validation Error (400)

{
  "success": false,
  "error": "ids array is required"
}
{
  "success": false,
  "error": "ids array cannot be empty"
}

Authentication Error (401)

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

Behavior

  1. Validates the request body contains a non-empty ids array
  2. Iterates through each subscription ID
  3. Sets isArchived: true and archivedAt timestamp on each subscription
  4. Preserves the original status (pending, notified, unsubscribed) for historical reference
  5. Returns summary of archived items and any errors

Data Model

After archiving, a subscription looks like:

interface NotifySubscription {
  id: string;
  email: string;
  productSlug: string;
  createdAt: string;
  status: 'pending' | 'notified' | 'unsubscribed';  // Original status preserved
  notifiedAt?: string;
  isArchived: true;           // Added on archive
  archivedAt: string;         // ISO timestamp when archived
}