/v1/unsubscribe
Project auth (?project= query param or X-LitePush-Project header). See Concepts → Authentication.
POST /v1/unsubscribe
What it does: Flips a subscriber's status to 'unsubscribed' so we stop sending pushes to that endpoint. The row stays in the database (preserves analytics history and lets the same user re-opt-in later without losing their event history).
When to use it: Almost never. The SDK's litepush.unsubscribe() calls this when the user opts out, and the service worker beacons it on pushsubscriptionchange (when the browser invalidates the subscription). For hard-delete (GDPR erasure that wipes the row), use /v1/subscribers instead.
Authentication: Project — ?project= query param or X-LitePush-Project header.
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
endpoint | string (URL, ≤ 2048 chars) | yes | The push endpoint URL to unsubscribe. Same value used at POST /v1/subscribe. |
Example:
curl -X POST 'https://api.litepush.dev/v1/unsubscribe?project=prj_xxxxxxxx' \
-H "Content-Type: application/json" \
-d '{ "endpoint": "https://fcm.googleapis.com/fcm/send/cZxJ..." }'
Success — 200 OK:
{ "ok": true }
Returns 200 even when the endpoint isn't on file — the operation is idempotent (you can't tell "already unsubscribed" from "never subscribed", and neither matters operationally).
Errors:
400 missing_project— no project param/header.404 project_not_found— project doesn't exist.429 rate_limited.