Skip to content

Register a browser for push notifications

POST
/api/push/subscribe
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.: endpoint is 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 carries code: "push_endpoint_in_use"; renew the browser subscription and send the new one.
Media type application/json

A browser push subscription.

object
auth
required

The subscription’s auth key, at most 256 characters.

string
endpoint
required

The push service address of the browser subscription.

string
p256dh
required

The subscription’s p256dh key, at most 256 characters.

string
Example generated
{
"auth": "example",
"endpoint": "example",
"p256dh": "example"
}

Success or a refusal: read success (the refusals are in the description).

Media type application/json

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
code

A machine-readable reason next to error, set only where the caller must act differently.

string
data

Always null on success: the route returns no data.

error

Why the request was refused, in plain words. Present when success is false.

string
success
required

true when the request did what it asked. false is a refusal: read error.

boolean
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.

Media type text/plain
string
Example
Session expired or invalid