---
title: Test Push Notifications
description: This example uses the notifications endpoint with the query parameter sync=true to test push notifications for a mobile application.
component: pingone-api
page_id: pingone-api:platform:notifications/send-notifications/test_push_notifications
canonical_url: https://developer.pingidentity.com/pingone-api/platform/notifications/send-notifications/test_push_notifications.html
section_ids:
  headers: Headers
  body: Body
  example-request: Example Request
  example-response: Example Response
---

# Test Push Notifications

##

```none
POST {{apiPath}}/v1/environments/{{envID}}/notifications?sync=true
```

This example uses the `notifications` endpoint with the query parameter `sync=true` to test push notifications for a mobile application.

If the push was successfully received, the `status` field in the response will be `SENT`. If there was a problem, a standard error response will be returned, containing details of the cause.

You must set `data.type` to `DRY` for the test to work correctly.

> **Collapse: Query parameters**
>
> The following query parameters are allowed in the request:
>
> | Parameter | Values       |
> | --------- | ------------ |
> | `expand`  | `attributes` |
> | `sync`    | `true`       |

> **Collapse: Request Model**
>
> | Property         | Type   | Required? |
> | ---------------- | ------ | --------- |
> | `application.id` | String | Required  |
> | `body`           | String | Required  |
> | `data.type`      | String | Required  |
> | `deliveryMethod` | String | Required  |
> | `pushToken`      | String | Required  |
> | `title`          | String | Required  |
>
> Refer to the [Send Notifications data model](../send-notifications.html#send-notifications-data-model) for full property descriptions.

### Headers

Authorization      Bearer {{accessToken}}

Content-Type      application/json

### Body

raw ( application/json )

```json
{
    "title": "PingOne test",
    "body": "Test push successful",
    "deliveryMethod": "Google",
    "pushToken": "{{pushToken}}",
    "application": {
        "id": "{{appID}}"
    },
    "data": {
        "type": "DRY"
    }
}
```

##

### Example Request

* cURL

* C#

* Go

* HTTP

* Java

* jQuery

* NodeJS

* Python

* PHP

* Ruby

* Swift

```shell
curl --location --globoff '{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{accessToken}}' \
--data '{
    "title": "PingOne test",
    "body": "Test push successful",
    "deliveryMethod": "Google",
    "pushToken": "{{pushToken}}",
    "application": {
        "id": "{{appID}}"
    },
    "data": {
        "type": "DRY"
    }
}'
```

```csharp
var options = new RestClientOptions("{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer {{accessToken}}");
var body = @"{" + "\n" +
@"    ""title"": ""PingOne test""," + "\n" +
@"    ""body"": ""Test push successful""," + "\n" +
@"    ""deliveryMethod"": ""Google""," + "\n" +
@"    ""pushToken"": ""{{pushToken}}""," + "\n" +
@"    ""application"": {" + "\n" +
@"        ""id"": ""{{appID}}""" + "\n" +
@"    }," + "\n" +
@"    ""data"": {" + "\n" +
@"        ""type"": ""DRY""" + "\n" +
@"    }" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
```

```golang
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true"
  method := "POST"

  payload := strings.NewReader(`{
    "title": "PingOne test",
    "body": "Test push successful",
    "deliveryMethod": "Google",
    "pushToken": "{{pushToken}}",
    "application": {
        "id": "{{appID}}"
    },
    "data": {
        "type": "DRY"
    }
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer {{accessToken}}")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

```http
POST /v1/environments/{{envID}}/notifications?sync=true HTTP/1.1
Host: {{apiPath}}
Content-Type: application/json
Authorization: Bearer {{accessToken}}

{
    "title": "PingOne test",
    "body": "Test push successful",
    "deliveryMethod": "Google",
    "pushToken": "{{pushToken}}",
    "application": {
        "id": "{{appID}}"
    },
    "data": {
        "type": "DRY"
    }
}
```

```java
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"title\": \"PingOne test\",\n    \"body\": \"Test push successful\",\n    \"deliveryMethod\": \"Google\",\n    \"pushToken\": \"{{pushToken}}\",\n    \"application\": {\n        \"id\": \"{{appID}}\"\n    },\n    \"data\": {\n        \"type\": \"DRY\"\n    }\n}");
Request request = new Request.Builder()
  .url("{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer {{accessToken}}")
  .build();
Response response = client.newCall(request).execute();
```

```javascript
var settings = {
  "url": "{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer {{accessToken}}"
  },
  "data": JSON.stringify({
    "title": "PingOne test",
    "body": "Test push successful",
    "deliveryMethod": "Google",
    "pushToken": "{{pushToken}}",
    "application": {
      "id": "{{appID}}"
    },
    "data": {
      "type": "DRY"
    }
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': '{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {{accessToken}}'
  },
  body: JSON.stringify({
    "title": "PingOne test",
    "body": "Test push successful",
    "deliveryMethod": "Google",
    "pushToken": "{{pushToken}}",
    "application": {
      "id": "{{appID}}"
    },
    "data": {
      "type": "DRY"
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

```python
import requests
import json

url = "{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true"

payload = json.dumps({
  "title": "PingOne test",
  "body": "Test push successful",
  "deliveryMethod": "Google",
  "pushToken": "{{pushToken}}",
  "application": {
    "id": "{{appID}}"
  },
  "data": {
    "type": "DRY"
  }
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer {{accessToken}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

```php
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer {{accessToken}}'
));
$request->setBody('{\n    "title": "PingOne test",\n    "body": "Test push successful",\n    "deliveryMethod": "Google",\n    "pushToken": "{{pushToken}}",\n    "application": {\n        "id": "{{appID}}"\n    },\n    "data": {\n        "type": "DRY"\n    }\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

```ruby
require "uri"
require "json"
require "net/http"

url = URI("{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer {{accessToken}}"
request.body = JSON.dump({
  "title": "PingOne test",
  "body": "Test push successful",
  "deliveryMethod": "Google",
  "pushToken": "{{pushToken}}",
  "application": {
    "id": "{{appID}}"
  },
  "data": {
    "type": "DRY"
  }
})

response = http.request(request)
puts response.read_body
```

```swift
let parameters = "{\n    \"title\": \"PingOne test\",\n    \"body\": \"Test push successful\",\n    \"deliveryMethod\": \"Google\",\n    \"pushToken\": \"{{pushToken}}\",\n    \"application\": {\n        \"id\": \"{{appID}}\"\n    },\n    \"data\": {\n        \"type\": \"DRY\"\n    }\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "{{apiPath}}/v1/environments/{{envID}}/notifications?sync=true")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer {{accessToken}}", forHTTPHeaderField: "Authorization")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()
```

### Example Response

202 Accepted

```json
{
    "_links": {
        "self": {
            "href": "https://api.pingone.eu/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/notifications/0f23701b-0cfa-43c0-a09f-fb35596c7c30"
        },
        "environment": {
            "href": "https://api.pingone.eu/v1/environments/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
        }
    },
    "id": "0f23701b-0cfa-43c0-a09f-fb35596c7c30",
    "environment": {
        "id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
    },
    "createdAt": "2023-08-07T16:26:10.541Z",
    "updatedAt": "2023-08-07T16:26:10.862Z",
    "status": "SENT",
    "policy": {
        "id": "a981b194-4caa-7af8-2ec1-9879af481c36"
    },
    "deliveryMethod": "Google",
    "vendor": "FCM_HTTP_V1",
    "bagParams": {
        "retry": false,
        "failures": 0
    },
    "claimedStatus": "NOT_CLAIMED",
    "pushToken": "df-a1bi2T9mqnNE66RHdHj:APA91bFiadh3HCC9YEEDfzZpeH6E0B94yJmn4q5f0fksAOjQ_FShcRxj1LYoSCW9Sxfa2EuYhgUVOopvIwl6xM_sJ4SFOhwFzoNjxFyKj-O7oboC52JsiOeyI1tiiGihWrtrq-UydPUG",
    "application": {
        "id": "8370dc35-a30d-45b6-9ff5-58aa943fca7d"
    },
    "title": "PingOne test",
    "body": "Test push successful",
    "dryRun": false,
    "data": {
        "type": "DRY"
    },
    "androidType": false
}
```
