curl --request GET \
--url 'https://api.onesignal.com/notifications?app_id={app_id}&limit={limit}&offset={offset}&kind={kind}&template_id={template_id}&time_offset={time_offset}' \
--header 'Authorization: <authorization>'import Onesignal from '@onesignal/node-onesignal';
const configuration = Onesignal.createConfiguration({
restApiKey: 'YOUR_REST_API_KEY',
});
const apiInstance = new Onesignal.DefaultApi(configuration);
// string | The app ID that you want to view notifications from
const appId: string = "00000000-0000-0000-0000-000000000000";
// number | How many notifications to return. Max is 50. Default is 50. (optional)
const limit: number = 10;
// number | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. (optional)
const offset: number = 0;
// 0 | 1 | 3 | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only (optional)
const kind: 0 | 1 | 3 = 0;
// string | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned. (optional)
const timeOffset: string = "2025-01-01T00:00:00.000Z";
try {
const response = await apiInstance.getNotifications(appId, limit, offset, kind, timeOffset);
console.log(response);
} catch (e) {
if (e instanceof Onesignal.ApiException) {
// `e.errorMessages` flattens any error-envelope shape to a `string[]`;
// the raw parsed body remains on `e.body`.
console.error("getNotifications failed: HTTP " + e.code, e.errorMessages);
} else {
throw e;
}
}import onesignal
from onesignal.api import default_api
from onesignal.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
# Some of the OneSignal endpoints require ORGANIZATION_API_KEY token for authorization, while others require REST_API_KEY.
# We recommend adding both of them in the configuration page so that you will not need to figure it out yourself.
configuration = onesignal.Configuration(
rest_api_key = "YOUR_REST_API_KEY", # App REST API key required for most endpoints
organization_api_key = "YOUR_ORGANIZATION_API_KEY" # Organization key is only required for creating new apps and other top-level endpoints
)
# Enter a context with an instance of the API client
with onesignal.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
app_id = "00000000-0000-0000-0000-000000000000" # The app ID that you want to view notifications from
limit = 10 # How many notifications to return. Max is 50. Default is 50. (optional)
offset = 0 # Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. (optional)
kind = 0 # Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only (optional)
time_offset = "2025-01-01T00:00:00.000Z" # Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned. (optional)
try:
# View notifications
api_response = api_instance.get_notifications(app_id, limit=limit, offset=offset, kind=kind, time_offset=time_offset)
pprint(api_response)
except onesignal.ApiException as e:
print("Exception when calling DefaultApi->get_notifications: %s\n" % e)
print("Status Code: %s" % e.status)
print("Response Body: %s" % e.body)<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: rest_api_key
$config = onesignal\client\Configuration::getDefaultConfiguration()
->setRestApiKeyToken('YOUR_REST_API_KEY')
->setOrganizationApiKeyToken('YOUR_ORGANIZATION_API_KEY');
$apiInstance = new onesignal\client\Api\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$app_id = '00000000-0000-0000-0000-000000000000'; // string | The app ID that you want to view notifications from
$limit = 10; // int | How many notifications to return. Max is 50. Default is 50.
$offset = 0; // int | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.
$kind = 0; // int | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only
$time_offset = '2025-01-01T00:00:00.000Z'; // string | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.
try {
$result = $apiInstance->getNotifications($app_id, $limit, $offset, $kind, $time_offset);
print_r($result);
} catch (\onesignal\client\ApiException $e) {
echo 'Exception when calling DefaultApi->getNotifications: ', $e->getMessage(), PHP_EOL;
echo 'Status Code: ', $e->getCode(), PHP_EOL;
// getErrorMessages() flattens any error-envelope shape to a string[];
// the raw body remains on getResponseBody().
echo 'Error Messages: ', implode(', ', $e->getErrorMessages()), PHP_EOL;
echo 'Response Body: ', $e->getResponseBody(), PHP_EOL;
} catch (\Exception $e) {
echo 'Exception when calling DefaultApi->getNotifications: ', $e->getMessage(), PHP_EOL;
}package main
import (
"context"
"fmt"
"os"
"github.com/OneSignal/onesignal-go-api/v5"
)
func main() {
appId := "00000000-0000-0000-0000-000000000000" // string | The app ID that you want to view notifications from
limit := int32(10) // int32 | How many notifications to return. Max is 50. Default is 50. (optional)
offset := int32(0) // int32 | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. (optional)
kind := int32(0) // int32 | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only (optional)
timeOffset := "2025-01-01T00:00:00.000Z" // string | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned. (optional)
configuration := onesignal.NewConfiguration()
apiClient := onesignal.NewAPIClient(configuration)
restAuth := context.WithValue(context.Background(), onesignal.RestApiKey, "YOUR_REST_API_KEY") // App REST API key required for most endpoints
resp, r, err := apiClient.DefaultApi.GetNotifications(restAuth).AppId(appId).Limit(limit).Offset(offset).Kind(kind).TimeOffset(timeOffset).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.GetNotifications``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
if apiErr, ok := err.(*onesignal.GenericOpenAPIError); ok {
// ErrorMessages() flattens any error-envelope shape to a []string;
// the raw body remains on Body().
fmt.Fprintf(os.Stderr, "Error Messages: %v\n", apiErr.ErrorMessages())
fmt.Fprintf(os.Stderr, "Response Body: %s\n", apiErr.Body())
}
}
// response from `GetNotifications`: NotificationSlice
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.GetNotifications`: %v\n", resp)
}require 'onesignal'
# setup authorization
OneSignal.configure do |config|
# Configure Bearer authorization: rest_api_key
config.rest_api_key = 'YOUR_REST_API_KEY'
end
api_instance = OneSignal::DefaultApi.new
app_id = '00000000-0000-0000-0000-000000000000' # String | The app ID that you want to view notifications from
opts = {
limit: 10, # Integer | How many notifications to return. Max is 50. Default is 50.
offset: 0, # Integer | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.
kind: 0, # Integer | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only
time_offset: '2025-01-01T00:00:00.000Z' # String | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.
}
begin
# View notifications
result = api_instance.get_notifications(app_id, opts)
p result
rescue OneSignal::ApiError => e
puts "Error when calling DefaultApi->get_notifications: #{e}"
puts "Status Code: #{e.code}"
# `e.error_messages` flattens any error-envelope shape to an Array<String>;
# the raw body remains on `e.response_body`.
puts "Error Messages: #{e.error_messages}"
puts "Response Body: #{e.response_body}"
end// Import classes:
import com.onesignal.client.ApiClient;
import com.onesignal.client.ApiException;
import com.onesignal.client.Configuration;
import com.onesignal.client.auth.*;
import com.onesignal.client.model.*;
import com.onesignal.client.api.DefaultApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.onesignal.com");
// Configure HTTP bearer authorization: rest_api_key
HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication("rest_api_key");
rest_api_key.setBearerToken("YOUR_REST_API_KEY");
DefaultApi apiInstance = new DefaultApi(defaultClient);
String appId = "00000000-0000-0000-0000-000000000000"; // String | The app ID that you want to view notifications from
Integer limit = 10; // Integer | How many notifications to return. Max is 50. Default is 50.
Integer offset = 0; // Integer | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.
Integer kind = 0; // Integer | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only
String timeOffset = "2025-01-01T00:00:00.000Z"; // String | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.
try {
NotificationSlice result = apiInstance.getNotifications(appId, limit, offset, kind, timeOffset);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#getNotifications");
System.err.println("Status code: " + e.getCode());
// getErrorMessages() flattens any error-envelope shape to a List<String>;
// the raw body remains on getResponseBody().
System.err.println("Error messages: " + e.getErrorMessages());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}using System;
using System.Collections.Generic;
using System.Diagnostics;
using OneSignalApi.Api;
using OneSignalApi.Client;
using OneSignalApi.Model;
namespace Example
{
public class GetNotificationsExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.onesignal.com";
// Configure Bearer token for authorization: rest_api_key
config.AccessToken = "YOUR_REST_API_KEY";
var apiInstance = new DefaultApi(config);
var appId = "00000000-0000-0000-0000-000000000000"; // string | The app ID that you want to view notifications from
var limit = 10; // int? | How many notifications to return. Max is 50. Default is 50. (optional)
var offset = 0; // int? | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. (optional)
var kind = 0; // int? | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only (optional)
var timeOffset = "2025-01-01T00:00:00.000Z"; // string | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned. (optional)
try
{
// View notifications
NotificationSlice result = apiInstance.GetNotifications(appId, limit, offset, kind, timeOffset);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.GetNotifications: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
// e.ErrorMessages flattens any error-envelope shape to an IReadOnlyList<string>;
// the raw body remains on e.ErrorContent.
Debug.Print("Error Messages: " + string.Join(", ", e.ErrorMessages));
Debug.Print("Response Body: " + e.ErrorContent);
Debug.Print(e.StackTrace);
}
}
}
}use onesignal_rust_api::apis::configuration::Configuration;
use onesignal_rust_api::apis::default_api;
#[tokio::main]
async fn main() {
let mut configuration = Configuration::new();
configuration.rest_api_key_token = Some("YOUR_REST_API_KEY".to_string());
// Realistic values are pulled from the spec's `example:` fields where present.
let app_id: &str = "00000000-0000-0000-0000-000000000000";
let limit: Option<i32> = None;
let offset: Option<i32> = None;
let kind: Option<i32> = None;
let time_offset: Option<&str> = None;
match default_api::get_notifications(&configuration, app_id, limit, offset, kind, time_offset).await {
Ok(resp) => println!("{:?}", resp),
Err(e @ onesignal_rust_api::apis::Error::ResponseError(_)) => {
// `e.error_messages()` flattens any error-envelope shape to a Vec<String>;
// the raw response remains on the ResponseError variant.
eprintln!("get_notifications failed: {:?}", e.error_messages());
}
Err(e) => eprintln!("get_notifications failed: {:?}", e),
}
}{
"total_count": 123,
"time_offset": "<string>",
"next_time_offset": "<string>",
"offset": 123,
"limit": 123,
"notifications": [
{
"app_id": "<string>",
"big_picture": "<string>",
"canceled": true,
"chrome_web_icon": "<string>",
"chrome_web_image": "<string>",
"name": "<string>",
"contents": {
"en": "<string>"
},
"converted": 123,
"data": {},
"delayed_option": "<string>",
"delivery_time_of_day": "<string>",
"remaining": 123,
"errored": 123,
"excluded_segments": "<array>",
"failed": 123,
"global_image": "<string>",
"headings": {},
"id": "<string>",
"included_segments": "<array>",
"ios_badgeCount": 123,
"ios_badgeType": "<string>",
"queued_at": 123,
"send_after": 123,
"completed_at": 123,
"successful": 123,
"received": 123,
"filters": {},
"template_id": "<string>",
"url": "<string>",
"web_url": "<string>",
"app_url": "<string>",
"platform_delivery_stats": {},
"throttle_rate_per_minute": 123,
"fcap_status": "<string>",
"outcomes": {}
}
]
}{
"errors": [
"API rate limit exceeded"
]
}{
"errors": [
"Service temporarily unavailable"
]
}View messages
View the details for a collection of messages.
curl --request GET \
--url 'https://api.onesignal.com/notifications?app_id={app_id}&limit={limit}&offset={offset}&kind={kind}&template_id={template_id}&time_offset={time_offset}' \
--header 'Authorization: <authorization>'import Onesignal from '@onesignal/node-onesignal';
const configuration = Onesignal.createConfiguration({
restApiKey: 'YOUR_REST_API_KEY',
});
const apiInstance = new Onesignal.DefaultApi(configuration);
// string | The app ID that you want to view notifications from
const appId: string = "00000000-0000-0000-0000-000000000000";
// number | How many notifications to return. Max is 50. Default is 50. (optional)
const limit: number = 10;
// number | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. (optional)
const offset: number = 0;
// 0 | 1 | 3 | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only (optional)
const kind: 0 | 1 | 3 = 0;
// string | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned. (optional)
const timeOffset: string = "2025-01-01T00:00:00.000Z";
try {
const response = await apiInstance.getNotifications(appId, limit, offset, kind, timeOffset);
console.log(response);
} catch (e) {
if (e instanceof Onesignal.ApiException) {
// `e.errorMessages` flattens any error-envelope shape to a `string[]`;
// the raw parsed body remains on `e.body`.
console.error("getNotifications failed: HTTP " + e.code, e.errorMessages);
} else {
throw e;
}
}import onesignal
from onesignal.api import default_api
from onesignal.models import *
from pprint import pprint
# See configuration.py for a list of all supported configuration parameters.
# Some of the OneSignal endpoints require ORGANIZATION_API_KEY token for authorization, while others require REST_API_KEY.
# We recommend adding both of them in the configuration page so that you will not need to figure it out yourself.
configuration = onesignal.Configuration(
rest_api_key = "YOUR_REST_API_KEY", # App REST API key required for most endpoints
organization_api_key = "YOUR_ORGANIZATION_API_KEY" # Organization key is only required for creating new apps and other top-level endpoints
)
# Enter a context with an instance of the API client
with onesignal.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = default_api.DefaultApi(api_client)
app_id = "00000000-0000-0000-0000-000000000000" # The app ID that you want to view notifications from
limit = 10 # How many notifications to return. Max is 50. Default is 50. (optional)
offset = 0 # Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. (optional)
kind = 0 # Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only (optional)
time_offset = "2025-01-01T00:00:00.000Z" # Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned. (optional)
try:
# View notifications
api_response = api_instance.get_notifications(app_id, limit=limit, offset=offset, kind=kind, time_offset=time_offset)
pprint(api_response)
except onesignal.ApiException as e:
print("Exception when calling DefaultApi->get_notifications: %s\n" % e)
print("Status Code: %s" % e.status)
print("Response Body: %s" % e.body)<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: rest_api_key
$config = onesignal\client\Configuration::getDefaultConfiguration()
->setRestApiKeyToken('YOUR_REST_API_KEY')
->setOrganizationApiKeyToken('YOUR_ORGANIZATION_API_KEY');
$apiInstance = new onesignal\client\Api\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$app_id = '00000000-0000-0000-0000-000000000000'; // string | The app ID that you want to view notifications from
$limit = 10; // int | How many notifications to return. Max is 50. Default is 50.
$offset = 0; // int | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.
$kind = 0; // int | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only
$time_offset = '2025-01-01T00:00:00.000Z'; // string | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.
try {
$result = $apiInstance->getNotifications($app_id, $limit, $offset, $kind, $time_offset);
print_r($result);
} catch (\onesignal\client\ApiException $e) {
echo 'Exception when calling DefaultApi->getNotifications: ', $e->getMessage(), PHP_EOL;
echo 'Status Code: ', $e->getCode(), PHP_EOL;
// getErrorMessages() flattens any error-envelope shape to a string[];
// the raw body remains on getResponseBody().
echo 'Error Messages: ', implode(', ', $e->getErrorMessages()), PHP_EOL;
echo 'Response Body: ', $e->getResponseBody(), PHP_EOL;
} catch (\Exception $e) {
echo 'Exception when calling DefaultApi->getNotifications: ', $e->getMessage(), PHP_EOL;
}package main
import (
"context"
"fmt"
"os"
"github.com/OneSignal/onesignal-go-api/v5"
)
func main() {
appId := "00000000-0000-0000-0000-000000000000" // string | The app ID that you want to view notifications from
limit := int32(10) // int32 | How many notifications to return. Max is 50. Default is 50. (optional)
offset := int32(0) // int32 | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. (optional)
kind := int32(0) // int32 | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only (optional)
timeOffset := "2025-01-01T00:00:00.000Z" // string | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned. (optional)
configuration := onesignal.NewConfiguration()
apiClient := onesignal.NewAPIClient(configuration)
restAuth := context.WithValue(context.Background(), onesignal.RestApiKey, "YOUR_REST_API_KEY") // App REST API key required for most endpoints
resp, r, err := apiClient.DefaultApi.GetNotifications(restAuth).AppId(appId).Limit(limit).Offset(offset).Kind(kind).TimeOffset(timeOffset).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.GetNotifications``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
if apiErr, ok := err.(*onesignal.GenericOpenAPIError); ok {
// ErrorMessages() flattens any error-envelope shape to a []string;
// the raw body remains on Body().
fmt.Fprintf(os.Stderr, "Error Messages: %v\n", apiErr.ErrorMessages())
fmt.Fprintf(os.Stderr, "Response Body: %s\n", apiErr.Body())
}
}
// response from `GetNotifications`: NotificationSlice
fmt.Fprintf(os.Stdout, "Response from `DefaultApi.GetNotifications`: %v\n", resp)
}require 'onesignal'
# setup authorization
OneSignal.configure do |config|
# Configure Bearer authorization: rest_api_key
config.rest_api_key = 'YOUR_REST_API_KEY'
end
api_instance = OneSignal::DefaultApi.new
app_id = '00000000-0000-0000-0000-000000000000' # String | The app ID that you want to view notifications from
opts = {
limit: 10, # Integer | How many notifications to return. Max is 50. Default is 50.
offset: 0, # Integer | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.
kind: 0, # Integer | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only
time_offset: '2025-01-01T00:00:00.000Z' # String | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.
}
begin
# View notifications
result = api_instance.get_notifications(app_id, opts)
p result
rescue OneSignal::ApiError => e
puts "Error when calling DefaultApi->get_notifications: #{e}"
puts "Status Code: #{e.code}"
# `e.error_messages` flattens any error-envelope shape to an Array<String>;
# the raw body remains on `e.response_body`.
puts "Error Messages: #{e.error_messages}"
puts "Response Body: #{e.response_body}"
end// Import classes:
import com.onesignal.client.ApiClient;
import com.onesignal.client.ApiException;
import com.onesignal.client.Configuration;
import com.onesignal.client.auth.*;
import com.onesignal.client.model.*;
import com.onesignal.client.api.DefaultApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.onesignal.com");
// Configure HTTP bearer authorization: rest_api_key
HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication("rest_api_key");
rest_api_key.setBearerToken("YOUR_REST_API_KEY");
DefaultApi apiInstance = new DefaultApi(defaultClient);
String appId = "00000000-0000-0000-0000-000000000000"; // String | The app ID that you want to view notifications from
Integer limit = 10; // Integer | How many notifications to return. Max is 50. Default is 50.
Integer offset = 0; // Integer | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at.
Integer kind = 0; // Integer | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only
String timeOffset = "2025-01-01T00:00:00.000Z"; // String | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned.
try {
NotificationSlice result = apiInstance.getNotifications(appId, limit, offset, kind, timeOffset);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#getNotifications");
System.err.println("Status code: " + e.getCode());
// getErrorMessages() flattens any error-envelope shape to a List<String>;
// the raw body remains on getResponseBody().
System.err.println("Error messages: " + e.getErrorMessages());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}using System;
using System.Collections.Generic;
using System.Diagnostics;
using OneSignalApi.Api;
using OneSignalApi.Client;
using OneSignalApi.Model;
namespace Example
{
public class GetNotificationsExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.onesignal.com";
// Configure Bearer token for authorization: rest_api_key
config.AccessToken = "YOUR_REST_API_KEY";
var apiInstance = new DefaultApi(config);
var appId = "00000000-0000-0000-0000-000000000000"; // string | The app ID that you want to view notifications from
var limit = 10; // int? | How many notifications to return. Max is 50. Default is 50. (optional)
var offset = 0; // int? | Page offset. Default is 0. Results are sorted by queued_at in descending order. queued_at is a representation of the time that the notification was queued at. (optional)
var kind = 0; // int? | Kind of notifications returned: * unset - All notification types (default) * `0` - Dashboard only * `1` - API only * `3` - Automated only (optional)
var timeOffset = "2025-01-01T00:00:00.000Z"; // string | Time-offset pagination cursor for sequential pulls of all messages. Accepts either an ISO 8601 formatted timestamp (e.g. `2025-01-01T00:00:00.000Z`) or the opaque Base64 cursor token returned as `next_time_offset` in a prior response. When set, results are sorted ascending by send_after and the standard `offset` parameter cannot be used. Repeat the request with each `next_time_offset` until an empty notifications array is returned. (optional)
try
{
// View notifications
NotificationSlice result = apiInstance.GetNotifications(appId, limit, offset, kind, timeOffset);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.GetNotifications: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
// e.ErrorMessages flattens any error-envelope shape to an IReadOnlyList<string>;
// the raw body remains on e.ErrorContent.
Debug.Print("Error Messages: " + string.Join(", ", e.ErrorMessages));
Debug.Print("Response Body: " + e.ErrorContent);
Debug.Print(e.StackTrace);
}
}
}
}use onesignal_rust_api::apis::configuration::Configuration;
use onesignal_rust_api::apis::default_api;
#[tokio::main]
async fn main() {
let mut configuration = Configuration::new();
configuration.rest_api_key_token = Some("YOUR_REST_API_KEY".to_string());
// Realistic values are pulled from the spec's `example:` fields where present.
let app_id: &str = "00000000-0000-0000-0000-000000000000";
let limit: Option<i32> = None;
let offset: Option<i32> = None;
let kind: Option<i32> = None;
let time_offset: Option<&str> = None;
match default_api::get_notifications(&configuration, app_id, limit, offset, kind, time_offset).await {
Ok(resp) => println!("{:?}", resp),
Err(e @ onesignal_rust_api::apis::Error::ResponseError(_)) => {
// `e.error_messages()` flattens any error-envelope shape to a Vec<String>;
// the raw response remains on the ResponseError variant.
eprintln!("get_notifications failed: {:?}", e.error_messages());
}
Err(e) => eprintln!("get_notifications failed: {:?}", e),
}
}{
"total_count": 123,
"time_offset": "<string>",
"next_time_offset": "<string>",
"offset": 123,
"limit": 123,
"notifications": [
{
"app_id": "<string>",
"big_picture": "<string>",
"canceled": true,
"chrome_web_icon": "<string>",
"chrome_web_image": "<string>",
"name": "<string>",
"contents": {
"en": "<string>"
},
"converted": 123,
"data": {},
"delayed_option": "<string>",
"delivery_time_of_day": "<string>",
"remaining": 123,
"errored": 123,
"excluded_segments": "<array>",
"failed": 123,
"global_image": "<string>",
"headings": {},
"id": "<string>",
"included_segments": "<array>",
"ios_badgeCount": 123,
"ios_badgeType": "<string>",
"queued_at": 123,
"send_after": 123,
"completed_at": 123,
"successful": 123,
"received": 123,
"filters": {},
"template_id": "<string>",
"url": "<string>",
"web_url": "<string>",
"app_url": "<string>",
"platform_delivery_stats": {},
"throttle_rate_per_minute": 123,
"fcap_status": "<string>",
"outcomes": {}
}
]
}{
"errors": [
"API rate limit exceeded"
]
}{
"errors": [
"Service temporarily unavailable"
]
}Overview
The View messages API fetches data for up to 50 push, email, or SMS messages at a time. To fetch a single message, use the View message API. In most cases, use Event Streams instead. This API does not return Journey-sent messages. See Journey analytics for details. Messages sent through the API are retained for 30 days after creation; messages sent through the OneSignal dashboard are retained for the app’s lifetime. See Rate limits for details on how often you can pull your message data with this API.How to use this API
Use time-offset pagination for sequential pulls of all messages, and standard pagination for ad-hoc queries. For ETL or bulk export pipelines, use Event Streams instead. Filter results to a specific message kind or template using thekind and template_id query parameters. Both filters work with either pagination style.
Optimized pagination with time offset
To efficiently retrieve all available messages for an app, usetime_offset-based pagination. When time_offset is specified, the sort order changes from descending to ascending — the oldest messages appear first based on the send_after date.
Accepted time_offset values
- ISO 8601 formatted timestamp — for example,
2025-01-01T00:00:00.000Z(January 1, 2025, at 00:00 UTC). - Opaque cursor token (Base64-encoded) — provided in the API response as
next_time_offset.
Initial fetch
time_offset to an ISO 8601 formatted timestamp. For example, to retrieve messages sent since January 1, 2025: time_offset=2025-01-01T00:00:00.000Z.time_offsetcannot be used with the standardoffsetparameter.time_offsetexcludes messages that match the exact timestamp to avoid duplicates.- The response includes
next_time_offset, a cursor token for the next page. No decoding required. For example:"next_time_offset": "MjAyNS0wMi0xOVQxOToxNjo0OS41Njg5NTFaIzQ2ZWVjMTAzLWQ5OGYtNGQzZC04MzA5LWQxNWI1M2QzMjQ5Nw=="
Fetch additional pages
next_time_offset from the previous response as the time_offset value in the next request. For example: time_offset=MjAyNS0wMi0xOVQxOToxNjo0OS41Njg5NTFaIzQ2ZWVjMTAzLWQ5OGYtNGQzZC04MzA5LWQxNWI1M2QzMjQ5Nw==.Continue until completion
notifications array is returned, indicating all messages have been fetched.Handling new messages
next_time_offset that returned an empty response.Standard pagination
Use thelimit and offset parameters to page through notifications for an app. The maximum result size is 50, and the default limit is 50. Use limit to specify the result size and offset to increment by the limit value with each request.
For example, the first request uses offset=0, the second offset=50, the third offset=100, and so on.
Standard pagination is convenient for ad-hoc queries but degrades as the offset value grows. For sequential pulls of all messages, use time-offset pagination.
Headers
Your App API key with prefix Key. See Keys & IDs.
Query Parameters
Your OneSignal App ID in UUID v4 format. See Keys & IDs.
Specifies the maximum number of messages to return in a single query. The maximum and default is 50 messages per request.
Controls the starting point for the notifications being returned. Default is 0. Results are returned and sorted in descending order by queued_at.
Specifies which push notifications to return based on how it was created. Use this to segment push by their creation method, allowing for targeted analysis or management of notification types. All push types are returned by default. 0 - Notifications created through the dashboard. 1 - Notifications sent via API calls. 3 - Notifications triggered through automated systems.
An ISO 8601 formatted timestamp or Base64 integer token (provided in the API response). See time_offset Accepted Values.
Response
200
Returns all message properties for up to 50 messages per request. See the Push notifications, Email, and/or SMS Message Create APIs for all properties. Most commonly used properties for this endpoint are listed.
The total number of messages available in the dashboard irrespective of page
The time_offset if specified in the request.
A Base64-encoded cursor token representing the next group of messages to fetch if time_offset provided.
The offset specified. Defaults to 0 if not provided in the request.
The limit specified. Defaults to 50 if not provided in the request.
An array of message objects. notifications: [] indicates no more messages to fetch. The data provided is generally the most desired from this request
Show child attributes
Show child attributes
Was this page helpful?