# Add Player ID to push notification

### Description

This service associates a `playerId` with the logged-in consumer for a specific application. This is typically used to register a device or user for push notification services (like OneSignal or similar providers).

***

### Request

#### Restrictions

This service requires an authenticated user and can only be called when a consumer is logged in.

#### Endpoint

```
PUT https://<server-url>/api/v4/communications/push-notifications/{appId}/player-id
```

#### Path Parameters

| **Parameter** | **Type** | **Description**                                                             |
| ------------- | -------- | --------------------------------------------------------------------------- |
| `appId`       | String   | The unique identifier for the push notification application (e.g., a UUID). |

#### Parameters

| **Parameter**  | **Location**   | **Description**                                                                    |
| -------------- | -------------- | ---------------------------------------------------------------------------------- |
| `touchpoint`   | Query / Header | The identifier for the touchpoint. Use `Thalamus-Touchpoint` for the header.       |
| `token`        | Query / Header | The authentication token for the API session. Use `Thalamus-Token` for the header. |
| `Content-Type` | Header         | Must be `application/json`.                                                        |

#### Full URL Example

```
https://<server-url>/api/v4/communications/push-notifications/f7d95316-198f-4f4f-a5b4-5fda8d77b9bb/player-id?touchpoint=test&token=...
```

#### Request Body

The request body must contain the `playerId` string provided by the push notification service.

| **Field**  | **Type** | **Description**                                                   |
| ---------- | -------- | ----------------------------------------------------------------- |
| `playerId` | String   | The unique ID assigned to the player/device by the push provider. |

JSON

```
{
   "playerId": "14"
}
```

***

### Response

#### ✅ Successful Response: `200 OK`

Indicates the `playerId` was successfully associated with the user account.

JSON

```
{
   "OK"
}
```

#### ❌ Unsuccessful Response: `400 Bad Request`

Returned if the provided `playerId` is invalid or if the request is malformed.

JSON

```
{
    "Invalid push notification player id"
}
```
