Code

You'll first need an account to send notifications. If you don't have an account already, create one with Try it Out, otherwise Login.

Sending Notifications

Here is a few examples of how to send a message with Pushback.

You can also get the first reply to your message adapting the code below to use Synchronous Mode.

Bash

curl -s https://api.pushback.io/v1/send \
    -u <at_token>: \
    -d 'id=user_1' \
    -d 'title=My friends' \
    -d 'body=Do you want to hangout later?' \
    -d 'action1=Yes' \
    -d 'action2=No' \
    -d 'reply=Make Excuse'

Ruby

require "net/http"
require "json"

uri = URI('https://api.pushback.io/v1/send')
req = Net::HTTP::Post.new uri,
                          'Content-Type' => 'application/json',
                          'Authorization' => 'Bearer <at_token>'
req.body = {
  id: 'user_1',
  title: 'Bitcoin price increased',
  action1: 'Buy Now!',
  action2: 'Sell Everything',
}.to_json
res = Net::HTTP.start(uri.hostname, uri.port,
                      use_ssl: true) { |http| http.request(req) }

Python

import requests
data = {
  "id": 'user_1',
  "title": 'Bitcoin price decreased',
  "body": 'What should we do?',
  "action1": 'Buy Now!',
  "action2": 'Sell Everything',
}
r = requests.post("https://api.pushback.io/v1/send",
        json=data,
        headers={"Authorization": "Bearer <at_token>"})

Go

values := map[string]string{
  "id":      "user_1",
  "title":   "Allow Dan to login?",
  "action1": "Sure",
  "action2": "Nah",
}
jsonData, err := json.Marshal(values)
// check err
req, err := http.NewRequest("POST",
    "https://api.pushback.io/v1/send",
    bytes.NewBuffer(jsonData))
// check err
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer <at_token>")
resp, err := http.DefaultClient.Do(req)
// check err
defer resp.Body.Close()