> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.onesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# View message

> View the details of a single message and the Outcomes associated with it.

## Overview

The View message API allows you to fetch data from a single push, email, or SMS message at a time. If you want to get multiple messages at a time, use the [View messages](/reference/view-messages) API. In most cases, you will likely want to use [Event Streams](/docs/en/event-streams) instead.

Currently this API does not provide Journey-sent messages. See [Journey analytics](/docs/en/journeys-analytics) for details.

Messages sent through the API are only **accessible 30 days after creation**; however, messages sent using the OneSignal dashboard are accessible for the app's lifetime.

See our [Rate limits](/reference/rate-limits) for details on how often you can pull your message data with this API.

***

## How to use this API

This API is most commonly used when sending [Transactional messages](/docs/en/transactional-messages) to individual users. The response of our Create message API has an `id` which corresponds to the `message_id` used in this request. You can store this `message_id` on your server and (after giving your users some time to interact with the message) pull the data if desired.

For example, if you send a message targeting the `include_aliases` parameter, the response will include the aliases you set. If you send with the `included_segments` parameter, then the response will only provide the segments you set. When targeting segments or filters, you can use the [Export audience activity CSV](/reference/export-csv-of-events) API to get the user event data.

To view outcome data for the message, you must include the `outcome_name` parameter with the name of the outcome you want to fetch, along with the accompanying aggregation type (.count or .sum), for example: `os__click.count`. For more information on outcome definitions, see [View Outcomes](/reference/view-outcomes).

***


## OpenAPI

````yaml GET /notifications/{message_id}?app_id={app_id}
openapi: 3.1.0
info:
  title: api.onesignal.com
  version: '11.6'
servers:
  - url: https://api.onesignal.com
security:
  - {}
paths:
  /notifications/{message_id}?app_id={app_id}:
    get:
      summary: View message
      description: >-
        View the details of a single message and the Outcomes associated with
        it.
      operationId: view-message
      parameters:
        - name: message_id
          in: path
          description: >-
            The identifier of the message in UUID v4 format. Get this `id` in
            the response of your Create Message API request, the [View Messages
            API](/reference/view-messages), and in your OneSignal dashboard
            Message Reports.
          schema:
            type: string
          required: true
        - name: app_id
          in: query
          description: >-
            Your OneSignal App ID in UUID v4 format. See [Keys &
            IDs](/docs/en/keys-and-ids).
          required: true
          schema:
            type: string
            default: YOUR_APP_ID
        - name: Authorization
          in: header
          description: >-
            Your App API key with prefix `Key `. See [Keys &
            IDs](/docs/en/keys-and-ids).
          required: true
          schema:
            type: string
            default: Key YOUR_APP_API_KEY
        - name: outcome_names
          in: query
          description: >-
            The name and aggregation type of the outcome(s) you want to fetch.
            Example: `my_outcome.count` or `my_outcome.sum`. For clicks, use
            `os__click.count`. For confirmed deliveries, use
            `os__confirmed_delivery.count`. For session duration, use
            `os__session_duration.count`.
          schema:
            type: array
            items:
              type: string
              default:
                - os__click.count
                - os__confirmed_delivery.count
                - os__session_duration.count
        - name: outcome_time_range
          in: query
          description: >-
            Time range for the returned data. Available values: `1h` (1 hour),
            `1d` (1 day), `1mo` (1 month)
          schema:
            type: string
            enum:
              - 1h
              - 1d
              - 1mo
            default: 1h
        - name: outcome_platforms
          in: query
          description: >-
            The platforms in which you want to pull the data represented as the
            `device_type` integer.
          schema:
            type: string
            default: 0,1,2,5,8,11,14,17
        - name: outcome_attribution
          in: query
          description: Attribution type for the outcomes.
          schema:
            type: string
            enum:
              - direct
              - influenced
              - unattributed
              - total
            default: total
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Returns all message properties set. See the [Push
                  notifications](/reference/push-notification),
                  [Email](/reference/email), and/or [SMS](/reference/sms)
                  Message Create APIs for all properties. Most commonly used
                  properties for this endpoint are listed.
                properties:
                  app_id:
                    type: string
                    description: >-
                      Your OneSignal App ID in UUID v4 format. See [Keys &
                      IDs](/docs/en/keys-and-ids).
                  big_picture:
                    description: The URL of the image set in the push notification.
                    type: string
                  canceled:
                    description: Whether the message was canceled.
                    type: boolean
                  chrome_web_icon:
                    description: The URL of the icon set in the push notification.
                    type: string
                  chrome_web_image:
                    description: The URL of the image set in the push notification.
                    type: string
                  name:
                    type: string
                    description: >-
                      An internal name you set to help organize and track
                      messages. Not shown to recipients. Maximum 128 characters.
                  contents:
                    description: >-
                      The main message body with [language-specific
                      values](/docs/en/multi-language-messaging#supported-languages).
                    type: object
                    properties:
                      en:
                        type: string
                        description: >-
                          The required message language type. See [Supported
                          Languages](/docs/en/multi-language-messaging#supported-languages).
                  converted:
                    type: integer
                    description: The number of times the push was clicked.
                  data:
                    type: object
                    description: The JSON data set in the push notification if applicable.
                  delayed_option:
                    type: string
                    description: The per-user delay option set for the message.
                  delivery_time_of_day:
                    type: string
                    description: >-
                      The delivery time of day set for the message if
                      `delayed_option` is `timezone`.
                  remaining:
                    type: integer
                    description: >-
                      The number of messages that have not been sent yet. If
                      `null`, then the system is still processing the audience,
                      try again later.
                  errored:
                    type: integer
                    description: The number of times the message errored.
                  excluded_segments:
                    type: array
                    description: The segments excluded from the message if applicable.
                  failed:
                    type: integer
                    description: >-
                      The number of subscriptions reported unsubscribed for the
                      message.
                  global_image:
                    description: The URL of the image set in the push notification.
                    type: string
                  headings:
                    type: object
                    description: The title of the push notification.
                  id:
                    type: string
                    description: The identifier of the message in UUID v4 format.
                  included_segments:
                    type: array
                    description: The segments included in the message if applicable.
                  ios_badgeCount:
                    type: integer
                    description: The badge count set for the message if applicable.
                  ios_badgeType:
                    type: string
                    description: The badge type set for the message if applicable.
                  queued_at:
                    type: integer
                    description: Unix timestamp of when the message was created.
                  send_after:
                    type: integer
                    description: >-
                      Unix timestamp of when the message delivery was scheduled
                      to begin.
                  completed_at:
                    type: integer
                    description: >-
                      Unix timestamp of when the message delivery was completed.
                      The delivery duration from start to finish can be
                      calculated with `completed_at - send_after`. 
                  successful:
                    type: integer
                    description: >-
                      The number of messages successfully delivered to the push,
                      email, or SMS servers.
                  received:
                    type: integer
                    description: >-
                      The number of messages that confirmed being received aka
                      [Confirmed Deliveries](/docs/confirmed-delivery).
                  filters:
                    type: object
                    description: The filters set for the message if applicable.
                  template_id:
                    type: string
                    description: >-
                      The template ID in UUID v4 format set for the message if
                      applicable. See [Templates](/docs/templates).
                  url:
                    type: string
                    description: The URL of the push notification.
                  web_url:
                    type: string
                    description: >-
                      The URL of the push notification for web push
                      subscriptions.
                  app_url:
                    type: string
                    description: The URL of the push notification for mobile subscriptions.
                  platform_delivery_stats:
                    type: object
                    description: >-
                      The successful, errored, failed, converted, received and
                      frequency cap counts for each platform applicable.
                  throttle_rate_per_minute:
                    type: number
                    description: The throttle rate of the push notification if applicable.
                  fcap_status:
                    type: string
                    description: >-
                      The frequency cap status of the push notification if
                      applicable.
                  outcomes:
                    type: object
                    description: >-
                      The id, value, and aggregation type of the outcome set in
                      the request.
        '429':
          description: >-
            Rate limit exceeded. Wait the number of seconds in the `Retry-After`
            header before retrying.
          headers:
            Retry-After:
              description: >-
                Number of seconds to wait before retrying the request. Always
                emitted on 429 responses.
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicErrorResponse'
              example:
                errors:
                  - API rate limit exceeded
        '503':
          description: >-
            Service temporarily unavailable. Retry after a short backoff. The
            body may be empty or non-JSON in some failure modes.
          headers:
            Retry-After:
              description: >-
                Number of seconds to wait before retrying. Optional — may be
                absent when the response is generated upstream.
              schema:
                type: integer
                minimum: 0
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BasicErrorResponse'
              example:
                errors:
                  - Service temporarily unavailable
      deprecated: false
      x-codeSamples:
        - lang: typescript
          label: Node.js SDK
          source: >-
            import Onesignal from '@onesignal/node-onesignal';


            const configuration = Onesignal.createConfiguration({
                restApiKey: '<YOUR_REST_API_KEY>',
            });

            const apiInstance = new Onesignal.DefaultApi(configuration);


            // string

            const appId: string = "00000000-0000-0000-0000-000000000000";

            // string

            const notificationId: string =
            "b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88";


            try {
              const response = await apiInstance.getNotification(appId, notificationId);
              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("getNotification failed: HTTP " + e.code, e.errorMessages);
              } else {
                throw e;
              }
            }
        - lang: python
          label: Python SDK
          source: >-
            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_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" 
                notification_id = "b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88" 

                # example passing only required values which don't have defaults set
                try:
                    # View notification
                    api_response = api_instance.get_notification(app_id, notification_id)
                    pprint(api_response)
                except onesignal.ApiException as e:
                    print("Exception when calling DefaultApi->get_notification: %s\n" % e)
                    print("Status Code: %s" % e.status)
                    print("Response Body: %s" % e.body)
        - lang: php
          label: PHP SDK
          source: |-
            <?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
            $notification_id = 'b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88'; // string

            try {
                $result = $apiInstance->getNotification($app_id, $notification_id);
                print_r($result);
            } catch (\onesignal\client\ApiException $e) {
                echo 'Exception when calling DefaultApi->getNotification: ', $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->getNotification: ', $e->getMessage(), PHP_EOL;
            }
        - lang: go
          label: Go SDK
          source: |-
            package main

            import (
                "context"
                "fmt"
                "os"

                "github.com/OneSignal/onesignal-go-api/v5"
            )

            func main() {
                appId := "00000000-0000-0000-0000-000000000000" // string | 
                notificationId := "b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88" // string | 

                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.GetNotification(restAuth, notificationId).AppId(appId).Execute()

                if err != nil {
                    fmt.Fprintf(os.Stderr, "Error when calling `DefaultApi.GetNotification``: %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 `GetNotification`: NotificationWithMeta
                fmt.Fprintf(os.Stdout, "Response from `DefaultApi.GetNotification`: %v\n", resp)
            }
        - lang: ruby
          label: Ruby SDK
          source: |-
            require 'onesignal'
            # setup authorization
            OneSignal.configure do |config|
              # Configure Bearer authorization: rest_api_key
              config.rest_api_key = 'YOUR_BEARER_TOKEN'

            end

            api_instance = OneSignal::DefaultApi.new
            app_id = '00000000-0000-0000-0000-000000000000' # String | 
            notification_id = 'b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88' # String | 

            begin
              # View notification
              result = api_instance.get_notification(app_id, notification_id)
              p result
            rescue OneSignal::ApiError => e
              puts "Error when calling DefaultApi->get_notification: #{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
        - lang: java
          label: Java SDK
          source: |-
            // 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("BEARER TOKEN");

                DefaultApi apiInstance = new DefaultApi(defaultClient);
                String appId = "00000000-0000-0000-0000-000000000000"; // String | 
                String notificationId = "b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88"; // String | 
                try {
                  NotificationWithMeta result = apiInstance.getNotification(appId, notificationId);
                  System.out.println(result);
                } catch (ApiException e) {
                  System.err.println("Exception when calling DefaultApi#getNotification");
                  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();
                }
              }
            }
        - lang: csharp
          label: C# SDK
          source: |-
            using System;
            using System.Collections.Generic;
            using System.Diagnostics;
            using OneSignalApi.Api;
            using OneSignalApi.Client;
            using OneSignalApi.Model;

            namespace Example
            {
                public class GetNotificationExample
                {
                    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_BEARER_TOKEN";

                        var apiInstance = new DefaultApi(config);
                        var appId = "00000000-0000-0000-0000-000000000000";  // string | 
                        var notificationId = "b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88";  // string | 

                        try
                        {
                            // View notification
                            NotificationWithMeta result = apiInstance.GetNotification(appId, notificationId);
                            Debug.WriteLine(result);
                        }
                        catch (ApiException  e)
                        {
                            Debug.Print("Exception when calling DefaultApi.GetNotification: " + 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);
                        }
                    }
                }
            }
        - lang: rust
          label: Rust SDK
          source: |-
            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 notification_id: &str = "b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88";

                match default_api::get_notification(&configuration, app_id, notification_id).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_notification failed: {:?}", e.error_messages());
                    }
                    Err(e) => eprintln!("get_notification failed: {:?}", e),
                }
            }
components:
  schemas:
    BasicErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          description: One or more human-readable error messages.
        success:
          type: boolean
          description: >-
            Present (and `false`) on some endpoints (notifications, templates,
            segments). Not emitted by every endpoint.
        reference:
          type: array
          items:
            type: string
          description: >-
            Documentation URL fragments related to the error. Only emitted by
            the API-key auth error helpers.

````