DirectData API

Introduction

The goal of Pushnami DirectData API is to enable clients to send personalized push notification to subscribers. This method will utilize client’s external data sources and services, rather than a blanket title/notification text and/or variables stored in the Pushnami database. The approach follows a well know WebHook pattern (https://en.wikipedia.org/wiki/Webhook ), and will be initialized by configuring a templatized URL into a push campaign form in Pushnami Admin application. The URL will point to an existing client API which will accept query string and return a payload with push data. The result will be specific to the parameters provided in the query string, and will contain information to be delivered web push notifications, such as title, message, URL, etc.

Input

DirectData API will be called using HTTP GET method. It will take a query string as an input. Query string can contain hardcoded values or templates that will be populated with subscriber variables. E.g.

http://someaddress.com/some-api?l={{=data.zip}}&q={{=data.job}}&ip={{=data.ip}}&ver=2&c1=AAA

Parameters will be fetched from Pushnami database, and can realize the following use cases:

  • Segment shaping – e.g. country, state, mobile/desktop
  • Individual variables (provided on subscription) – IP, location, query
  • Client defined IDs (provided on subscription) – to fetch data form client’s databases or services

Result Codes

DirectData API implementations are expected to return one of the following HTTP codes.

  • 200 - Success
  • 400 – Error: Invalid request
  • 500 – Error: Internal API error

Error codes 400 and 500 will trigger a fallback on the default campaign title/message/URL. Success code 200 will bring back a valid push data payload.

Output

DirectData API will produce a response in a form of a JSON payload with the following structure:

{
"title": "My special title text",
"message": "My special notification text",
"url": "http://mysite.com/some-service?a=aaa&b=bbb&c=ccc",
"icon": "http://mysite.com/some-icon/icon-id"
}

All data elements are optional, if not returned the system will fallback on a default campaign value. E.g. if icon is not provided the default campaign item will be used.

Notes

  • DirectData API has 5 seconds to deliver a personalized result. If it takes longer – Pushnami will fall back on the default campaign values for title, message, etc.
  • Different devices/browsers will show notification in a slightly different manner –see text limits in the table below

Title/Message Limits

Chrome (Android) Chrome (Desktop) Safari Firefox
Title 30 50 40 30
Message 20-40 120 100 30