prufy
Skip to the page

AlertsSubscribe a browser to push

Alerts

Subscribe a browser to push

Register a browser's push subscription, so alerts arrive as notifications.

POST/api/v1/notifications/push

The body is what PushManager.subscribe() returns, made with the key in capabilities.pushPublicKey. Only endpoints at the push services browsers actually use are accepted.

Subscribing the same endpoint twice keeps one subscription.

Authentication

Send the session cookie. Without it the answer is unauthorized. How sessions work.

Body

JSON, with content-type: application/json.

  • endpointURLrequired

    The push service's address for this browser.

    • At most 2,000 characters
  • keysobjectrequired

    The subscription's keys, as the browser gives them.

    Show the 2 fields insideInside keys
    • p256dhstring

      The browser's public key.

      • At most 256 characters
    • authstring

      The browser's authentication secret.

      • At most 128 characters

Response

200 OK, with every field below present. Times are ISO 8601 strings in UTC.

  • emailobject | null

    The alert address. Null when none is set.

    Show the 2 fields insideInside email
    • addressstring

      Where alert emails go.

    • verifiedboolean

      False until the confirmation link has been used.

  • pushDevicesinteger

    How many browsers are subscribed to push.

  • capabilitiesobject

    Which channels this server can use.

    Show the 2 fields insideInside capabilities
    • emailboolean

      Whether this server can send email at all.

    • pushPublicKeystring | null

      The key a browser subscribes with. Null when push is off.

Errors

StatusKindWhen
400bad_requestThe body doesn't match the shape below, or the endpoint isn't a push service we recognise.
401unauthorizedThe request has no session cookie, or one we don't recognise.
503push_unavailableThis server has no push keys set up.

Any route can also answer 500 with internal_error. Every error has the same shape, described in Errors.