Get the web push public key
push.config
GET/api/v1/push/config
- Route
The server's VAPID public key, to pass to pushManager.subscribe as applicationServerKey. public_key is null when push isn't set up on this server; notifications are still recorded and shown in the app, and the device toggle should say so.
Response#
200 The key, or null.
| Field | Description |
|---|---|
public_keystring or nullrequired | The VAPID public key, base64url, or null when push isn't set up on this server. |
Errors#
Every error has the same envelope: error.code, error.message, error.details, error.recovery and error.request_id.
| Status | Code | When |
|---|---|---|
401 | Read error.code | Described above. |
401 | unauthenticated | The request has no valid session. |
Examples#
These are real. Each was recorded from a sample household, the Okafors, running through the whole API when this site was built.
Get the web push key
The public key to pass to pushManager.subscribe as applicationServerKey.
Request, curl
curl 'https://rigel.house/api/v1/push/config' \
-H "Cookie: rigel_session=$RIGEL_SESSION"Request, TypeScript
const response = await fetch("https://rigel.house/api/v1/push/config", {
headers: {
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
});
const data = await response.json();Request, HTTP
GET /api/v1/push/config HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>Response, 200
HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CST985WH9EXN3J7ZBCK1
{
"public_key": "BJRFf_3iiRZ-zv1SNI1qwOxLwQzTmSQYIlPqaAkmG2r0XGaTN73u0NRwCt5LwPkW-VP8CN1QtNEr17FVR3n7Fhc"
}