Skip to content

API reference

Base URL: the value of BASE_URL, for example https://api.example.com.

All responses are small. Browser-facing links redirect to pages on the static site (SITE_URL); the form endpoint returns JSON errors.

Starts a subscription and sends a confirmation email.

Request (Content-Type: application/json, body at most 4 KiB):

{ "email": "reader@example.com", "list": "newsletter", "website": "" }
FieldRequiredNotes
emailyesTrimmed and lower-cased. A bare address only; Name <a@b.c> is rejected
listyesMust be one of the configured LISTS
websitenoHoneypot. Leave empty; keep the input hidden from humans

Responses:

StatusMeaning
202 AcceptedAccepted. Also returned for already-confirmed addresses and honeypot hits, on purpose
400 Bad RequestMalformed JSON, oversized body, invalid email or unknown list. Body: {"error":"..."}
500 Internal Server ErrorStorage or email failure. Body: {"error":"internal error"}

Linked from the confirmation email. Confirms the subscription.

OutcomeResponse
Success, or already confirmed303 to SITE_URL/newsletter/confirmed/
Invalid, expired, wrong-purpose token, or the address has since unsubscribed303 to SITE_URL/newsletter/invalid/
Storage failure500 internal error

Linked from newsletters. Unsubscribes the address; idempotent.

OutcomeResponse
Success, or the address is unknown303 to SITE_URL/newsletter/unsubscribed/
Invalid or expired token303 to SITE_URL/newsletter/invalid/
Storage failure500 internal error

The service can create these links with Service.UnsubscribeURL(email, list); nothing calls it yet because newsletter sending is not implemented.

Returns 200 with an empty body. Use it for uptime checks.

Requests whose Origin header equals SITE_URL get Access-Control-Allow-Origin. Preflight OPTIONS requests from that origin receive 204 with Access-Control-Allow-Methods: POST, Access-Control-Allow-Headers: Content-Type and Access-Control-Max-Age: 600. Other origins get no CORS headers, so browsers block them.

Terminal window
curl -i -X POST https://api.example.com/v1/subscribe \
-H 'Content-Type: application/json' \
-H 'Origin: https://example.com' \
-d '{"email":"reader@example.com","list":"newsletter"}'