> For the complete documentation index, see [llms.txt](https://docs.codemash.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.codemash.io/dashboard/notifications/push/notifications.md).

# Push Notifications API

## Send Push Notification

<mark style="color:green;">`POST`</mark> `https://api.codemash.io/:version/notifications/push`

Send a mobile notification message.

#### Path Parameters

| Name    | Type   | Description                                             |
| ------- | ------ | ------------------------------------------------------- |
| version | string | The version of the API endpoint. Current latest **v1**. |

#### Headers

| Name           | Type   | Description                                            |
| -------------- | ------ | ------------------------------------------------------ |
| Authorization  | string | Your project's secret key.                             |
| x-cm-projectid | string | Your project's ID. Can be passed as a query parameter. |

#### Request Body

| Name            | Type    | Description                                                                                                                            |
| --------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| templateId      | string  | The ID of push notification template to use.                                                                                           |
| roles           | array   | Roles of users to set as recipients.                                                                                                   |
| users           | array   | An array of user IDs to be set as recipients.                                                                                          |
| devices         | array   | An array of device IDs to be set as recipients.                                                                                        |
| isNonPushable   | boolean | If set as true, creates a silent notification without popping up at the recipient's device.                                            |
| tokens          | object  | Key-value pair (string: string) object of custom tokens.                                                                               |
| postpone        | integer | Amount of milliseconds to postpone sending the notification.                                                                           |
| respectTimeZone | boolean | If creating a postponed notification and the recipient's devices have timezone set, then postpones according to the device's timezone. |

{% tabs %}
{% tab title="200 Returns an ID of created notification group." %}

```javascript
{
    Result: ""
}
```

{% endtab %}

{% tab title="401 Returns if the user does not have a valid permission to call this method." %}

```
```

{% endtab %}

{% tab title="500 " %}

```
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);

var response = await pushService.SendPushNotificationAsync(
    new SendPushNotificationRequest
    {
        TemplateId = Guid.Parse("{TEMPLATE_ID}"),
        Users = new List<string> { "{USER_ID}" }
    }
);
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;

class CodemashService
{
    protected CodemashPushNotification $codemashPushNotification;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $codemashPushNotification = new CodemashPushNotification($client);
    }
    
    public function sendPushNotification()
    {
        $responseData = $this->codemashPushNotification->sendNotification([
            'templateId' => '{TEMPLATE_ID}',
            'users' => [
                '{USER_ID}',
                '{USER_ID}',
                '{USER_ID}',
            ],
        ]);
    }
    
}
```

{% endtab %}
{% endtabs %}

## Get Notification

<mark style="color:blue;">`GET`</mark> `https://api.codemash.io/:version/notifications/push/:id`

Gets a push notification.

#### Path Parameters

| Name    | Type   | Description                                             |
| ------- | ------ | ------------------------------------------------------- |
| version | string | The version of the API endpoint. Current latest **v1**. |
| id      | string | The ID of a notification to get.                        |

#### Headers

| Name           | Type   | Description                                            |
| -------------- | ------ | ------------------------------------------------------ |
| Authorization  | string | Your project's secret key.                             |
| x-cm-projectid | string | Your project's ID. Can be passed as a query parameter. |

{% tabs %}
{% tab title="200 Returns an ID of created notification group." %}

```javascript
{
    Result: ""
}
```

{% endtab %}

{% tab title="401 Returns if the user does not have a valid permission to call this method." %}

```
```

{% endtab %}

{% tab title="500 " %}

```
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);

var response = await pushService.GetNotificationAsync(
    new GetNotificationRequest
    {
        Id = "{NOTIFICATION_ID}"
    }
);
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;

class CodemashService
{
    protected CodemashPushNotification $codemashPushNotification;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $codemashPushNotification = new CodemashPushNotification($client);
    }
    
    public function getNotification()
    {
        $responseData = $this->codemashPushNotification->getNotification([
            'id' => '{NOTIFICATION_ID}',
        ]);
    }
    
}
```

{% endtab %}
{% endtabs %}

## Get Notifications

<mark style="color:blue;">`GET`</mark> `https://api.codemash.io/:version/notifications/push`

Gets many push notifications.

#### Path Parameters

| Name    | Type   | Description                                             |
| ------- | ------ | ------------------------------------------------------- |
| version | string | The version of the API endpoint. Current latest **v1**. |

#### Query Parameters

| Name     | Type   | Description                                    |
| -------- | ------ | ---------------------------------------------- |
| userId   | string | The ID of a user whose notifications to get.   |
| deviceId | string | The ID of a device whose notifications to get. |

#### Headers

| Name           | Type   | Description                                            |
| -------------- | ------ | ------------------------------------------------------ |
| Authorization  | string | Your project's secret key.                             |
| x-cm-projectid | string | Your project's ID. Can be passed as a query parameter. |

{% tabs %}
{% tab title="200 Returns an ID of created notification group." %}

```javascript
{
    Result: ""
}
```

{% endtab %}

{% tab title="401 Returns if the user does not have a valid permission to call this method." %}

```
```

{% endtab %}

{% tab title="500 " %}

```
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);

var response = await pushService.GetNotificationsAsync(
    new GetNotificationsRequest
    {
        UserId = "{USER_ID}"
    }
);
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;

class CodemashService
{
    protected CodemashPushNotification $codemashPushNotification;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $codemashPushNotification = new CodemashPushNotification($client);
    }
    
    public function getNotifications()
    {
        $responseData = $this->codemashPushNotification->getNotifications([
            'userId' => '{USER_ID}',
        ]);
    }
    
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
If you do not specify user ID or device ID, the method will return notifications directed to the calling user. To get any user's or device's notifications, the calling user need's to have the appropriate permission for that.
{% endhint %}

## Get Notifications Count

<mark style="color:blue;">`GET`</mark> `https://api.codemash.io/:version/notifications/push/count`

Gets total and total unread notifications.

#### Path Parameters

| Name    | Type   | Description                                             |
| ------- | ------ | ------------------------------------------------------- |
| version | string | The version of the API endpoint. Current latest **v1**. |

#### Query Parameters

| Name     | Type   | Description                                    |
| -------- | ------ | ---------------------------------------------- |
| userId   | string | The ID of a user whose notifications to get.   |
| deviceId | string | The ID of a device whose notifications to get. |

#### Headers

| Name           | Type   | Description                                            |
| -------------- | ------ | ------------------------------------------------------ |
| Authorization  | string | Your project's secret key.                             |
| x-cm-projectid | string | Your project's ID. Can be passed as a query parameter. |

{% tabs %}
{% tab title="200 Returns an ID of created notification group." %}

```javascript
{
    "result": {
        "totalCount": 20,
        "totalUnread": 2
    }
}
```

{% endtab %}

{% tab title="401 Returns if the user does not have a valid permission to call this method." %}

```
```

{% endtab %}

{% tab title="500 " %}

```
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);

var response = await pushService.GetNotificationsCountAsync(
    new GetNotificationsCountRequest
    {
        UserId = "{USER_ID}"
    }
);
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;

class CodemashService
{
    protected CodemashPushNotification $codemashPushNotification;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $codemashPushNotification = new CodemashPushNotification($client);
    }
    
    public function getNotificationsCount()
    {
        $responseData = $this->codemashPushNotification->getNotificationCount([
            'userId' => '{USER_ID}',
        ]);
    }
    
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
If you do not specify user ID or device ID, the method will return notifications directed to the calling user. To get any user's or device's notifications, the calling user need's to have the appropriate permission for that.
{% endhint %}

## Read Notification

<mark style="color:purple;">`PATCH`</mark> `https://api.codemash.io/:version/notifications/push/:notificationId/read`

Marks a particular push notification as read.

#### Path Parameters

| Name    | Type   | Description                                             |
| ------- | ------ | ------------------------------------------------------- |
| version | string | The version of the API endpoint. Current latest **v1**. |
| id      | string | The ID of a notification to delete.                     |

#### Headers

| Name           | Type   | Description                                            |
| -------------- | ------ | ------------------------------------------------------ |
| Authorization  | string | Your project's secret key.                             |
| x-cm-projectid | string | Your project's ID. Can be passed as a query parameter. |

#### Request Body

| Name           | Type   | Description                                                 |
| -------------- | ------ | ----------------------------------------------------------- |
| notificationId | string | The ID of notification to mark as read.                     |
| userId         | string | The ID of the user at which this notification was directed. |
| deviceId       | string | The ID of device at which this notification was directed.   |

{% tabs %}
{% tab title="200 Returns an ID of created notification group." %}

```javascript
{
    Result: ""
}
```

{% endtab %}

{% tab title="401 Returns if the user does not have a valid permission to call this method." %}

```
```

{% endtab %}

{% tab title="500 " %}

```
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);

var response = await pushService.ReadNotificationAsync(
    new MarkNotificationAsReadRequest
    {
        NotificationId = "{NOTIFICATION_ID}"
    }
);
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;

class CodemashService
{
    protected CodemashPushNotification $codemashPushNotification;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $codemashPushNotification = new CodemashPushNotification($client);
    }
    
    public function readNotification()
    {
        $responseData = $codemashPushNotification->readNotification([
            'id' => '{NOTIFICATION_ID}',
        ]);
    }
    
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
If you do not specify user ID or device ID, the method will assume that notification was directed to a calling user. If you want to set other user's notification as read, you need to have the appropriate permission for that.
{% endhint %}

## Delete Notification

<mark style="color:red;">`DELETE`</mark> `https://api.codemash.io/:version/notifications/push/:id`

Deletes a particular push notification.

#### Path Parameters

| Name    | Type   | Description                                             |
| ------- | ------ | ------------------------------------------------------- |
| version | string | The version of the API endpoint. Current latest **v1**. |
| id      | string | The ID of a notification to delete.                     |

#### Headers

| Name           | Type   | Description                                            |
| -------------- | ------ | ------------------------------------------------------ |
| Authorization  | string | Your project's secret key.                             |
| x-cm-projectid | string | Your project's ID. Can be passed as a query parameter. |

{% tabs %}
{% tab title="200 Returns an ID of created notification group." %}

```javascript
{
    Result: ""
}
```

{% endtab %}

{% tab title="401 Returns if the user does not have a valid permission to call this method." %}

```
```

{% endtab %}

{% tab title="500 " %}

```
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title=".NET" %}

```csharp
var client = new CodeMashClient(apiKey, projectId);
var pushService = new CodeMashPushService(client);

var response = await pushService.DeleteNotificationAsync(
    new DeleteNotificationRequest
    {
        Id = "{NOTIFICATION_ID}"
    }
);
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashPushNotification;

class CodemashService
{
    protected CodemashPushNotification $codemashPushNotification;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $codemashPushNotification = new CodemashPushNotification($client);
    }
    
    public function deleteNotification()
    {
        $responseData = $codemashPushNotification->deleteNotification([
            'id' => '{NOTIFICATION_ID}',
        ]);
    }
    
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.codemash.io/dashboard/notifications/push/notifications.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
