Introduction
What is Catapush?
Catapush is a simple, reliable and scalable delivery API for transactional push notifications for mobile applications
What is API documentation for?
Simple APIs allow you to integrate the Catapush’s reliable Mobile Push Notification Gateway into your mobile application, quickly and simply. In the following paragraphs we’ll show you how to send push messages and receive single message status report using various different programming languages.
If you need any assistance in getting our APIs working, we’ll be happy to help.
Postman Collection
To test our REST API calls you can download and import the Postman Collection.
Authentication
To call authenticated endpoints you have to provide a token.
This token (usually called access_token) can be provided:
- in the header of the request Authorization:Bearer TOKEN (preferred way, suggested by OAuth2 RFC);
- as the HTTP Parameter access_token.
There are two types of access_token:
- a permanent token that is displayed inside your panel, it will never change until you manually regenerate it;
- a temporary access token obtained through the OAuth2 endpoint (client_id and client_secret, available in your panel, must be provided for the Client Credentials Grant).
Rest alternatives - SOAP
Instead of REST endpoints, Catapush also support a SOAP (Simple Object Access Protocol) endpoint. The WSDL is available at
http://api.catapush.com/soap/1/?wsdl
.By clicking the soap label on the top right corner you will be able to see some examples of SOAP request and response for each endpoint.
Validation
Some query parameters and json properties are validated against length restrictions or regex patterns, that are highlighted in the following documentation. By using the schema provided for some endpoints it is possible to validate a json object using tools like Json Schema Lint validator. “Safe Characters” refers to those properties that must not contain non-printable and non-utf8 characters (this is done to enforce a safe encoding that is supported by most devices). This restriction can be bypassed by using an encoding scheme like Base64.
Errors
In case of errors, the APIs provide information in two different ways:
- in the response header through status code and header messages;
- in the response body.
Error status codes are in the range 4xx (errors that can be corrected by the user) or 5xx (errors related to the service).
Typical response body is:
{
"detail": "Detailed description of the error",
"status": 403,
"title": "Short description of the error"
}
The title of the response, also present in the header, is immutable, so that it can be used together with the status code to trigger specific actions while developing the api. Many titles are shared throught differente APIs.
The detail field, instead, can vary depending of api version and developers should not embed them in their code.
The Catapush API may return following errors on every request, together with those specific for any endpoint:
Status Code | Status Name | Title | Details |
---|---|---|---|
400 | Bad Request | Bad Request | |
401 | Unauthorized | invalid_grant | OAuth related - This can happen if the user or Catapush revoked or expired an access token. To fix, you should re-authenticate the user. |
403 | Forbidden | invalid_request | OAuth related - Wrong consumer key, bad nonce, expired timestamp, etc. Unfortunately, re-authenticating the user won’t help here. |
403 | Forbidden | Wrong Authentication | |
404 | Not Found | Missing Required Parameters | |
500 | Internal Server Error | Application Generic Error |
Please check [rfc6749#section-5.2](http://tools.ietf.org/html/rfc6749#section-5.2) for a detailed explanation of OAuth related errors.
Calling a non-existing endpoint will trigger a 400 - Bad Request - error
SMS Fallback
Reach your users even when they lost mobile data connectivity. Catapush system can automatically send an SMS to all users who didn’t receive the push notification within a predefined timeframe after message expiry.
To send them, Catapush has partnered with Skebby, a company that delivers SMS internationally at the best price available. Furthermore it has been proven to be very reliable and scalable.
To setup the integration please follow the instructions provided in the SMS Fallback Panel in your app panel: you will need to enter the Skebby account details and set their settings appropriately.
You can then enable SMS Fallback for every push sent through the fallback property available in the push notification object: check the related section for more details (expand the optional fields).
2 Way
2Way allows you to receive push messages from mobile app directly on your own server through a HTTP call.
You can choose between GET and POST method. Depending on this choice parameters will be sent as an HTTP Get Query or in the Raw Request Body.
More details about the parameters received may be read in the 2Way Documentation page.
Channels
Catapush provides you the possibilities to create different channels or conversation threads like Whatsapp does for example to enable end user interaction with different internal department Sales, Administration, Support,.. Our channel feature is available both for SDKs as well as on our White Label Messenger.
You can create and add a channel simply and any time by yourselves via API. Simply add the channel name as it were the name of a contact in a messaging app. The channel will be created both in the app and when the app starts the end users can start the conversation by selection one of the channel you created for them. Simply add the channel name using our API if and when required. Catapush adds a parameter for the channel and there will not be a control panel for managing this feature.
Once multiple channels are created and you send a message via an API call you you must define an additional parameter i.e. the chosen channel; similarly when you receive an incoming message from you end users there will be another parameter that is the channel declared on the app which enable you to recognise the conversation and forward the message to the right internal end point.
API
Follows the specifications of the endpoints available. Check the right column for a snippet of code based on the example available for each method.
1 Authentication
Generate authentication tokens or invalidate them. Authentication tokens must be provided to authenticated endpoints. A permanent authentication token is provided in the client panel.
1.1 OAuth authentication
You can authenticate using OAuth2 protocol. The only currently supported method is client_credentials.
1.1.1 POST - Acquire an access token
Get access token
<?php
// Requirement: Client URL Library (see http://php.net/manual/en/book.curl.php)
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.catapush.com/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request POST \
--url 'https://api.catapush.com/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'
// Requirement: Unirest Library (see http://unirest.io/java.html)
HttpResponse<String> response = Unirest.post("https://api.catapush.com/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.catapush.com/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
const http = require("https");
const options = {
"method": "POST",
"hostname": "api.catapush.com",
"port": null,
"path": "/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
/* Requirement: libcurl library (see https://curl.haxx.se/libcurl/) */
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.catapush.com/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
/* Requirement: RestSharp library (see http://restsharp.org/) */
var client = new RestClient("https://api.catapush.com/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.catapush.com/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.catapush.com/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
response = http.request(request)
puts response.read_body
# Requirement: Python3 HTTP Client library (see https://docs.python.org/3/library/http.client.html)
import http.client
conn = http.client.HTTPSConnection("api.catapush.com")
headers = {
'Accept': "application/json",
'Content-Type': "application/json"
}
conn.request("POST", "/1/auth/oauth?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:authOauthCreate>
<params>
<client_id>user1</client_id>
<client_secret>pass1</client_secret>
<grant_type>client_credentials</grant_type>
</params>
</soap:authOauthCreate>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://api.catapush.com/soap/">
<SOAP-ENV:Body>
<ns1:authOauthCreateResponse>
<authOauthCreateResult>
<grant_type>client_credentials</grant_type>
<access_token>ACCESS_TOKEN</access_token>
</authOauthCreateResult>
</ns1:authOauthCreateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Acquire an access token in various fashions, depending on the value of **grant_type**:
- `client_credentials`
Exchanges your client credentials for an *access token* via HTTP basic authentication as described in the [OAuth 2.0 Specification Section 4.4](http://tools.ietf.org/html/rfc6749#section-4.4). Both client_id and client_secret (which can be found in your panel) have to be sent. This token expire after some hours (differently from the one provided through your dashboard, which is permanent).
HTTP Request
POST https://api.catapush.com/1/auth/oauth
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
client_id | false | The client id | |
client_secret | false | The client secret | |
grant_type | false | Grant method, actually only `client_credentials` is supported |
Responses
200 - Returns the current (or newly issued) access token (“Bearer Token”)
Content-type: application/json
Examples:
{
"grant_type": "client_credentials",
"access_token": "2YotnFZFEjr1zCsicMWpAA",
"expires_in": 3600
}
400 - HTTP 400 [bad request]
See rfc6749#section-5.2 for a detailed explanation of all possible error responses and how to interpret them
Content-type: application/json - unsupported_grant_type
Examples:
{
"error": "unsupported_grant_type"
}
Content-type: application/json - invalid_client
Examples:
{
"error": "invalid_client"
}
1.1.2 DELETE - Invalidate every access token
Invalidate access token
<?php
// Requirement: Client URL Library (see http://php.net/manual/en/book.curl.php)
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.catapush.com/1/auth/oauth",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Bearer ACCESS_TOKEN",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request DELETE \
--url https://api.catapush.com/1/auth/oauth \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json'
// Requirement: Unirest Library (see http://unirest.io/java.html)
HttpResponse<String> response = Unirest.delete("https://api.catapush.com/1/auth/oauth")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer ACCESS_TOKEN")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("DELETE", "https://api.catapush.com/1/auth/oauth");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer ACCESS_TOKEN");
xhr.send(data);
const http = require("https");
const options = {
"method": "DELETE",
"hostname": "api.catapush.com",
"port": null,
"path": "/1/auth/oauth",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer ACCESS_TOKEN"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
/* Requirement: libcurl library (see https://curl.haxx.se/libcurl/) */
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.catapush.com/1/auth/oauth");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer ACCESS_TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
/* Requirement: RestSharp library (see http://restsharp.org/) */
var client = new RestClient("https://api.catapush.com/1/auth/oauth");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer ACCESS_TOKEN");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.catapush.com/1/auth/oauth"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer ACCESS_TOKEN")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.catapush.com/1/auth/oauth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Delete.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer ACCESS_TOKEN'
response = http.request(request)
puts response.read_body
# Requirement: Python3 HTTP Client library (see https://docs.python.org/3/library/http.client.html)
import http.client
conn = http.client.HTTPSConnection("api.catapush.com")
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer ACCESS_TOKEN"
}
conn.request("DELETE", "/1/auth/oauth", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:authOauthDeleteList>
<auth>
<access_token>ACCESS_TOKEN</access_token>
</auth>
</soap:authOauthDeleteList>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://api.catapush.com/soap/">
<SOAP-ENV:Body>
<ns1:authOauthDeleteListResponse>
<authOauthDeleteListResult>true</authOauthDeleteListResult>
</ns1:authOauthDeleteListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Invalidate every access token for your user
HTTP Request
DELETE https://api.catapush.com/1/auth/oauth
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
access_token | false | Used to send a valid access token. Do not use together with the “Authorization” header |
Responses
200 - Access token deleted correctly
Content-type: application/json
Examples:
true
2 Message
Send a push message to your users.
2.1 POST - Send a new message
Send a message
<?php
// Requirement: Client URL Library (see http://php.net/manual/en/book.curl.php)
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.catapush.com/1/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{ \"mobileAppId\":2, \"text\":\"lorem ipsum dolor\", \"recipients\":[ { \"identifier\":\"johndoe\", \"recipientRef\":\"testreference-johndoe\" } ], \"notificationText\":\"notification message\", \"messageRef\":\"testreference\", \"devicesData\":{ \"ios\":{ \"badge\":2, \"soundPath\":\"folder/sound.mp3\", \"category\":\"test\", \"customData\":{ \"exampleKey\":\"exampleValue\" } }, \"android\":{ \"title\":\"test\" } }, \"notifyCallback\":{ \"method\":\"post\", \"url\":\"http://yoursite/notify-callback\" } }",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Bearer ACCESS_TOKEN",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request POST \
--url https://api.catapush.com/1/messages \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{ "mobileAppId":2, "text":"lorem ipsum dolor", "recipients":[ { "identifier":"johndoe", "recipientRef":"testreference-johndoe" } ], "notificationText":"notification message", "messageRef":"testreference", "devicesData":{ "ios":{ "badge":2, "soundPath":"folder/sound.mp3", "category":"test", "customData":{ "exampleKey":"exampleValue" } }, "android":{ "title":"test" } }, "notifyCallback":{ "method":"post", "url":"http://yoursite/notify-callback" } }'
// Requirement: Unirest Library (see http://unirest.io/java.html)
HttpResponse<String> response = Unirest.post("https://api.catapush.com/1/messages")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer ACCESS_TOKEN")
.body("{ \"mobileAppId\":2, \"text\":\"lorem ipsum dolor\", \"recipients\":[ { \"identifier\":\"johndoe\", \"recipientRef\":\"testreference-johndoe\" } ], \"notificationText\":\"notification message\", \"messageRef\":\"testreference\", \"devicesData\":{ \"ios\":{ \"badge\":2, \"soundPath\":\"folder/sound.mp3\", \"category\":\"test\", \"customData\":{ \"exampleKey\":\"exampleValue\" } }, \"android\":{ \"title\":\"test\" } }, \"notifyCallback\":{ \"method\":\"post\", \"url\":\"http://yoursite/notify-callback\" } }")
.asString();
const data = JSON.stringify({
"mobileAppId": 2,
"text": "lorem ipsum dolor",
"recipients": [
{
"identifier": "johndoe",
"recipientRef": "testreference-johndoe"
}
],
"notificationText": "notification message",
"messageRef": "testreference",
"devicesData": {
"ios": {
"badge": 2,
"soundPath": "folder/sound.mp3",
"category": "test",
"customData": {
"exampleKey": "exampleValue"
}
},
"android": {
"title": "test"
}
},
"notifyCallback": {
"method": "post",
"url": "http://yoursite/notify-callback"
}
});
const xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.catapush.com/1/messages");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer ACCESS_TOKEN");
xhr.send(data);
const http = require("https");
const options = {
"method": "POST",
"hostname": "api.catapush.com",
"port": null,
"path": "/1/messages",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer ACCESS_TOKEN"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
mobileAppId: 2,
text: 'lorem ipsum dolor',
recipients: [{identifier: 'johndoe', recipientRef: 'testreference-johndoe'}],
notificationText: 'notification message',
messageRef: 'testreference',
devicesData: {
ios: {
badge: 2,
soundPath: 'folder/sound.mp3',
category: 'test',
customData: {exampleKey: 'exampleValue'}
},
android: {title: 'test'}
},
notifyCallback: {method: 'post', url: 'http://yoursite/notify-callback'}
}));
req.end();
/* Requirement: libcurl library (see https://curl.haxx.se/libcurl/) */
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.catapush.com/1/messages");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer ACCESS_TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{ \"mobileAppId\":2, \"text\":\"lorem ipsum dolor\", \"recipients\":[ { \"identifier\":\"johndoe\", \"recipientRef\":\"testreference-johndoe\" } ], \"notificationText\":\"notification message\", \"messageRef\":\"testreference\", \"devicesData\":{ \"ios\":{ \"badge\":2, \"soundPath\":\"folder/sound.mp3\", \"category\":\"test\", \"customData\":{ \"exampleKey\":\"exampleValue\" } }, \"android\":{ \"title\":\"test\" } }, \"notifyCallback\":{ \"method\":\"post\", \"url\":\"http://yoursite/notify-callback\" } }");
CURLcode ret = curl_easy_perform(hnd);
/* Requirement: RestSharp library (see http://restsharp.org/) */
var client = new RestClient("https://api.catapush.com/1/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer ACCESS_TOKEN");
request.AddParameter("application/json", "{ \"mobileAppId\":2, \"text\":\"lorem ipsum dolor\", \"recipients\":[ { \"identifier\":\"johndoe\", \"recipientRef\":\"testreference-johndoe\" } ], \"notificationText\":\"notification message\", \"messageRef\":\"testreference\", \"devicesData\":{ \"ios\":{ \"badge\":2, \"soundPath\":\"folder/sound.mp3\", \"category\":\"test\", \"customData\":{ \"exampleKey\":\"exampleValue\" } }, \"android\":{ \"title\":\"test\" } }, \"notifyCallback\":{ \"method\":\"post\", \"url\":\"http://yoursite/notify-callback\" } }", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.catapush.com/1/messages"
payload := strings.NewReader("{ \"mobileAppId\":2, \"text\":\"lorem ipsum dolor\", \"recipients\":[ { \"identifier\":\"johndoe\", \"recipientRef\":\"testreference-johndoe\" } ], \"notificationText\":\"notification message\", \"messageRef\":\"testreference\", \"devicesData\":{ \"ios\":{ \"badge\":2, \"soundPath\":\"folder/sound.mp3\", \"category\":\"test\", \"customData\":{ \"exampleKey\":\"exampleValue\" } }, \"android\":{ \"title\":\"test\" } }, \"notifyCallback\":{ \"method\":\"post\", \"url\":\"http://yoursite/notify-callback\" } }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer ACCESS_TOKEN")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.catapush.com/1/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer ACCESS_TOKEN'
request.body = "{ \"mobileAppId\":2, \"text\":\"lorem ipsum dolor\", \"recipients\":[ { \"identifier\":\"johndoe\", \"recipientRef\":\"testreference-johndoe\" } ], \"notificationText\":\"notification message\", \"messageRef\":\"testreference\", \"devicesData\":{ \"ios\":{ \"badge\":2, \"soundPath\":\"folder/sound.mp3\", \"category\":\"test\", \"customData\":{ \"exampleKey\":\"exampleValue\" } }, \"android\":{ \"title\":\"test\" } }, \"notifyCallback\":{ \"method\":\"post\", \"url\":\"http://yoursite/notify-callback\" } }"
response = http.request(request)
puts response.read_body
# Requirement: Python3 HTTP Client library (see https://docs.python.org/3/library/http.client.html)
import http.client
conn = http.client.HTTPSConnection("api.catapush.com")
payload = "{ \"mobileAppId\":2, \"text\":\"lorem ipsum dolor\", \"recipients\":[ { \"identifier\":\"johndoe\", \"recipientRef\":\"testreference-johndoe\" } ], \"notificationText\":\"notification message\", \"messageRef\":\"testreference\", \"devicesData\":{ \"ios\":{ \"badge\":2, \"soundPath\":\"folder/sound.mp3\", \"category\":\"test\", \"customData\":{ \"exampleKey\":\"exampleValue\" } }, \"android\":{ \"title\":\"test\" } }, \"notifyCallback\":{ \"method\":\"post\", \"url\":\"http://yoursite/notify-callback\" } }"
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer ACCESS_TOKEN"
}
conn.request("POST", "/1/messages", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:messagesCreate>
<data>
<mobileAppId>2</mobileAppId>
<text>lorem ipsum dolor</text>
<recipients>
<item>
<identifier>johndoe</identifier>
<recipientRef>testreference-johndoe</recipientRef>
</item>
</recipients>
<notificationText>notification message</notificationText>
<messageRef>testreference</messageRef>
<devicesData>
<ios>
<badge>2</badge>
<soundPath>folder/sound.mp3</soundPath>
<category>test</category>
<customData>
<exampleKey>exampleValue</exampleKey>
</customData>
</ios>
<android>
<title>test</title>
</android>
</devicesData>
<notifyCallback>
<method>post</method>
<url>http://yoursite/notify-callback</url>
</notifyCallback>
</data>
<auth>
<access_token>ACCESS_TOKEN</access_token>
</auth>
</soap:messagesCreate>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://api.catapush.com/soap/">
<SOAP-ENV:Body>
<ns1:messagesCreateResponse>
<messagesCreateResult>
<messageId>id-test-message</messageId>
<createdAt>2015-04-26T01:37:17Z</createdAt>
<mobileAppId>2</mobileAppId>
<text>lorem ipsum dolor</text>
<recipients>
<item>
<identifier>johndoe</identifier>
<recipientRef>testreference-johndoe</recipientRef>
</item>
</recipients>
<notificationText>notification message</notificationText>
<messageRef>testreference</messageRef>
<devicesData>
<ios>
<badge>2</badge>
<soundPath>folder/sound.mp3</soundPath>
<category>test</category>
<customData>
<exampleKey>exampleValue</exampleKey>
</customData>
</ios>
<android>
<title>test</title>
</android>
</devicesData>
<notifyCallback>
<method>post</method>
<url>http://yoursite/notify-callback</url>
<logLevel>info</logLevel>
</notifyCallback>
</messagesCreateResult>
</ns1:messagesCreateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP Request
POST https://api.catapush.com/1/messages
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
access_token | false | Used to send a valid access token. Do not use together with the “Authorization” header |
Body
Content-type: application/json
{ "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "title": "Message", "description": "Message to be sent to a User", "type": "object", "properties": { "mobileAppId": { "description": "Unique identifier of the mobile app", "type": "integer" }, "text": { "description": "Text of the message", "type": "string", "minLength": 1, "maxLength": 32768, "charset": "safe" }, "recipients": { "title": "Define message recipients", "type": "array", "minItems": 1, "items": { "title": "Recipient", "type": "object", "properties": { "identifier": { "description": "Identifier of the recipient (can be a phonenumber or the username used to login in the app)", "type": "string", "pattern": "^[!-~]{1,100}$" }, "recipientRef": { "description": "Custom identifier of the single dispatch to the recipient, expecially useful to track status", "type": "string", "pattern": "^[a-zA-Z0-9._-]{5,100}$", "charset": "safe" }, "override": { "title": "Override some parameters for the recipient", "type": "object", "properties": { "text": { "description": "Override normal text for the recipient", "type": "string", "maxLength": 32768, "charset": "safe" }, "mobileNumber": { "description": "Recipient number (international format without + or 00) used to send the SMS Fallback. By default the recipient identifier is used", "type": "string", "pattern": "^[0-9]{8,}$" } } } }, "required": [ "identifier" ], "defaultProperties": [ "identifier" ] }, "uniqueItems": true }, "notificationText": { "description": "Text shown as the notification message from the device (in the notification bar). If not present, text is used", "type": "string", "minLength": 1, "maxLength": 400, "charset": "safe" }, "channel": { "description": "Provides you the possibilities to create different channels or conversation threads like Whatsapp does, for example to enable end user interaction with different internal department Sales, Administration, Support", "type": "string", "minLength": 1, "maxLength": 100, "charset": "safe" }, "messageRef": { "description": "Custom identifier of the message", "type": "string", "pattern": "^[a-zA-Z0-9_-]{5,50}$", "charset": "safe" }, "expireTime": { "description": "Seconds after creation after which the message is discarded if still undelivered (by default 2 days)", "type": "integer", "minimum": 1, "maximum": 2592000, "default": 172800 }, "isMarketing": { "description": "Set if the message is a marketing message or if is massive sending of single different push. Our backend is optimized to handle different types of traffic, 'transactional' as the default setting. For campaigns or massive sending, please enable this flag.", "type": "boolean", "default": false }, "optionalData": { "description": "Custom key-value pairs of the message's payload, value type must be string, key must not contain $ and . characters", "type": [ "object", "null" ], "default": null }, "devicesData": { "title": "Push options for every device type", "type": "object", "properties": { "ios": { "title": "IOS devices", "type": "object", "properties": { "badge": { "description": "Badge number", "type": "integer", "minimum": 0, "maximum": 2147483647, "default": 0 }, "soundPath": { "description": "Sound path (leave null for default)", "type": [ "string", "null" ], "default": null, "maxLength": 32768 }, "category": { "description": "Category used for custom actions", "type": [ "string", "null" ], "default": null, "maxLength": 100 }, "customData": { "description": "Custom object (see official Apple Documentation at https:\/\/apple.co\/3cdpKmu for more details). Keys must not contain $ and . characters", "type": [ "object", "null" ], "default": null }, "alert": { "description": "Text to display the standard alert or a banner (string or object, the object must contain the properties defined at https:\/\/apple.co\/3gnrThd). Catapush sets the value for alert for the native push notification only when the recipient is using the Catapush iOS version >= 2.x . This is the text that is showed to the user if there is some unexpected behaviour with the Notification Service Extension and for some reason iOS ignore the Notification Extension and just display the text of the native push notification.", "type": [ "object", "string", "null" ], "default": null, "maxLength": 4096 }, "interruptionLevel": { "description": "A string that indicates the importance and delivery timing of a notification. The string values correspond to the UNNotificationInterruptionLevel (https:\/\/developer.apple.com\/documentation\/usernotifications\/unnotificationinterruptionlevel) enumeration cases.", "type": [ "string", "null" ], "enum": [ "passive", "active", "time-sensitive", "critical" ], "default": null }, "relevanceScore": { "description": "The relevance score, a number between 0 and 1, that the system uses to sort the notifications from your app. The highest score gets featured in the notification summary. (https:\/\/developer.apple.com\/documentation\/usernotifications\/unnotificationcontent\/3821031-relevancescore)", "type": [ "float", "null" ], "default": null, "minimum": 0, "maximum": 1 } } }, "android": { "title": "Android devices", "type": "object", "properties": { "title": { "description": "Title of the message", "type": "string", "maxLength": 400, "charset": "safe" }, "data": { "description": "Custom key-value pairs of the message's payload, value type can be boolean, numeric or string. Keys must not contain $ and . characters", "type": [ "object", "null" ], "default": null } } }, "huawei": { "title": "Huawei devices", "type": "object", "properties": { "title": { "description": "Title of the message", "type": "string", "maxLength": 400, "charset": "safe" }, "data": { "description": "Custom key-value pairs of the message's payload, value type can be boolean, numeric or string. Keys must not contain $ and . characters", "type": [ "object", "null" ], "default": null } } } } }, "notifyCallback": { "title": "Notify Callback", "description": "Endpoint used to receive notifications of message status changes, this can also be set on a per-app basis through the app panel (check https:\/\/www.catapush.com\/quickstarts\/push-notification-delivery-callback for more details)", "type": "object", "properties": { "url": { "description": "Url used to send the callback", "type": "string", "format": "uri" }, "method": { "description": "Method used for the callback", "type": "string", "enum": [ "get", "post" ] }, "logLevel": { "description": "Logging level", "type": "string", "enum": [ "info", "debug" ], "default": "info" } }, "required": [ "url", "method" ] }, "fallback": { "title": "SMS fallback", "description": "Enable the SMS fallback if condition is verified after a custom amount of time", "type": "object", "properties": { "timeout": { "description": "Seconds after which the message will be sent", "type": "integer", "minimum": 10, "maximum": 864000, "default": 60 }, "validityPeriod": { "description": "How many seconds the operator must retry to send the SMS in case of phone turned off or unreachable", "type": "integer", "minimum": 300, "maximum": 864000, "default": 172800 }, "condition": { "description": "SMS will be sent if the condition specified is true after the specified amount of time", "type": "string", "enum": [ "undelivered", "unread" ], "default": "undelivered" }, "text": { "description": "Text of the message (characters [,\\,],^,{,|,},~,\u20ac are long 2)", "type": "string", "maxLength": 1530, "pattern": "^[\\u0020-\\u007E\u00a3\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\\r\u00d8\u00f8\n\u00c5\u00e5\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\\u001B\u00c6\u00e6\u00df\u00c9 \u00a4\u00a1\u00c4\u00d6\u00d1\u00dc\u00a7\u00bf\u00e4\u00f6\u00f1\u00fc\u00e0\\u000C\u20ac]*$" }, "senderNumber": { "description": "Allows to specify any phone number you want as sender ID, the number must be in international format without + or 00, e.g.: 393334455666", "type": "string", "pattern": "^[0-9]*$" }, "senderString": { "description": "Allows to specify an alphanumeric string of maximum 11 characters to use as sender name", "type": "string", "pattern": "^[a-zA-Z0-9 .]{0,11}$" } } } }, "required": [ "mobileAppId", "text", "recipients" ], "defaultProperties": [ "mobileAppId", "text", "recipients" ] }
Schema:
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"title": "Message",
"description": "Message to be sent to a User",
"type": "object",
"properties": {
"mobileAppId": {
"description": "Unique identifier of the mobile app",
"type": "integer"
},
"text": {
"description": "Text of the message",
"type": "string",
"minLength": 1,
"maxLength": 32768,
"charset": "safe"
},
"recipients": {
"title": "Define message recipients",
"type": "array",
"minItems": 1,
"items": {
"title": "Recipient",
"type": "object",
"properties": {
"identifier": {
"description": "Identifier of the recipient (can be a phonenumber or the username used to login in the app)",
"type": "string",
"pattern": "^[!-~]{1,100}$"
},
"recipientRef": {
"description": "Custom identifier of the single dispatch to the recipient, expecially useful to track status",
"type": "string",
"pattern": "^[a-zA-Z0-9._-]{5,100}$",
"charset": "safe"
},
"override": {
"title": "Override some parameters for the recipient",
"type": "object",
"properties": {
"text": {
"description": "Override normal text for the recipient",
"type": "string",
"maxLength": 32768,
"charset": "safe"
},
"mobileNumber": {
"description": "Recipient number (international format without + or 00) used to send the SMS Fallback. By default the recipient identifier is used",
"type": "string",
"pattern": "^[0-9]{8,}$"
}
}
}
},
"required": [
"identifier"
],
"defaultProperties": [
"identifier"
]
},
"uniqueItems": true
},
"notificationText": {
"description": "Text shown as the notification message from the device (in the notification bar). If not present, text is used",
"type": "string",
"minLength": 1,
"maxLength": 400,
"charset": "safe"
},
"channel": {
"description": "Provides you the possibilities to create different channels or conversation threads like Whatsapp does, for example to enable end user interaction with different internal department Sales, Administration, Support",
"type": "string",
"minLength": 1,
"maxLength": 100,
"charset": "safe"
},
"messageRef": {
"description": "Custom identifier of the message",
"type": "string",
"pattern": "^[a-zA-Z0-9_-]{5,50}$",
"charset": "safe"
},
"expireTime": {
"description": "Seconds after creation after which the message is discarded if still undelivered (by default 2 days)",
"type": "integer",
"minimum": 1,
"maximum": 2592000,
"default": 172800
},
"isMarketing": {
"description": "Set if the message is a marketing message or if is massive sending of single different push. Our backend is optimized to handle different types of traffic, 'transactional' as the default setting. For campaigns or massive sending, please enable this flag.",
"type": "boolean",
"default": false
},
"optionalData": {
"description": "Custom key-value pairs of the message's payload, value type must be string, key must not contain $ and . characters",
"type": [
"object",
"null"
],
"default": null
},
"devicesData": {
"title": "Push options for every device type",
"type": "object",
"properties": {
"ios": {
"title": "IOS devices",
"type": "object",
"properties": {
"badge": {
"description": "Badge number",
"type": "integer",
"minimum": 0,
"maximum": 2147483647,
"default": 0
},
"soundPath": {
"description": "Sound path (leave null for default)",
"type": [
"string",
"null"
],
"default": null,
"maxLength": 32768
},
"category": {
"description": "Category used for custom actions",
"type": [
"string",
"null"
],
"default": null,
"maxLength": 100
},
"customData": {
"description": "Custom object (see official Apple Documentation at https:\/\/apple.co\/3cdpKmu for more details). Keys must not contain $ and . characters",
"type": [
"object",
"null"
],
"default": null
},
"alert": {
"description": "Text to display the standard alert or a banner (string or object, the object must contain the properties defined at https:\/\/apple.co\/3gnrThd). Catapush sets the value for alert for the native push notification only when the recipient is using the Catapush iOS version >= 2.x . This is the text that is showed to the user if there is some unexpected behaviour with the Notification Service Extension and for some reason iOS ignore the Notification Extension and just display the text of the native push notification.",
"type": [
"object",
"string",
"null"
],
"default": null,
"maxLength": 4096
},
"interruptionLevel": {
"description": "A string that indicates the importance and delivery timing of a notification. The string values correspond to the UNNotificationInterruptionLevel (https:\/\/developer.apple.com\/documentation\/usernotifications\/unnotificationinterruptionlevel) enumeration cases.",
"type": [
"string",
"null"
],
"enum": [
"passive",
"active",
"time-sensitive",
"critical"
],
"default": null
},
"relevanceScore": {
"description": "The relevance score, a number between 0 and 1, that the system uses to sort the notifications from your app. The highest score gets featured in the notification summary. (https:\/\/developer.apple.com\/documentation\/usernotifications\/unnotificationcontent\/3821031-relevancescore)",
"type": [
"float",
"null"
],
"default": null,
"minimum": 0,
"maximum": 1
}
}
},
"android": {
"title": "Android devices",
"type": "object",
"properties": {
"title": {
"description": "Title of the message",
"type": "string",
"maxLength": 400,
"charset": "safe"
},
"data": {
"description": "Custom key-value pairs of the message's payload, value type can be boolean, numeric or string. Keys must not contain $ and . characters",
"type": [
"object",
"null"
],
"default": null
}
}
},
"huawei": {
"title": "Huawei devices",
"type": "object",
"properties": {
"title": {
"description": "Title of the message",
"type": "string",
"maxLength": 400,
"charset": "safe"
},
"data": {
"description": "Custom key-value pairs of the message's payload, value type can be boolean, numeric or string. Keys must not contain $ and . characters",
"type": [
"object",
"null"
],
"default": null
}
}
}
}
},
"notifyCallback": {
"title": "Notify Callback",
"description": "Endpoint used to receive notifications of message status changes, this can also be set on a per-app basis through the app panel (check https:\/\/www.catapush.com\/quickstarts\/push-notification-delivery-callback for more details)",
"type": "object",
"properties": {
"url": {
"description": "Url used to send the callback",
"type": "string",
"format": "uri"
},
"method": {
"description": "Method used for the callback",
"type": "string",
"enum": [
"get",
"post"
]
},
"logLevel": {
"description": "Logging level",
"type": "string",
"enum": [
"info",
"debug"
],
"default": "info"
}
},
"required": [
"url",
"method"
]
},
"fallback": {
"title": "SMS fallback",
"description": "Enable the SMS fallback if condition is verified after a custom amount of time",
"type": "object",
"properties": {
"timeout": {
"description": "Seconds after which the message will be sent",
"type": "integer",
"minimum": 10,
"maximum": 864000,
"default": 60
},
"validityPeriod": {
"description": "How many seconds the operator must retry to send the SMS in case of phone turned off or unreachable",
"type": "integer",
"minimum": 300,
"maximum": 864000,
"default": 172800
},
"condition": {
"description": "SMS will be sent if the condition specified is true after the specified amount of time",
"type": "string",
"enum": [
"undelivered",
"unread"
],
"default": "undelivered"
},
"text": {
"description": "Text of the message (characters [,\\,],^,{,|,},~,\u20ac are long 2)",
"type": "string",
"maxLength": 1530,
"pattern": "^[\\u0020-\\u007E\u00a3\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\\r\u00d8\u00f8\n\u00c5\u00e5\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\\u001B\u00c6\u00e6\u00df\u00c9 \u00a4\u00a1\u00c4\u00d6\u00d1\u00dc\u00a7\u00bf\u00e4\u00f6\u00f1\u00fc\u00e0\\u000C\u20ac]*$"
},
"senderNumber": {
"description": "Allows to specify any phone number you want as sender ID, the number must be in international format without + or 00, e.g.: 393334455666",
"type": "string",
"pattern": "^[0-9]*$"
},
"senderString": {
"description": "Allows to specify an alphanumeric string of maximum 11 characters to use as sender name",
"type": "string",
"pattern": "^[a-zA-Z0-9 .]{0,11}$"
}
}
}
},
"required": [
"mobileAppId",
"text",
"recipients"
],
"defaultProperties": [
"mobileAppId",
"text",
"recipients"
]
}
Examples:
{
"mobileAppId": 2,
"text": "lorem ipsum dolor",
"recipients": [
{
"identifier": "johndoe",
"recipientRef": "testreference-johndoe"
}
],
"notificationText": "notification message",
"messageRef": "testreference",
"devicesData": {
"ios": {
"badge": 2,
"soundPath": "folder/sound.mp3",
"category": "test",
"customData": {
"exampleKey": "exampleValue"
}
},
"android": {
"title": "test"
}
},
"notifyCallback": {
"method": "post",
"url": "http://yoursite/notify-callback"
}
}
Responses
200 - Message created correctly
Content-type: application/json
Schema:
{ "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "title": "Message", "description": "Message to be sent to a User", "type": "object", "properties": { "messageId": { "description": "Unique identifier of the message", "type": "string", "pattern": "^[a-zA-Z0-9_-]{5,50}$" }, "createdAt": { "description": "Creation datetime (rfc-3339)", "type": "string", "format": "date-time" }, "mobileAppId": { "description": "Unique identifier of the mobile app", "type": "integer" }, "text": { "description": "Text of the message", "type": "string", "minLength": 1, "maxLength": 32768, "charset": "safe" }, "recipients": { "title": "Define message recipients", "type": "array", "minItems": 1, "items": { "title": "Recipient", "type": "object", "properties": { "identifier": { "description": "Identifier of the recipient (can be a phonenumber or the username used to login in the app)", "type": "string", "pattern": "^[!-~]{1,100}$" }, "recipientRef": { "description": "Custom identifier of the single dispatch to the recipient, expecially useful to track status", "type": "string", "pattern": "^[a-zA-Z0-9._-]{5,100}$", "charset": "safe" }, "override": { "title": "Override some parameters for the recipient", "type": "object", "properties": { "text": { "description": "Override normal text for the recipient", "type": "string", "maxLength": 32768, "charset": "safe" }, "mobileNumber": { "description": "Recipient number (international format without + or 00) used to send the SMS Fallback. By default the recipient identifier is used", "type": "string", "pattern": "^[0-9]{8,}$" } } } }, "required": [ "identifier" ], "defaultProperties": [ "identifier" ] }, "uniqueItems": true }, "notificationText": { "description": "Text shown as the notification message from the device (in the notification bar). If not present, text is used", "type": "string", "minLength": 1, "maxLength": 400, "charset": "safe" }, "channel": { "description": "Provides you the possibilities to create different channels or conversation threads like Whatsapp does, for example to enable end user interaction with different internal department Sales, Administration, Support", "type": "string", "minLength": 1, "maxLength": 100, "charset": "safe" }, "messageRef": { "description": "Custom identifier of the message", "type": "string", "pattern": "^[a-zA-Z0-9_-]{5,50}$", "charset": "safe" }, "expireTime": { "description": "Seconds after creation after which the message is discarded if still undelivered (by default 2 days)", "type": "integer", "minimum": 1, "maximum": 2592000, "default": 172800 }, "isMarketing": { "description": "Set if the message is a marketing message or if is massive sending of single different push. Our backend is optimized to handle different types of traffic, 'transactional' as the default setting. For campaigns or massive sending, please enable this flag.", "type": "boolean", "default": false }, "optionalData": { "description": "Custom key-value pairs of the message's payload, value type must be string, key must not contain $ and . characters", "type": [ "object", "null" ], "default": null }, "devicesData": { "title": "Push options for every device type", "type": "object", "properties": { "ios": { "title": "IOS devices", "type": "object", "properties": { "badge": { "description": "Badge number", "type": "integer", "minimum": 0, "maximum": 2147483647, "default": 0 }, "soundPath": { "description": "Sound path (leave null for default)", "type": [ "string", "null" ], "default": null, "maxLength": 32768 }, "category": { "description": "Category used for custom actions", "type": [ "string", "null" ], "default": null, "maxLength": 100 }, "customData": { "description": "Custom object (see official Apple Documentation at https:\/\/apple.co\/3cdpKmu for more details). Keys must not contain $ and . characters", "type": [ "object", "null" ], "default": null }, "alert": { "description": "Text to display the standard alert or a banner (string or object, the object must contain the properties defined at https:\/\/apple.co\/3gnrThd). Catapush sets the value for alert for the native push notification only when the recipient is using the Catapush iOS version >= 2.x . This is the text that is showed to the user if there is some unexpected behaviour with the Notification Service Extension and for some reason iOS ignore the Notification Extension and just display the text of the native push notification.", "type": [ "object", "string", "null" ], "default": null, "maxLength": 4096 }, "interruptionLevel": { "description": "A string that indicates the importance and delivery timing of a notification. The string values correspond to the UNNotificationInterruptionLevel (https:\/\/developer.apple.com\/documentation\/usernotifications\/unnotificationinterruptionlevel) enumeration cases.", "type": [ "string", "null" ], "enum": [ "passive", "active", "time-sensitive", "critical" ], "default": null }, "relevanceScore": { "description": "The relevance score, a number between 0 and 1, that the system uses to sort the notifications from your app. The highest score gets featured in the notification summary. (https:\/\/developer.apple.com\/documentation\/usernotifications\/unnotificationcontent\/3821031-relevancescore)", "type": [ "float", "null" ], "default": null, "minimum": 0, "maximum": 1 } } }, "android": { "title": "Android devices", "type": "object", "properties": { "title": { "description": "Title of the message", "type": "string", "maxLength": 400, "charset": "safe" }, "data": { "description": "Custom key-value pairs of the message's payload, value type can be boolean, numeric or string. Keys must not contain $ and . characters", "type": [ "object", "null" ], "default": null } } }, "huawei": { "title": "Huawei devices", "type": "object", "properties": { "title": { "description": "Title of the message", "type": "string", "maxLength": 400, "charset": "safe" }, "data": { "description": "Custom key-value pairs of the message's payload, value type can be boolean, numeric or string. Keys must not contain $ and . characters", "type": [ "object", "null" ], "default": null } } } } }, "notifyCallback": { "title": "Notify Callback", "description": "Endpoint used to receive notifications of message status changes, this can also be set on a per-app basis through the app panel (check https:\/\/www.catapush.com\/quickstarts\/push-notification-delivery-callback for more details)", "type": "object", "properties": { "url": { "description": "Url used to send the callback", "type": "string", "format": "uri" }, "method": { "description": "Method used for the callback", "type": "string", "enum": [ "get", "post" ] }, "logLevel": { "description": "Logging level", "type": "string", "enum": [ "info", "debug" ], "default": "info" } }, "required": [ "url", "method" ] }, "fallback": { "title": "SMS fallback", "description": "Enable the SMS fallback if condition is verified after a custom amount of time", "type": "object", "properties": { "timeout": { "description": "Seconds after which the message will be sent", "type": "integer", "minimum": 10, "maximum": 864000, "default": 60 }, "validityPeriod": { "description": "How many seconds the operator must retry to send the SMS in case of phone turned off or unreachable", "type": "integer", "minimum": 300, "maximum": 864000, "default": 172800 }, "condition": { "description": "SMS will be sent if the condition specified is true after the specified amount of time", "type": "string", "enum": [ "undelivered", "unread" ], "default": "undelivered" }, "text": { "description": "Text of the message (characters [,\\,],^,{,|,},~,\u20ac are long 2)", "type": "string", "maxLength": 1530, "pattern": "^[\\u0020-\\u007E\u00a3\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\\r\u00d8\u00f8\n\u00c5\u00e5\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\\u001B\u00c6\u00e6\u00df\u00c9 \u00a4\u00a1\u00c4\u00d6\u00d1\u00dc\u00a7\u00bf\u00e4\u00f6\u00f1\u00fc\u00e0\\u000C\u20ac]*$" }, "senderNumber": { "description": "Allows to specify any phone number you want as sender ID, the number must be in international format without + or 00, e.g.: 393334455666", "type": "string", "pattern": "^[0-9]*$" }, "senderString": { "description": "Allows to specify an alphanumeric string of maximum 11 characters to use as sender name", "type": "string", "pattern": "^[a-zA-Z0-9 .]{0,11}$" } } } }, "required": [ "messageId", "createdAt", "mobileAppId", "text", "recipients" ], "defaultProperties": [ "mobileAppId", "text", "recipients" ] }
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"title": "Message",
"description": "Message to be sent to a User",
"type": "object",
"properties": {
"messageId": {
"description": "Unique identifier of the message",
"type": "string",
"pattern": "^[a-zA-Z0-9_-]{5,50}$"
},
"createdAt": {
"description": "Creation datetime (rfc-3339)",
"type": "string",
"format": "date-time"
},
"mobileAppId": {
"description": "Unique identifier of the mobile app",
"type": "integer"
},
"text": {
"description": "Text of the message",
"type": "string",
"minLength": 1,
"maxLength": 32768,
"charset": "safe"
},
"recipients": {
"title": "Define message recipients",
"type": "array",
"minItems": 1,
"items": {
"title": "Recipient",
"type": "object",
"properties": {
"identifier": {
"description": "Identifier of the recipient (can be a phonenumber or the username used to login in the app)",
"type": "string",
"pattern": "^[!-~]{1,100}$"
},
"recipientRef": {
"description": "Custom identifier of the single dispatch to the recipient, expecially useful to track status",
"type": "string",
"pattern": "^[a-zA-Z0-9._-]{5,100}$",
"charset": "safe"
},
"override": {
"title": "Override some parameters for the recipient",
"type": "object",
"properties": {
"text": {
"description": "Override normal text for the recipient",
"type": "string",
"maxLength": 32768,
"charset": "safe"
},
"mobileNumber": {
"description": "Recipient number (international format without + or 00) used to send the SMS Fallback. By default the recipient identifier is used",
"type": "string",
"pattern": "^[0-9]{8,}$"
}
}
}
},
"required": [
"identifier"
],
"defaultProperties": [
"identifier"
]
},
"uniqueItems": true
},
"notificationText": {
"description": "Text shown as the notification message from the device (in the notification bar). If not present, text is used",
"type": "string",
"minLength": 1,
"maxLength": 400,
"charset": "safe"
},
"channel": {
"description": "Provides you the possibilities to create different channels or conversation threads like Whatsapp does, for example to enable end user interaction with different internal department Sales, Administration, Support",
"type": "string",
"minLength": 1,
"maxLength": 100,
"charset": "safe"
},
"messageRef": {
"description": "Custom identifier of the message",
"type": "string",
"pattern": "^[a-zA-Z0-9_-]{5,50}$",
"charset": "safe"
},
"expireTime": {
"description": "Seconds after creation after which the message is discarded if still undelivered (by default 2 days)",
"type": "integer",
"minimum": 1,
"maximum": 2592000,
"default": 172800
},
"isMarketing": {
"description": "Set if the message is a marketing message or if is massive sending of single different push. Our backend is optimized to handle different types of traffic, 'transactional' as the default setting. For campaigns or massive sending, please enable this flag.",
"type": "boolean",
"default": false
},
"optionalData": {
"description": "Custom key-value pairs of the message's payload, value type must be string, key must not contain $ and . characters",
"type": [
"object",
"null"
],
"default": null
},
"devicesData": {
"title": "Push options for every device type",
"type": "object",
"properties": {
"ios": {
"title": "IOS devices",
"type": "object",
"properties": {
"badge": {
"description": "Badge number",
"type": "integer",
"minimum": 0,
"maximum": 2147483647,
"default": 0
},
"soundPath": {
"description": "Sound path (leave null for default)",
"type": [
"string",
"null"
],
"default": null,
"maxLength": 32768
},
"category": {
"description": "Category used for custom actions",
"type": [
"string",
"null"
],
"default": null,
"maxLength": 100
},
"customData": {
"description": "Custom object (see official Apple Documentation at https:\/\/apple.co\/3cdpKmu for more details). Keys must not contain $ and . characters",
"type": [
"object",
"null"
],
"default": null
},
"alert": {
"description": "Text to display the standard alert or a banner (string or object, the object must contain the properties defined at https:\/\/apple.co\/3gnrThd). Catapush sets the value for alert for the native push notification only when the recipient is using the Catapush iOS version >= 2.x . This is the text that is showed to the user if there is some unexpected behaviour with the Notification Service Extension and for some reason iOS ignore the Notification Extension and just display the text of the native push notification.",
"type": [
"object",
"string",
"null"
],
"default": null,
"maxLength": 4096
},
"interruptionLevel": {
"description": "A string that indicates the importance and delivery timing of a notification. The string values correspond to the UNNotificationInterruptionLevel (https:\/\/developer.apple.com\/documentation\/usernotifications\/unnotificationinterruptionlevel) enumeration cases.",
"type": [
"string",
"null"
],
"enum": [
"passive",
"active",
"time-sensitive",
"critical"
],
"default": null
},
"relevanceScore": {
"description": "The relevance score, a number between 0 and 1, that the system uses to sort the notifications from your app. The highest score gets featured in the notification summary. (https:\/\/developer.apple.com\/documentation\/usernotifications\/unnotificationcontent\/3821031-relevancescore)",
"type": [
"float",
"null"
],
"default": null,
"minimum": 0,
"maximum": 1
}
}
},
"android": {
"title": "Android devices",
"type": "object",
"properties": {
"title": {
"description": "Title of the message",
"type": "string",
"maxLength": 400,
"charset": "safe"
},
"data": {
"description": "Custom key-value pairs of the message's payload, value type can be boolean, numeric or string. Keys must not contain $ and . characters",
"type": [
"object",
"null"
],
"default": null
}
}
},
"huawei": {
"title": "Huawei devices",
"type": "object",
"properties": {
"title": {
"description": "Title of the message",
"type": "string",
"maxLength": 400,
"charset": "safe"
},
"data": {
"description": "Custom key-value pairs of the message's payload, value type can be boolean, numeric or string. Keys must not contain $ and . characters",
"type": [
"object",
"null"
],
"default": null
}
}
}
}
},
"notifyCallback": {
"title": "Notify Callback",
"description": "Endpoint used to receive notifications of message status changes, this can also be set on a per-app basis through the app panel (check https:\/\/www.catapush.com\/quickstarts\/push-notification-delivery-callback for more details)",
"type": "object",
"properties": {
"url": {
"description": "Url used to send the callback",
"type": "string",
"format": "uri"
},
"method": {
"description": "Method used for the callback",
"type": "string",
"enum": [
"get",
"post"
]
},
"logLevel": {
"description": "Logging level",
"type": "string",
"enum": [
"info",
"debug"
],
"default": "info"
}
},
"required": [
"url",
"method"
]
},
"fallback": {
"title": "SMS fallback",
"description": "Enable the SMS fallback if condition is verified after a custom amount of time",
"type": "object",
"properties": {
"timeout": {
"description": "Seconds after which the message will be sent",
"type": "integer",
"minimum": 10,
"maximum": 864000,
"default": 60
},
"validityPeriod": {
"description": "How many seconds the operator must retry to send the SMS in case of phone turned off or unreachable",
"type": "integer",
"minimum": 300,
"maximum": 864000,
"default": 172800
},
"condition": {
"description": "SMS will be sent if the condition specified is true after the specified amount of time",
"type": "string",
"enum": [
"undelivered",
"unread"
],
"default": "undelivered"
},
"text": {
"description": "Text of the message (characters [,\\,],^,{,|,},~,\u20ac are long 2)",
"type": "string",
"maxLength": 1530,
"pattern": "^[\\u0020-\\u007E\u00a3\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\\r\u00d8\u00f8\n\u00c5\u00e5\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\\u001B\u00c6\u00e6\u00df\u00c9 \u00a4\u00a1\u00c4\u00d6\u00d1\u00dc\u00a7\u00bf\u00e4\u00f6\u00f1\u00fc\u00e0\\u000C\u20ac]*$"
},
"senderNumber": {
"description": "Allows to specify any phone number you want as sender ID, the number must be in international format without + or 00, e.g.: 393334455666",
"type": "string",
"pattern": "^[0-9]*$"
},
"senderString": {
"description": "Allows to specify an alphanumeric string of maximum 11 characters to use as sender name",
"type": "string",
"pattern": "^[a-zA-Z0-9 .]{0,11}$"
}
}
}
},
"required": [
"messageId",
"createdAt",
"mobileAppId",
"text",
"recipients"
],
"defaultProperties": [
"mobileAppId",
"text",
"recipients"
]
}
Examples:
{
"messageId": "id-test-message",
"createdAt": "2015-04-26T01:37:17Z",
"mobileAppId": 2,
"text": "lorem ipsum dolor",
"recipients": [
{
"identifier": "johndoe",
"recipientRef": "testreference-johndoe"
}
],
"notificationText": "notification message",
"messageRef": "testreference",
"devicesData": {
"ios": {
"badge": 2,
"soundPath": "folder/sound.mp3",
"category": "test",
"customData": {
"exampleKey": "exampleValue"
}
},
"android": {
"title": "test"
}
},
"notifyCallback": {
"method": "post",
"url": "http://yoursite/notify-callback",
"logLevel": "info"
}
}
Send attachments
It is possible to send a single attachment together with the message. The post request follows the rules of a web filled-in form (RFC 2388). Content-Type must be set to multipart/form-data. The json body seen previously must be sent as a parameter named metadata. The file must be sent as a parameter named file and must not be larger than 8MB. A basic CURL example follows:
curl --header 'authorization: Bearer ACCESS_TOKEN'
--url http://api.catapush.com/1/messages
-F "metadata={\"mobileAppId\":2,\"text\":\"lorem ipsum dolor\",\"recipients\":[{\"identifier\":\"johndoe\"}]}"
-F "file=@image.jpg"
The reply to this request follows same rules seen in the previous section.
3 User
Manage mobile users.
3.1 GET - List users - filter,search
Get user collection
<?php
// Requirement: Client URL Library (see http://php.net/manual/en/book.curl.php)
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.catapush.com/1/apps/2/users/?page=1&size=10",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Bearer ACCESS_TOKEN",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request GET \
--url 'https://api.catapush.com/1/apps/2/users/?page=1&size=10' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json'
// Requirement: Unirest Library (see http://unirest.io/java.html)
HttpResponse<String> response = Unirest.get("https://api.catapush.com/1/apps/2/users/?page=1&size=10")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer ACCESS_TOKEN")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.catapush.com/1/apps/2/users/?page=1&size=10");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer ACCESS_TOKEN");
xhr.send(data);
const http = require("https");
const options = {
"method": "GET",
"hostname": "api.catapush.com",
"port": null,
"path": "/1/apps/2/users/?page=1&size=10",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer ACCESS_TOKEN"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
/* Requirement: libcurl library (see https://curl.haxx.se/libcurl/) */
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.catapush.com/1/apps/2/users/?page=1&size=10");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer ACCESS_TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
/* Requirement: RestSharp library (see http://restsharp.org/) */
var client = new RestClient("https://api.catapush.com/1/apps/2/users/?page=1&size=10");
var request = new RestRequest(Method.GET);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer ACCESS_TOKEN");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.catapush.com/1/apps/2/users/?page=1&size=10"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer ACCESS_TOKEN")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.catapush.com/1/apps/2/users/?page=1&size=10")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer ACCESS_TOKEN'
response = http.request(request)
puts response.read_body
# Requirement: Python3 HTTP Client library (see https://docs.python.org/3/library/http.client.html)
import http.client
conn = http.client.HTTPSConnection("api.catapush.com")
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer ACCESS_TOKEN"
}
conn.request("GET", "/1/apps/2/users/?page=1&size=10", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:appsUsersFetchAll>
<idMobileApp>1</idMobileApp>
<params>
<page>0</page>
<size>2</size>
</params>
<auth>
<access_token>ACCESS_TOKEN</access_token>
</auth>
</soap:appsUsersFetchAll>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<SOAP-ENV:Body>
<ns1:appsUsersFetchAllResponse>
<appsUsersFetchAllResult>
<items>
<SOAP-ENC:Struct>
<platform>iOS</platform>
<createdAt>2014-04-28T09:40:00+0200</createdAt>
<identifier>johndoe</identifier>
</SOAP-ENC:Struct>
<SOAP-ENC:Struct>
<platform>iOS</platform>
<createdAt>2014-04-28T09:23:00+0200</createdAt>
<identifier>foo</identifier>
</SOAP-ENC:Struct>
</items>
<totalCount>4</totalCount>
</appsUsersFetchAllResult>
</ns1:appsUsersFetchAllResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP Request
GET https://api.catapush.com/1/apps/{appId}/users
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
page | false | The page of results to return | |
size | false | The number of results to return, max 1000 | |
filterIdentifier | false | Filter results by user identifier, (starting with the parameter received, case insentive) | |
filterId | false | Filter results by user ID (exact match) | |
access_token | false | Used to send a valid access token. Do not use together with the “Authorization” header |
Responses
200 - User list
Content-type: application/json
Schema:
{ "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "title": "User Set", "type": "object", "properties": { "total_count": { "id": "http:\/\/jsonschema.net\/total_count", "type": "integer" }, "_embedded": { "type": "object", "properties": { "AppUser": { "type": "array", "items": { "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "id": "#user", "title": "User", "description": "Mobile User", "type": "object", "properties": { "identifier": { "description": "User identifier (can be a phonenumber or the username used to login in the app)", "type": "string", "pattern": "^[!-~]{1,100}$" }, "createdAt": { "description": "Creation datetime (rfc-3339)", "type": "string", "format": "date-time" }, "platform": { "description": "Device OS", "type": [ "string", "null" ], "enum": [ "Android", "iOS", null ] } }, "required": [ "identifier", "createdAt", "platform" ] } } } } }, "required": [ "total_count", "_embedded" ] }
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"title": "User Set",
"type": "object",
"properties": {
"total_count": {
"id": "http:\/\/jsonschema.net\/total_count",
"type": "integer"
},
"_embedded": {
"type": "object",
"properties": {
"AppUser": {
"type": "array",
"items": {
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"id": "#user",
"title": "User",
"description": "Mobile User",
"type": "object",
"properties": {
"identifier": {
"description": "User identifier (can be a phonenumber or the username used to login in the app)",
"type": "string",
"pattern": "^[!-~]{1,100}$"
},
"createdAt": {
"description": "Creation datetime (rfc-3339)",
"type": "string",
"format": "date-time"
},
"platform": {
"description": "Device OS",
"type": [
"string",
"null"
],
"enum": [
"Android",
"iOS",
null
]
}
},
"required": [
"identifier",
"createdAt",
"platform"
]
}
}
}
}
},
"required": [
"total_count",
"_embedded"
]
}
Examples:
{
"total_count": 4,
"_embedded": {
"AppUser": [
{
"createdAt": "2015-07-22T13:13:53+0200",
"identifier": "johndoe",
"platform": null
},
{
"createdAt": "2015-07-22T13:13:53+0200",
"identifier": "foo",
"platform": null
}
]
}
}
500 - HTTP 500 [Internal Server Error]
Content-type: application/json
Examples:
{
"error": "Backend Error Communication"
}
3.2 POST - Create a new user
Create a user
<?php
// Requirement: Client URL Library (see http://php.net/manual/en/book.curl.php)
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.catapush.com/1/apps/2/users",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{ \"identifier\":\"johndoe\", \"password\":\"johnd0e56_a\" }",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Bearer ACCESS_TOKEN",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request POST \
--url https://api.catapush.com/1/apps/2/users \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{ "identifier":"johndoe", "password":"johnd0e56_a" }'
// Requirement: Unirest Library (see http://unirest.io/java.html)
HttpResponse<String> response = Unirest.post("https://api.catapush.com/1/apps/2/users")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer ACCESS_TOKEN")
.body("{ \"identifier\":\"johndoe\", \"password\":\"johnd0e56_a\" }")
.asString();
const data = JSON.stringify({
"identifier": "johndoe",
"password": "johnd0e56_a"
});
const xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.catapush.com/1/apps/2/users");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer ACCESS_TOKEN");
xhr.send(data);
const http = require("https");
const options = {
"method": "POST",
"hostname": "api.catapush.com",
"port": null,
"path": "/1/apps/2/users",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer ACCESS_TOKEN"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({identifier: 'johndoe', password: 'johnd0e56_a'}));
req.end();
/* Requirement: libcurl library (see https://curl.haxx.se/libcurl/) */
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.catapush.com/1/apps/2/users");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer ACCESS_TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{ \"identifier\":\"johndoe\", \"password\":\"johnd0e56_a\" }");
CURLcode ret = curl_easy_perform(hnd);
/* Requirement: RestSharp library (see http://restsharp.org/) */
var client = new RestClient("https://api.catapush.com/1/apps/2/users");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer ACCESS_TOKEN");
request.AddParameter("application/json", "{ \"identifier\":\"johndoe\", \"password\":\"johnd0e56_a\" }", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.catapush.com/1/apps/2/users"
payload := strings.NewReader("{ \"identifier\":\"johndoe\", \"password\":\"johnd0e56_a\" }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer ACCESS_TOKEN")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.catapush.com/1/apps/2/users")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer ACCESS_TOKEN'
request.body = "{ \"identifier\":\"johndoe\", \"password\":\"johnd0e56_a\" }"
response = http.request(request)
puts response.read_body
# Requirement: Python3 HTTP Client library (see https://docs.python.org/3/library/http.client.html)
import http.client
conn = http.client.HTTPSConnection("api.catapush.com")
payload = "{ \"identifier\":\"johndoe\", \"password\":\"johnd0e56_a\" }"
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer ACCESS_TOKEN"
}
conn.request("POST", "/1/apps/2/users", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:appsUsersCreate>
<idMobileApp>1</idMobileApp>
<data>
<identifier>johndoe</identifier>
<password>johnd0e56_a</password>
</data>
<auth>
<access_token>ACCESS_TOKEN</access_token>
</auth>
</soap:appsUsersCreate>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<SOAP-ENV:Body>
<ns1:appsUsersCreateResponse>
<appsUsersCreateResult>
<platform xsi:nil="true"/>
<createdAt>2015-07-22T15:13:04+0200</createdAt>
<identifier>johndoe</identifier>
</appsUsersCreateResult>
</ns1:appsUsersCreateResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP Request
POST https://api.catapush.com/1/apps/{appId}/users
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
access_token | false | Used to send a valid access token. Do not use together with the “Authorization” header |
Body
Content-type: application/json
{ "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "title": "User", "description": "Mobile User", "type": "object", "properties": { "identifier": { "description": "User identifier (can be a phonenumber or the username used to login in the app)", "type": "string", "pattern": "^[!-~]{1,100}$" }, "password": { "description": "User password", "type": "string", "pattern": "^[a-zA-Z0-9\\+\\-\\*_@]{3,30}$" } }, "required": [ "identifier", "password" ] }
Schema:
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"title": "User",
"description": "Mobile User",
"type": "object",
"properties": {
"identifier": {
"description": "User identifier (can be a phonenumber or the username used to login in the app)",
"type": "string",
"pattern": "^[!-~]{1,100}$"
},
"password": {
"description": "User password",
"type": "string",
"pattern": "^[a-zA-Z0-9\\+\\-\\*_@]{3,30}$"
}
},
"required": [
"identifier",
"password"
]
}
Examples:
{
"identifier": "johndoe",
"password": "johnd0e56_a"
}
Responses
201 - User created correctly
Content-type: application/json
Schema:
{ "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "title": "User", "description": "Mobile User", "type": "object", "properties": { "identifier": { "description": "User identifier (can be a phonenumber or the username used to login in the app)", "type": "string", "pattern": "^[!-~]{1,100}$" }, "createdAt": { "description": "Creation datetime (rfc-3339)", "type": "string", "format": "date-time" }, "platform": { "description": "Device OS", "type": [ "string", "null" ], "enum": [ "Android", "iOS", null ] } }, "required": [ "identifier", "createdAt", "platform" ] }
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"title": "User",
"description": "Mobile User",
"type": "object",
"properties": {
"identifier": {
"description": "User identifier (can be a phonenumber or the username used to login in the app)",
"type": "string",
"pattern": "^[!-~]{1,100}$"
},
"createdAt": {
"description": "Creation datetime (rfc-3339)",
"type": "string",
"format": "date-time"
},
"platform": {
"description": "Device OS",
"type": [
"string",
"null"
],
"enum": [
"Android",
"iOS",
null
]
}
},
"required": [
"identifier",
"createdAt",
"platform"
]
}
Examples:
{
"identifier": "johndoe",
"createdAt": "2015-07-22T13:13:53+0200",
"platform": null
}
500 - HTTP 500 [Internal Server Error]
Content-type: application/json
Examples:
{
"error": "Backend Error Communication"
}
3.3 User Entity
Manage an existing user entity.
3.3.1 GET - Get user
Get a user
<?php
// Requirement: Client URL Library (see http://php.net/manual/en/book.curl.php)
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.catapush.com/1/apps/2/users/johndoe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Bearer ACCESS_TOKEN",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request GET \
--url https://api.catapush.com/1/apps/2/users/johndoe \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json'
// Requirement: Unirest Library (see http://unirest.io/java.html)
HttpResponse<String> response = Unirest.get("https://api.catapush.com/1/apps/2/users/johndoe")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer ACCESS_TOKEN")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://api.catapush.com/1/apps/2/users/johndoe");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer ACCESS_TOKEN");
xhr.send(data);
const http = require("https");
const options = {
"method": "GET",
"hostname": "api.catapush.com",
"port": null,
"path": "/1/apps/2/users/johndoe",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer ACCESS_TOKEN"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
/* Requirement: libcurl library (see https://curl.haxx.se/libcurl/) */
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.catapush.com/1/apps/2/users/johndoe");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer ACCESS_TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
/* Requirement: RestSharp library (see http://restsharp.org/) */
var client = new RestClient("https://api.catapush.com/1/apps/2/users/johndoe");
var request = new RestRequest(Method.GET);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer ACCESS_TOKEN");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.catapush.com/1/apps/2/users/johndoe"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer ACCESS_TOKEN")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.catapush.com/1/apps/2/users/johndoe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer ACCESS_TOKEN'
response = http.request(request)
puts response.read_body
# Requirement: Python3 HTTP Client library (see https://docs.python.org/3/library/http.client.html)
import http.client
conn = http.client.HTTPSConnection("api.catapush.com")
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer ACCESS_TOKEN"
}
conn.request("GET", "/1/apps/2/users/johndoe", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:appsUsersFetch>
<idMobileApp>1</idMobileApp>
<identifier>johndoe</identifier>
<auth>
<access_token>ACCESS_TOKEN</access_token>
</auth>
</soap:appsUsersFetch>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<SOAP-ENV:Body>
<ns1:appsUsersFetchResponse>
<appsUsersFetchResult>
<platform>Android</platform>
<createdAt>2014-04-28T09:23:00+0200</createdAt>
<identifier>johndoe</identifier>
</appsUsersFetchResult>
</ns1:appsUsersFetchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP Request
GET https://api.catapush.com/1/apps/{appId}/users/{identifier}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
access_token | false | Used to send a valid access token. Do not use together with the “Authorization” header |
Responses
200 - User entity
Content-type: application/json
Schema:
{ "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "title": "User", "description": "Mobile User", "type": "object", "properties": { "identifier": { "description": "User identifier (can be a phonenumber or the username used to login in the app)", "type": "string", "pattern": "^[!-~]{1,100}$" }, "createdAt": { "description": "Creation datetime (rfc-3339)", "type": "string", "format": "date-time" }, "platform": { "description": "Device OS", "type": [ "string", "null" ], "enum": [ "Android", "iOS", null ] } }, "required": [ "identifier", "createdAt", "platform" ] }
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"title": "User",
"description": "Mobile User",
"type": "object",
"properties": {
"identifier": {
"description": "User identifier (can be a phonenumber or the username used to login in the app)",
"type": "string",
"pattern": "^[!-~]{1,100}$"
},
"createdAt": {
"description": "Creation datetime (rfc-3339)",
"type": "string",
"format": "date-time"
},
"platform": {
"description": "Device OS",
"type": [
"string",
"null"
],
"enum": [
"Android",
"iOS",
null
]
}
},
"required": [
"identifier",
"createdAt",
"platform"
]
}
Examples:
{
"identifier": "johndoe",
"createdAt": "2015-07-22T13:13:53+0200",
"platform": null
}
404 - HTTP 404 [Not Found]
Content-type: application/json
Examples:
{
"error": "Not Found"
}
500 - HTTP 500 [Internal Server Error]
Content-type: application/json
Examples:
{
"error": "Backend Error Communication"
}
3.3.2 PATCH - Modify user
Modify a user
<?php
// Requirement: Client URL Library (see http://php.net/manual/en/book.curl.php)
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.catapush.com/1/apps/2/users/johndoe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => "{ \"password\":\"johnd0e56_abc\" }",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Bearer ACCESS_TOKEN",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request PATCH \
--url https://api.catapush.com/1/apps/2/users/johndoe \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{ "password":"johnd0e56_abc" }'
// Requirement: Unirest Library (see http://unirest.io/java.html)
HttpResponse<String> response = Unirest.patch("https://api.catapush.com/1/apps/2/users/johndoe")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer ACCESS_TOKEN")
.body("{ \"password\":\"johnd0e56_abc\" }")
.asString();
const data = JSON.stringify({
"password": "johnd0e56_abc"
});
const xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("PATCH", "https://api.catapush.com/1/apps/2/users/johndoe");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer ACCESS_TOKEN");
xhr.send(data);
const http = require("https");
const options = {
"method": "PATCH",
"hostname": "api.catapush.com",
"port": null,
"path": "/1/apps/2/users/johndoe",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer ACCESS_TOKEN"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({password: 'johnd0e56_abc'}));
req.end();
/* Requirement: libcurl library (see https://curl.haxx.se/libcurl/) */
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.catapush.com/1/apps/2/users/johndoe");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer ACCESS_TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{ \"password\":\"johnd0e56_abc\" }");
CURLcode ret = curl_easy_perform(hnd);
/* Requirement: RestSharp library (see http://restsharp.org/) */
var client = new RestClient("https://api.catapush.com/1/apps/2/users/johndoe");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer ACCESS_TOKEN");
request.AddParameter("application/json", "{ \"password\":\"johnd0e56_abc\" }", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.catapush.com/1/apps/2/users/johndoe"
payload := strings.NewReader("{ \"password\":\"johnd0e56_abc\" }")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer ACCESS_TOKEN")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.catapush.com/1/apps/2/users/johndoe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Patch.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer ACCESS_TOKEN'
request.body = "{ \"password\":\"johnd0e56_abc\" }"
response = http.request(request)
puts response.read_body
# Requirement: Python3 HTTP Client library (see https://docs.python.org/3/library/http.client.html)
import http.client
conn = http.client.HTTPSConnection("api.catapush.com")
payload = "{ \"password\":\"johnd0e56_abc\" }"
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer ACCESS_TOKEN"
}
conn.request("PATCH", "/1/apps/2/users/johndoe", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:appsUsersPatch>
<idMobileApp>1</idMobileApp>
<identifier>johndoe</identifier>
<data>
<identifier>johndoe</identifier>
<password>newpwd</password>
</data>
<auth>
<access_token>ACCESS_TOKEN</access_token>
</auth>
</soap:appsUsersPatch>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<SOAP-ENV:Body>
<ns1:appsUsersPatchResponse>
<appsUsersPatchResult>
<platform>iOS</platform>
<createdAt>2014-04-28T09:40:00+0200</createdAt>
<identifier>johndoe</identifier>
</appsUsersPatchResult>
</ns1:appsUsersPatchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP Request
PATCH https://api.catapush.com/1/apps/{appId}/users/{identifier}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
access_token | false | Used to send a valid access token. Do not use together with the “Authorization” header |
Body
Content-type: application/json
{ "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "title": "Patch User", "description": "Mobile User", "type": "object", "properties": { "password": { "description": "User password", "type": "string", "pattern": "^[a-zA-Z0-9\\+\\-\\*_@]{3,30}$" } } }
Schema:
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"title": "Patch User",
"description": "Mobile User",
"type": "object",
"properties": {
"password": {
"description": "User password",
"type": "string",
"pattern": "^[a-zA-Z0-9\\+\\-\\*_@]{3,30}$"
}
}
}
Examples:
{
"password": "johnd0e56_abc"
}
Responses
200 - User modified correctly
Content-type: application/json
Schema:
{ "$schema": "http:\/\/json-schema.org\/draft-04\/schema#", "title": "User", "description": "Mobile User", "type": "object", "properties": { "identifier": { "description": "User identifier (can be a phonenumber or the username used to login in the app)", "type": "string", "pattern": "^[!-~]{1,100}$" }, "createdAt": { "description": "Creation datetime (rfc-3339)", "type": "string", "format": "date-time" }, "platform": { "description": "Device OS", "type": [ "string", "null" ], "enum": [ "Android", "iOS", null ] } }, "required": [ "identifier", "createdAt", "platform" ] }
{
"$schema": "http:\/\/json-schema.org\/draft-04\/schema#",
"title": "User",
"description": "Mobile User",
"type": "object",
"properties": {
"identifier": {
"description": "User identifier (can be a phonenumber or the username used to login in the app)",
"type": "string",
"pattern": "^[!-~]{1,100}$"
},
"createdAt": {
"description": "Creation datetime (rfc-3339)",
"type": "string",
"format": "date-time"
},
"platform": {
"description": "Device OS",
"type": [
"string",
"null"
],
"enum": [
"Android",
"iOS",
null
]
}
},
"required": [
"identifier",
"createdAt",
"platform"
]
}
Examples:
{
"identifier": "johndoe",
"createdAt": "2015-07-22T13:13:53+0200",
"platform": null
}
404 - HTTP 404 [Not Found]
Content-type: application/json
Examples:
{
"error": "Not Found"
}
500 - HTTP 500 [Internal Server Error]
Content-type: application/json
Examples:
{
"error": "Backend Error Communication"
}
3.3.3 DELETE - Delete user
Delete a user
<?php
// Requirement: Client URL Library (see http://php.net/manual/en/book.curl.php)
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.catapush.com/1/apps/2/users/johndoe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Accept: application/json",
"Authorization: Bearer ACCESS_TOKEN",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request DELETE \
--url https://api.catapush.com/1/apps/2/users/johndoe \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json'
// Requirement: Unirest Library (see http://unirest.io/java.html)
HttpResponse<String> response = Unirest.delete("https://api.catapush.com/1/apps/2/users/johndoe")
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Bearer ACCESS_TOKEN")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("DELETE", "https://api.catapush.com/1/apps/2/users/johndoe");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer ACCESS_TOKEN");
xhr.send(data);
const http = require("https");
const options = {
"method": "DELETE",
"hostname": "api.catapush.com",
"port": null,
"path": "/1/apps/2/users/johndoe",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer ACCESS_TOKEN"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
/* Requirement: libcurl library (see https://curl.haxx.se/libcurl/) */
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.catapush.com/1/apps/2/users/johndoe");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer ACCESS_TOKEN");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
/* Requirement: RestSharp library (see http://restsharp.org/) */
var client = new RestClient("https://api.catapush.com/1/apps/2/users/johndoe");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer ACCESS_TOKEN");
IRestResponse response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.catapush.com/1/apps/2/users/johndoe"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer ACCESS_TOKEN")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.catapush.com/1/apps/2/users/johndoe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Delete.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer ACCESS_TOKEN'
response = http.request(request)
puts response.read_body
# Requirement: Python3 HTTP Client library (see https://docs.python.org/3/library/http.client.html)
import http.client
conn = http.client.HTTPSConnection("api.catapush.com")
headers = {
'Accept': "application/json",
'Content-Type': "application/json",
'Authorization': "Bearer ACCESS_TOKEN"
}
conn.request("DELETE", "/1/apps/2/users/johndoe", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<soapenv:Header/>
<soapenv:Body>
<soap:appsUsersDelete>
<idMobileApp>1</idMobileApp>
<identifier>johndoe</identifier>
<auth>
<access_token>ACCESS_TOKEN</access_token>
</auth>
</soap:appsUsersDelete>
</soapenv:Body>
</soapenv:Envelope>
Response:
<SOAP-ENV:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="https://api.catapush.com/soap/">
<SOAP-ENV:Body>
<ns1:appsUsersDeleteResponse>
<appsUsersDeleteResult>true</appsUsersDeleteResult>
</ns1:appsUsersDeleteResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP Request
DELETE https://api.catapush.com/1/apps/{appId}/users/{identifier}
Query Parameters
Parameter | Required | Default | Description |
---|---|---|---|
access_token | false | Used to send a valid access token. Do not use together with the “Authorization” header |
Responses
200 - User deleted correctly
Content-type: application/json
Examples:
true
404 - HTTP 404 [Not Found]
Content-type: application/json
Examples:
{
"error": "Not Found"
}
500 - HTTP 500 [Internal Server Error]
Content-type: application/json
Examples:
{
"error": "Backend Error Communication"
}