LoguDocs
Open Logu

Delivery · subscribeWebPush

Turn on browser notifications

POST /v1/web-push/subscriptions

Subscribes this browser (its PushSubscription.toJSON()). Re-subscribing an endpoint moves it to the signed-in member.

Who may call it
any signed-in human
Server
https://api.logu.dev

Request body#

Content type application/json (required).

A browser's PushSubscription.toJSON(). Strict.

FieldTypeRequiredNotes
endpointstringrequireduri · 0–2048 chars
expirationTimenumber | nulloptional
keysobjectrequired
keys.p256dhstringrequired80–100 chars
keys.authstringrequired16–32 chars
{
  "endpoint": "https://fcm.googleapis.com/fcm/send/c1KrmpTuRm4:APA91bGq3nYdF8wN2xH5kL7mP9rT1vY3zB6",
  "expirationTime": null,
  "keys": {
    "p256dh": "BOr0Wq5bNn7m3VPZqM2Qv2qYb4yLw8M3Kp5uR7tY9wA1cE3gH5jK7mN9pR1tV3xZ5bD7fH9kL1nP3rT5vX7zB9dF",
    "auth": "k8JV6sjdbhAi-n3Qzm2zqA"
  }
}

Example#

curl -s -X POST "https://api.logu.dev/v1/web-push/subscriptions" \
  -H "Authorization: Bearer $LOGU_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"endpoint":"https://fcm.googleapis.com/fcm/send/c1KrmpTuRm4:APA91bGq3nYdF8wN2xH5kL7mP9rT1vY3zB6","expirationTime":null,"keys":{"p256dh":"BOr0Wq5bNn7m3VPZqM2Qv2qYb4yLw8M3Kp5uR7tY9wA1cE3gH5jK7mN9pR1tV3xZ5bD7fH9kL1nP3rT5vX7zB9dF","auth":"k8JV6sjdbhAi-n3Qzm2zqA"}}'

Responses#

201

The subscription's id.

{
  "id": "wps_01K7DA3C5E7G9J1L3N5Q7S9U1W"
}
Response fields
FieldTypeRequiredNotes
idstringrequired

Errors#

Every error is {"error":{"code","message","hint","docUrl","requestId"}}: branch on code. See Errors.

StatusCodeMeaning
400bad_requestThe request is malformed or a field is invalid (see issues).
400unknown_fieldThe body has a field the endpoint doesn't know (often a typo or snake_case).
401unauthorizedNo credentials, or the API key or session is invalid or revoked.
403forbiddenThe caller is authenticated but may not do this (wrong role, or an API key on a human-only endpoint).
500internal_errorSomething went wrong on Logu's side.
503service_unavailableA dependency is down or a feature isn't configured on this server.