Carbonio Notification Push Api v0.1.1
Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
Carbonio Notification Push HTTP APIs definition.
Base URLs:
Email: Support
Tokens
registerToken
Code samples
# You can also use wget
curl -X PUT http://localhost:10000/tokens \
-H 'Content-Type: application/json' \
-H 'Accept: application/json'
PUT http://localhost:10000/tokens HTTP/1.1
Host: localhost:10000
Content-Type: application/json
Accept: application/json
const inputBody = '{
"userId": "2c4a230c-5085-4924-a3e1-25fb4fc5965b",
"deviceId": "string",
"app": "wsc",
"deviceType": "android",
"token": "string"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json'
};
fetch('http://localhost:10000/tokens',
{
method: 'PUT',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
const fetch = require('node-fetch');
const inputBody = {
"userId": "2c4a230c-5085-4924-a3e1-25fb4fc5965b",
"deviceId": "string",
"app": "wsc",
"deviceType": "android",
"token": "string"
};
const headers = {
'Content-Type':'application/json',
'Accept':'application/json'
};
fetch('http://localhost:10000/tokens',
{
method: 'PUT',
body: JSON.stringify(inputBody),
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
result = RestClient.put 'http://localhost:10000/tokens',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.put('http://localhost:10000/tokens', headers = headers)
print(r.json())
URL obj = new URL("http://localhost:10000/tokens");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("PUT");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("PUT", "http://localhost:10000/tokens", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
'application/json',
'Accept' => 'application/json',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('PUT','http://localhost:10000/tokens', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
PUT /tokens
Register a token for the specified app and device type
Registers a token for the specified app and device type (Android or iOS). The request must contain the userId, deviceId, app, deviceType and the token which will be used to send push notifications.
Body parameter
{
"userId": "2c4a230c-5085-4924-a3e1-25fb4fc5965b",
"deviceId": "string",
"app": "wsc",
"deviceType": "android",
"token": "string"
}
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | TokenData | true | token to be registered |
Example responses
200 Response
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"userId": "2c4a230c-5085-4924-a3e1-25fb4fc5965b",
"deviceId": "string",
"app": "wsc",
"deviceType": "android",
"token": "string"
}
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | Token is registered successfully | TokenData |
| 400 | Bad Request | The request had wrong or missing parameters | None |
| 401 | Unauthorized | User not authorized | None |
| 403 | Forbidden | The requester could not access the resource | None |
| 409 | Conflict | The request conflict with the current state | None |
deleteToken
Code samples
# You can also use wget
curl -X DELETE http://localhost:10000/tokens/{tokenId}
DELETE http://localhost:10000/tokens/{tokenId} HTTP/1.1
Host: localhost:10000
fetch('http://localhost:10000/tokens/{tokenId}',
{
method: 'DELETE'
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
const fetch = require('node-fetch');
fetch('http://localhost:10000/tokens/{tokenId}',
{
method: 'DELETE'
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
result = RestClient.delete 'http://localhost:10000/tokens/{tokenId}',
params: {
}
p JSON.parse(result)
import requests
r = requests.delete('http://localhost:10000/tokens/{tokenId}')
print(r.json())
URL obj = new URL("http://localhost:10000/tokens/{tokenId}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("DELETE");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("DELETE", "http://localhost:10000/tokens/{tokenId}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
request('DELETE','http://localhost:10000/tokens/{tokenId}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
DELETE /tokens/{tokenId}
Deletes the specified token
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| tokenId | path | string(uuid) | true | token identifier |
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 204 | No Content | Token is deleted successfully | None |
| 401 | Unauthorized | User not authorized | None |
| 403 | Forbidden | The requester could not access the resource | None |
Notifications
sendNotification
Code samples
# You can also use wget
curl -X POST http://localhost:10000/notifications \
-H 'Content-Type: application/json'
POST http://localhost:10000/notifications HTTP/1.1
Host: localhost:10000
Content-Type: application/json
const inputBody = '{
"senderId": "6b2f63ba-164c-48c9-87b1-690cee2b3da3",
"receiverIds": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
],
"title": "string",
"message": "string",
"data": [
{
"field": "string",
"value": "string"
}
]
}';
const headers = {
'Content-Type':'application/json'
};
fetch('http://localhost:10000/notifications',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
const fetch = require('node-fetch');
const inputBody = {
"senderId": "6b2f63ba-164c-48c9-87b1-690cee2b3da3",
"receiverIds": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
],
"title": "string",
"message": "string",
"data": [
{
"field": "string",
"value": "string"
}
]
};
const headers = {
'Content-Type':'application/json'
};
fetch('http://localhost:10000/notifications',
{
method: 'POST',
body: JSON.stringify(inputBody),
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json'
}
result = RestClient.post 'http://localhost:10000/notifications',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.post('http://localhost:10000/notifications', headers = headers)
print(r.json())
URL obj = new URL("http://localhost:10000/notifications");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "http://localhost:10000/notifications", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
'application/json',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','http://localhost:10000/notifications', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
POST /notifications
Sends notifications to mobile notifications endpoints
Sends mobile notifications to any mobile notifications endpoint allowed. It sends notifications for both FCM and APNS or any of them enabled.
Body parameter
{
"senderId": "6b2f63ba-164c-48c9-87b1-690cee2b3da3",
"receiverIds": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
],
"title": "string",
"message": "string",
"data": [
{
"field": "string",
"value": "string"
}
]
}
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | NotificationPayload | true | notification payload to send |
Responses
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 204 | No Content | Notification is sent successfully | None |
| 400 | Bad Request | The request had wrong or missing parameters | None |
| 401 | Unauthorized | User not authorized | None |
| 403 | Forbidden | The requester could not access the resource | None |
| 409 | Conflict | The request conflict with the current state | None |
Schemas
TokenData
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"userId": "2c4a230c-5085-4924-a3e1-25fb4fc5965b",
"deviceId": "string",
"app": "wsc",
"deviceType": "android",
"token": "string"
}
user's token to be registered
Properties
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| id | string(uuid) | false | read-only | token identifier |
| userId | string(uuid) | true | none | user identifier |
| deviceId | string | true | none | device identifier |
| app | App | true | none | the app name |
| deviceType | DeviceType | true | none | the device type |
| token | string | true | none | Firebase or Apns token for push notifications |
App
"wsc"
the app name
Properties
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| anonymous | string | false | none | the app name |
Enumerated Values
| Property | Value |
|---|---|
| anonymous | wsc |
| anonymous | wsc-beta |
DeviceType
"android"
the device type
Properties
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| anonymous | string | false | none | the device type |
Enumerated Values
| Property | Value |
|---|---|
| anonymous | android |
| anonymous | ios |
NotificationPayload
{
"senderId": "6b2f63ba-164c-48c9-87b1-690cee2b3da3",
"receiverIds": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
],
"title": "string",
"message": "string",
"data": [
{
"field": "string",
"value": "string"
}
]
}
user's notification to send
Properties
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| senderId | string(uuid) | true | none | sender user identifier |
| receiverIds | [string] | true | none | list of receiver ids |
| title | string | true | none | notification title to display in the notification |
| message | string | true | none | text message to display in the notification |
| data | [NotificationData] | false | none | useful data for clients related to the notification |
NotificationData
{
"field": "string",
"value": "string"
}
single notification data
Properties
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| field | string | true | none | name of the field |
| value | string | true | none | value related to the field |