Send a notification to a recipient (v2)

Purpose

Sends a notification to a given recipient_key or a token.
If you do not want to register a recipient first, you have the option of sending it just to token you provide.

URL

Sandbox

https://sandbox.httpush.com/ACCOUNT_KEY/v2/recipient/notification.json
https://sandbox.httpush.com/ACCOUNT_KEY/v2/recipient/notification.xml

Production

https://production.httpush.com/ACCOUNT_KEY/v2/recipient/notification.json
https://production.httpush.com/ACCOUNT_KEY/v2/recipient/notification.xml

Find your ACCOUNT_KEY on the dashboard at the management web site.

HTTP Method

POST

Formats

JSON, XML

Requires Authentication

Yes (about Authentication)

Parameters

Send the parameters as either JSON or XML data as the body of your request.

Example JSON data

  {"a": "05673b6d12c796afc0cb74849e60573949bf2521", "b": "{\"aps\":{\"badge\":1,\"alert\":\"Hi from squidshot!\"}}", "r": "test"}
  {"a": "05673b6d12c796afc0cb74849e60573949bf2521", "b": "{\"aps\":{\"badge\":1,\"alert\":\"Hi from squidshot!\"}}", "t": "1ab182418e3bca321dab504f96dd0339869eef0c"}

Example XML data

  <?xml version="1.0" encoding="UTF-8"?>
  <notification>
    <a>05673b6d12c796afc0cb74849e60573949bf2521</a>
    <b>{"aps":{"badge":1,"alert":"Hi from squidshot!"}}</b>
    <r>test</r>
  </notification>
  <?xml version="1.0" encoding="UTF-8"?>
  <notification>
    <a>05673b6d12c796afc0cb74849e60573949bf2521</a>
    <b>{"aps":{"badge":1,"alert":"Hi from squidshot!"}}</b>
    <t>1ab182418e3bca321dab504f96dd0339869eef0c</t>
  </notification>

Responses

See return codes for all codes, here are specific ones

  400   {"error" : "error parsing the json input"}
  400   {"error" : "application_hash missing in notification"}
  400   {"error" : "json body is missing in notification"}
  400   {"error" : "recipient missing in notification"}
  400   {"error" : "recipient not found"}
  400   {"error" : "application_hash not found"}
  400   {"error" : "no apns token set registered for recipient"}

XML returns the same errors string like JSON.

  <?xml version="1.0" encoding="UTF-8"?>
  <errors>
    <error>application_hash has wrong length</error>
  </errors>

Usage examples

cURL (about cURL)

  curl -k -X POST -d '{"a": "05673b6d12c796afc0cb74849e60573949bf2521", "b": "{\"aps":{\"badge\":1,\"alert\":"Hi from squidshot!\"}}", "r": "test"}' -u 'c3bb3b10864278055b3873503629904b98862895:1ab182418e3bca321dab504f96dd0339869eef0c' https://sandbox.httpush.com/ACCOUNT_KEY/v2/recipient/notification.json
  curl -k -X POST -d '{"a": "05673b6d12c796afc0cb74849e60573949bf2521", "b": "{\"aps\":{\"badge\":1,\"alert\":\"Hi from squidshot!\"}}", "t": "1ab182418e3bca321dab504f96dd0339869eef0c"}' -u 'c3bb3b10864278055b3873503629904b98862895:1ab182418e3bca321dab504f96dd0339869eef0c' https://sandbox.httpush.com/ACCOUNT_KEY/v2/recipient/notification.json
  curl -k -X POST -d '<?xml version="1.0" encoding="UTF-8"?><notification><a>05673b6d12c796afc0cb74849e60573949bf2521</a><b>{"aps":{"badge":1,"alert":"Hi from squidshot!"}}</b><r>test</r></notification>' -u 'c3bb3b10864278055b3873503629904b98862895:1ab182418e3bca321dab504f96dd0339869eef0c' https://sandbox.httpush.com/ACCOUNT_KEY/v2/recipient/notification.xml
  curl -k -X POST -d '<?xml version="1.0" encoding="UTF-8"?><notification><a>05673b6d12c796afc0cb74849e60573949bf2521</a><b>{"aps":{"badge":1,"alert":"Hi from squidshot!"}}</b><t>1ab182418e3bca321dab504f96dd0339869eef0c</t></notification>' -u 'c3bb3b10864278055b3873503629904b98862895:1ab182418e3bca321dab504f96dd0339869eef0c' https://sandbox.httpush.com/ACCOUNT_KEY/v2/recipient/notification.xml

Do you have an example to share in the language of your choice? Please share!