Webhook Calls
Info! This is Beta version, if you have any problem in using API, please mail us at support@sarv.com
/settings/addWebhook
Add a new Webhook
<?php
try {
require_once 'SarvMTA_PHP/Sarv.php';
$sarv = new Sarv('owner_id', 'token', 'SarvTES_APP_DOMAIN');
$result = $sarv->settings->addWebhook(url, event, description, store_log);
print_r($result);
/*
Array
(
[status] => "success"
[message] => "Webhook Added"
)
*/
} catch(Sarv_Error $e) {
// Sarv errors are thrown as exceptions
echo "A sarv error occurred: " . get_class($e) . " - " . $e->getMessage();
}
?>
Array
(
[status] => "success"
[message] => "Webhook Added"
)
Array
(
[status]=> "error"
[code]=> -1
[name]=> "AuthenticationError"
[message]=> "Token MissMatch"
)
Parameters |
owner_id* string |
a valid Sarv User Id |
token* string |
a valid token |
SarvTES_APP_DOMAIN* string |
a valid SarvTES APP DOMAIN |
url* string |
a valid url ,that always response 'God bless you, Sarv' |
event string |
a valid events string with comma separated like 'send,open,click,soft_bounce,hard_bounce,spam' |
description string |
description about webhook |
store_log string |
value is Either 'Enable' OR 'Disable' |
* compulsory field
Return Value: Success |
struct |
the results of newly created webhook
status string |
always success |
message string |
human readable message |
|
|
Return Value: Error |
struct |
the error results when attempt to create webhook
status string |
error |
message string |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. Sarv Developers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
/settings/editWebhook
Edit Webhook
<?php
try {
require_once 'SarvMTA_PHP/Sarv.php';
$sarv = new Sarv('owner_id', 'token', 'SarvTES_APP_DOMAIN');
$result = $sarv->settings->editWebhook(webhook_id, url, event, description, store_log);
print_r($result);
/*
Array
(
[status] => "success"
[message] => "Webhook Edited"
)
*/
} catch(Sarv_Error $e) {
// Sarv errors are thrown as exceptions
echo "A sarv error occurred: " . get_class($e) . " - " . $e->getMessage();
}
?>
Array
(
[status] => "success"
[message] => "Webhook Edited"
)
Array
(
[status]=> "error"
[code]=> -1
[name]=> "AuthenticationError"
[message]=> "Token MissMatch"
)
Parameters |
owner_id* string |
a valid Sarv User Id |
token* string |
a valid token |
SarvTES_APP_DOMAIN* string |
a valid SarvTES APP DOMAIN |
webhook_id* string |
a valid webhook_id |
url* string |
a valid url ,that always response 'God bless you, Sarv' |
event string |
a valid events string with comma separated like 'send,open,click,soft_bounce,hard_bounce,spam' |
description string |
description about webhook |
store_log string |
value is Either 'Enable' OR 'Disable' |
* compulsory field
Return Value: Success |
struct |
the results of updated Webhook
status string |
always success |
message string |
human readable message |
|
|
Return Value: Error |
struct |
the error results when attempt to update webhook details
status string |
error |
message string |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. Sarv Developers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
/settings/keyResetWebhook
Key Reset for Webhook
<?php
try {
require_once 'SarvMTA_PHP/Sarv.php';
$sarv = new Sarv('owner_id', 'token', 'SarvTES_APP_DOMAIN');
$result = $sarv->settings->keyResetWebhook(webhook_id);
print_r($result);
/*
Array
(
[status] => "success"
[message] => "Webhook key reseted"
[webhook_id] => "424353445757557577457"
[key] => "2fg345gy6r7"
)
*/
} catch(Sarv_Error $e) {
// Sarv errors are thrown as exceptions
echo "A sarv error occurred: " . get_class($e) . " - " . $e->getMessage();
}
?>
Array
(
[status] => "success"
[message] => "Webhook key reseted"
[webhook_id] => "424353445757557577457"
[key] => "2fg345gy6r7"
)
Array
(
[status]=> "error"
[code]=> -1
[name]=> "AuthenticationError"
[message]=> "Token MissMatch"
)
Parameters |
owner_id* string |
a valid Sarv User Id |
token* string |
a valid token |
SarvTES_APP_DOMAIN* string |
a valid SarvTES APP DOMAIN |
webhook_id* string |
a valid webhook id |
* compulsory field
Return Value:Success |
struct |
the results of key reset for Webhook
status string |
always success |
message string |
human readable message |
webhook_id string |
webhook id |
key string |
new key |
|
|
Return Value: Error |
struct |
the error results when attempt to key reset for Webhook
status string |
error |
message string |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. Sarv Developers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
/settings/listWebhook
List Webhooks
<?php
try {
require_once 'SarvMTA_PHP/Sarv.php';
$sarv = new Sarv('owner_id', 'token', 'SarvTES_APP_DOMAIN');
$result = $sarv->settings->listWebhook();
print_r($result);
/*
Array
(
[status] => "success"
[webhook_list] => array(
array(
[webhook_id] => "424353445757557577457"
[url] => "http://abc.com/wh1.php"
[event] => "open,click"
[key] => "cgvddgrsd"
[store_log] => "Enable"
[description] => "this webhook for only open and click"
[create_date] => 754453534
),
array(
[webhook_id] => "424353120757587577493"
[url] => "http://abc.com/wh1.php"
[event] => "soft_bounce,click"
[key] => "sdfgdggdgd"
[store_log] => "Disable"
[description] => "this webhook for only soft_bounce and click"
[create_date] => 8350953531
)
)
)
*/
} catch(Sarv_Error $e) {
// Sarv errors are thrown as exceptions
echo "A sarv error occurred: " . get_class($e) . " - " . $e->getMessage();
}
?>
Array
(
[status] => "success"
[webhook_list] => array(
array(
[webhook_id] => "424353445757557577457"
[url] => "http://abc.com/wh1.php"
[event] => "open,click"
[key] => "cgvddgrsd"
[store_log] => "Enable"
[description] => "this webhook for only open and click"
[create_date] => 754453534
),
array(
[webhook_id] => "424353120757587577493"
[url] => "http://abc.com/wh1.php"
[event] => "soft_bounce,click"
[key] => "sdfgdggdgd"
[store_log] => "Disable"
[description] => "this webhook for only soft_bounce and click"
[create_date] => 8350953531
)
)
)
Array
(
[status]=> "error"
[code]=> -1
[name]=> "AuthenticationError"
[message]=> "Token MissMatch"
)
Parameters |
owner_id* string |
a valid Sarv User Id |
token* string |
a valid token |
SarvTES_APP_DOMAIN* string |
a valid SarvTES APP DOMAIN |
* compulsory field
Return Value: Success |
struct |
the results of List Webhook
status string |
always success |
message string |
human readable message |
webhook_list[]struct |
information of single webhook
webhook_id string |
webhook id |
url string |
url |
event string |
event string with comma separated like 'open,click' |
description string |
description about webhook |
store_log string |
value of status is Either 'Enable' OR 'Disable' |
key integer |
key |
create_date integer |
create date in seconds |
|
|
|
|
Return Value: Error |
struct |
the error results when attempt to List Webhook
status string |
error |
message string |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. Sarv Developers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
/settings/deleteWebhook
Delete Webhook
<?php
try {
require_once 'SarvMTA_PHP/Sarv.php';
$sarv = new Sarv('owner_id', 'token', 'SarvTES_APP_DOMAIN');
$result = $sarv->settings->deleteWebhook(webhook_id);
print_r($result);
/*
Array
(
[status] => success
[message] => "Webhook Deleted"
)
*/
} catch(Sarv_Error $e) {
// Sarv errors are thrown as exceptions
echo "A sarv error occurred: " . get_class($e) . " - " . $e->getMessage();
}
?>
Array
(
[status] => success
[message] => "Webhook Deleted"
)
Array
(
[status]=> "error"
[code]=> -1
[name]=> "AuthenticationError"
[message]=> "Token MissMatch"
)
Parameters |
owner_id* string |
a valid Sarv User Id |
token* string |
a valid token |
SarvTES_APP_DOMAIN* string |
a valid SarvTES APP DOMAIN |
webhook_id* string |
valid webhook id |
* compulsory field
Return Value: Success |
struct |
the results of Delete webhook
status string |
always success |
message string |
human readable message |
|
|
Return Value: Error |
struct |
the error results when attempt to Delete webhook
status string |
error |
message string |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. Sarv Developers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
/settings/getWebhookInfo
Get info of any webhook
<?php
try {
require_once 'SarvMTA_PHP/Sarv.php';
$sarv = new Sarv('owner_id', 'token', 'SarvTES_APP_DOMAIN');
$result = $sarv->settings->getWebhookInfo(webhook_id);
print_r($result);
/*
Array
(
[status] => success
[webhook_data] => Array
(
[webhook_id] => 405602261459333060372
[url] => http://xyz.com/webhook3.php
[event] => open
[description] => this is desctiptyioj......
[store_log] => Enable
[key] => aVLnPysvkKUU95AFrb47Zr
[create_date] => 1459333060
[last_success] => 1459366666
[total_event] => 23
)
)
*/
} catch(Sarv_Error $e) {
// Sarv errors are thrown as exceptions
echo "A sarv error occurred: " . get_class($e) . " - " . $e->getMessage();
}
?>
Array
(
[status] => success
[webhook_data] => Array
(
[webhook_id] => 405602261459333060372
[url] => http://103.255.101.118/webhook3.php
[event] => open
[description] => this is desctiptyioj......
[store_log] => Enable
[key] => aVLnPysvkKUU95AFrb47Zr
[create_date] => 1459333060
[last_success] => 0
[total_event] => 0
)
)
Array
(
[status]=> "error"
[code]=> -1
[name]=> "AuthenticationError"
[message]=> "Token MissMatch"
)
Parameters |
owner_id* string |
a valid Sarv User Id |
token* string |
a valid token |
SarvTES_APP_DOMAIN* string |
a valid SarvTES APP DOMAIN |
webhook_id* string |
valid webhook id |
* compulsory field
Return Value: Success |
struct |
the results of webhook info
status string |
always success |
webhook_data struct |
information of webhook
webhook_id string |
smtp webhook id |
url string |
webhook url |
event string |
events with comma separate |
description string |
description |
store_log string |
value of store_log is Either 'Enable' OR 'Disable' |
key string |
key |
create_date integer |
create date |
last_success integer |
last success time |
total_event integer |
total event sent on webhook url |
|
|
|
Return Value: Error |
struct |
the error results when attempt to get webhook info
status string |
error |
message string |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. Sarv Developers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
[{
"_id": "14304056-C18956K3-AX7C-41E4-8A14-7E1G4HJYCBCD.129.1",
"smtp_name": "smtp87654321",
"x_unique_id": "6f708632d96fe1cb0cb15eccc2676323b2615d5309a7896cf002c54d1a6ea4785",
"ts": 1465890656000,
"msg": {
"bounceDesc": "Requested action not taken: mailbox unavailable ",
"bounceCodeTrad": 550,
"bounceCodeEnh": "5.2.2"
},
"event": "hard_bounce"
}, {
"_id": "14304056-C18956K3-AX7C-41E4-8A14-7E1G4HJYCBCD.129.1",
"smtp_name": "smtp87654321",
"x_unique_id": "5H708632d96ty7ub0cb15eccc2676323b2615d87879a7896cf002c54d1a6ea4893",
"ts": 1465890656000,
"msg": {
"bounceDesc": "smtp; 552 5.2.2 Over quota ",
"bounceCodeTrad": 472,
"bounceCodeEnh": "4.2.2"
},
"event": "soft_bounce"
}, {
"_id": "14304056-C18956K3-AX7C-41E4-8A14-7E1G4HJYCBCD.129.1",
"smtp_name": "smtp87654321",
"x_unique_id": "5H708632d96ty7ub0cb15eccc2676323b2615d87879a7896cf002c54d1a6ea4893",
"ts": 1465890656000,
"msg": {},
"event": "send"
}, {
"_id": "14304056-C18956K3-AX7C-41E4-8A14-7E1G4HJYCBCD.129.1",
"smtp_name": "smtp87654321",
"x_unique_id": "5H708632d96ty7ub0cb15eccc2676323b2615d87879a7896cf002c54d1a6ea4893",
"ts": 1465890656000,
"msg": {},
"event": "delivered"
}, {
"_id": "14304056-C18956K3-AX7C-41E4-8A14-7E1G4HJYCBCD.129.1",
"smtp_name": "smtp87654321",
"x_unique_id": "",
"ts": 1465988183000,
"msg": {
"clicks": [{
"clickTs": 1465988314000,
"clickUrl": "http://example.com/",
"clickIp": "0.0.0.0",
"clickUa": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"
}]
},
"event": "click"
}, {
"_id": "14304056-C18956K3-AX7C-41E4-8A14-7E1G4HJYCBCD.129.1",
"smtp_name": "smtp87654321",
"x_unique_id": "",
"ts": 1465988314000,
"msg": {
"opens": [{
"openTs": 1465988314000,
"openIp": "0.0.0.0",
"openUa": "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)"
}]
},
"event": "open"
}, {
"_id": "14304056-C18956K3-AX7C-41E4-8A14-7E1G4HJYCBCD.129.1",
"smtp_name": "smtp87654321",
"x_unique_id": "5H708632d96ty7ub0cb15eccc2676323b2615d87879a7896cf002c54d1a6ea4893",
"ts": 1465890656000,
"msg": {
"feedbackReport": "Arrival-Date: Tue, 14 June 2016 07:50:56 +0000\r\nOriginal-Rcpt-To: b0df23337efdcda913f1e8888014812b@example.com\r\nOriginal-Mail-From: b-60821810-purchase=example.com@example.org\r\nReported-Domain: example.org\r\nSource-Ip: 0.0.0.0\r\nFeedback-Type: abuse\r\nAbuse-Type: complaint\r\nUser-Agent: ReturnPathFBL/2.0\r\n"
},
"event": "spam"
}]
Webhook Authentication