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.
| Field | Type | Required | Notes |
|---|---|---|---|
endpoint | string | required | uri · 0–2048 chars |
expirationTime | number | null | optional | |
keys | object | required | |
keys.p256dh | string | required | 80–100 chars |
keys.auth | string | required | 16–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
| Field | Type | Required | Notes |
|---|---|---|---|
id | string | required |
Errors#
Every error is {"error":{"code","message","hint","docUrl","requestId"}}: branch on code. See Errors.
| Status | Code | Meaning |
|---|---|---|
| 400 | bad_request | The request is malformed or a field is invalid (see issues). |
| 400 | unknown_field | The body has a field the endpoint doesn't know (often a typo or snake_case). |
| 401 | unauthorized | No credentials, or the API key or session is invalid or revoked. |
| 403 | forbidden | The caller is authenticated but may not do this (wrong role, or an API key on a human-only endpoint). |
| 500 | internal_error | Something went wrong on Logu's side. |
| 503 | service_unavailable | A dependency is down or a feature isn't configured on this server. |