# Web push

## Retrive VAPID public key

<mark style="color:blue;">`GET`</mark> `https://muni-portal-backend.openup.org.za/api/webpush/public-key/`

Get the value to use in the `applicationServerKey`in PushManager.subscribe()

#### Headers

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| HTTP\_AUTHORIZATION | string | Bearer JWT.TOKEN |

{% tabs %}
{% tab title="200 " %}

```
{"vapid_public_key": "abcdef"}
```

{% endtab %}
{% endtabs %}

## Create web push subscription object

<mark style="color:green;">`POST`</mark> `https://muni-portal-backend.openup.org.za/api/webpush/subscription/`

Create a new subscription object for the user identified by the provided token.

#### Headers

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| HTTP\_AUTHORIZATION | string | Bearer JWT.TOKEN |

#### Request Body

| Name                 | Type   | Description                             |
| -------------------- | ------ | --------------------------------------- |
| subscription\_object | object | The result of PushSubscription.toJSON() |

{% tabs %}
{% tab title="201 Web push record saved successfully" %}

```
```

{% endtab %}

{% tab title="400 Web push object is invalid" %}

```
```

{% endtab %}
{% endtabs %}
