Newsletter Signup API

Email signup endpoint with flexible metadata storage and admin management.

Features

  • Public signup endpoint - POST /subscribe
  • Protected admin endpoints - List, update, and delete subscribers
  • Flexible metadata - details field accepts any JSON
  • Developer notes - Internal annotations per subscriber
  • Duplicate emails allowed - De-duplicate downstream as needed
  • SQLite storage - Timestamps for created/updated
  • CORS enabled

Setup

Set the ADMIN_API_KEY environment variable to protect admin endpoints.

Endpoints

MethodPathAuthDescription
POST/subscribePublicSubmit a signup
GET/subscribersAPI KeyList all subscribers
PUT/subscribers/:idAPI KeyUpdate details or notes
DELETE/subscribers/:idAPI KeyRemove a subscriber

Usage

Subscribe (public):

curl -X POST https://YOUR_ENDPOINT/subscribe \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "details": {"any": "json"}}'

Admin requests:

curl https://YOUR_ENDPOINT/subscribers \ -H "X-API-Key: your-admin-key"

Schema

ColumnTypeDescription
idINTEGERAuto-incrementing primary key
emailTEXTSubscriber email
detailsTEXTJSON metadata (flexible)
developer_notesTEXTInternal notes
created_atTEXTSubmission timestamp
updated_atTEXTLast update timestamp