Register a browser for push notifications
const url = 'https://foxleague.ai/api/push/subscribe';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"auth":"example","endpoint":"example","p256dh":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://foxleague.ai/api/push/subscribe \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "auth": "example", "endpoint": "example", "p256dh": "example" }'Stores this browser’s push subscription for you, so your new notifications reach it as browser notifications while the app is closed. Subscribe in the browser with the key from GET /api/push/vapid-key, then send the subscription here. Only the push services of Chrome, Edge, Firefox and Safari are accepted. You keep at most 10 browsers: the oldest goes when you add another. Sending the same browser again renews it.
Who: a signed-in player.
Refusals:
This browser's notification service is not supported. Notifications work in Chrome, Edge, Firefox and Safari.:endpointis not a browser push service or a key is longer than 256 characters.Not registered: the wallet has no account.This browser already receives notifications for another account.: another account registered this endpoint. The answer carriescode: "push_endpoint_in_use"; renew the browser subscription and send the new one.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”A browser push subscription.
object
The subscription’s auth key, at most 256 characters.
The push service address of the browser subscription.
The subscription’s p256dh key, at most 256 characters.
Example generated
{ "auth": "example", "endpoint": "example", "p256dh": "example"}Responses
Section titled “ Responses ”Success or a refusal: read success (the refusals are in the description).
The answer of a request that returns no data. POST /api/tournaments/{id}/delete answers its refusals with it: success is false and error says why.
object
A machine-readable reason next to error, set only where the caller must act differently.
Always null on success: the route returns no data.
Why the request was refused, in plain words. Present when success is false.
true when the request did what it asked. false is a refusal: read error.
Example
{ "data": null, "success": true}No valid session. The body is plain text: Missing Authorization header, Invalid Authorization format, Invalid session token or Session expired or invalid. Sign in again.
Example
Session expired or invalid