| APIs / Push API | |
The Localytics Push API currently exposes push as a single endpoint at https://messaging.localytics.com/v2/push/:app_id, which accepts the HTTP POST method.
POST /v2/push/:app_id
The payload is defined with a top level key of messages. Within messages is an array of one or more comma separated message objects.
You can send transactional messages to four types of user targets: audience_id, profile, customer_id, or broadcast. To locate the audience_id, export your audience files.
| Target type | Description | 
|---|---|
| audience_id | Must be an integer. Sends a push notification to a specific audience | 
| customer_id | Must be a string. Sends a push message to a specific customer ID | 
| profile | Sends a push message to a user who has specific profile attributes, defined as a JSON object | 
| broadcast | Must be the string "broadcast". Sends a broadcast push message to all of your app users | 
Here's an example of the general payload structure.
{ 
request_id: “1234-1234-1234-1234”, // Optional
campaign_key: null, // Required. Specify "null" if you don't want to use a campaign key.
target_type: "customer_id" // Replace with “customer_id” or "audience_id" or "profile" or
        "broadcast"
messages: [
            { 
              alert: "Mohana, your pizza is on its way!",
              target: "XYZ" // Replace with the customer ID, the audience ID, or { … profile rules… } 
              ios : {  // Optional block specific to iOS                             
                sound: "default.wav" // Optional                             
                badge: 1 // Optional                             
                extra: {} // Optional field for any custom key/value data that your app is configured to interpret                   
               }                         
               android : {  // Optional block specific to android                             
                  extra: {} // Optional field for any custom key/value data that your app is configured to interpret
                           }
          ]}
    Here's an example of a payload targeting all users with specific profile information. You will need to specify the type of each profile attribute as a string, an integer, or a date. Dates should be formatted yyyy-mm-dd. You can use logical operators to join profile values based on the profile data type.
{   "profile": {
                criteria: [{         
                  key: "cats", // Profile key        
                  scope: "Organization"    // Profile scope: "LocalyticsApplication" or "Organization"
                  type: "string", // Data: "string", "int", or "date"  
                  op: "in", // Operator. Reference the table below for choices       
                  values: ["Ofelia", "Simba"] // Profile values        
                  }, 
                  <another criteria>],
              op: "and" // Outer operator for additional Profile attributes: "and" or "or           
              }
          }
    
| Data type | Operators available | 
|---|---|
| string | ['in'] | 
| int | [ 'in', '<', '<=', '>', '>=', 'between' ] | 
| date | [ 'in', '<=', '>=', 'between' ] | 
Here's an example broadcast payload.
{ 
    request_id: “1234-1234-1234-1234”, // Optional  
    campaign_key: null, // Required, but specify null if you want no campaign key  
    target_type: "broadcast"
    messages: [                
        {               
          alert: “The Bruins win the Stanley Cup!"
        }
  ]
}
    The following limits apply to data uploaded to the Localytics Push API:
| Property | Description | 
|---|---|
| messages | An array of message payloads which specify the push messages that should be delivered | 
| message_attributes(optional) | Optional, platform-specific attributes to be added to the message request body. | 
| target_type | "audience_id", "profile", or "broadcast" | 
| app_id | The Localytics application ID for the application sending the message | 
| campaign_key | Specifies the campaign identifier and creates a performance report in your account’s dashboard. Set as null if no performance report is needed. | 
| request_id | Specify to uniquely identify your request. Typically, you will send a GUID/UUID in this field. Localytics will handle automatically de-duping messages that are received for the same request_id. | 
| Property | Description | 
|---|---|
| target | The specific Customer ID, Audience ID, or profile rules you want to target. If your target is broadcast, pass "null" or do not specify a target. | 
| alert | The text of the push message to send | 
| iOS | Optional. Use to include iOS-specific information | 
| android | Optional. Use to include Android-specific information | 
| sound (optional) | iOS only. The name of the sound file to play. This file must be part of the app package | 
| badge (optional) | iOS only. The unread ‘badge’ number to show | 
| extra (optional) | Any additional key value data to send along to the app. Your app must be configured to understand how to parse the key/value information. This can be useful for things like deep-linking into particular parts of the app |