Add a webhook
Post /settings/webhooks
Parameters:
| Name | Description | Type | Mandatory |
|---|---|---|---|
| url | Url used to call as event will occur | String | Yes |
| description | Webhook description | String | Yes |
| events |
Lists of events
Event available:
| Array | Yes |
Response:
Before adding the webhook, we test if the url is good and return a 200 http code. Else we don't save the webhook and return an error code.
| Name | Description | Type |
|---|---|---|
| id | Id of the webhook | String |
| url | Webhook url | String |
| description | Webhook description | String |
| events | Events used for the Webhook | Array of String |
| success | Number of call in success | Int |
| errors | Number of call in error | Int |
| createdAt | Creation date | String |
| updatedAt | Update date | String |
Programming language:
Request exemple:
{
"url": "http://yourwebsite.com/webhook",
"description": "my first webhook",
"events": ["delivered", "opened", "clicked"]
}
Response exemple:
{
"id": "5654654v6re54v654654648c",
"url": "http://yourwebsite.com/webhook",
"description": "Webhook description",
"createdAt": 1452177334,
"updatedAt": 1452177334,
"success": 0,
"errors": 0,
"events": ["delivered", "opened", "clicked"],
"status": "success"
}
Code example:
curl -X POST -d '{"url":"http://yourwebsite.com/webhook","description":"my first webhook","events":["delivered"]}' -H "Content-Type: application/json" -H "X-Tipimail-ApiUser:YOUR_SMTP_USERNAME" -H "X-Tipimail-ApiKey:YOUR_SMTP_KEY" https://api.tipimail.com/v1/settings/webhooks/add
require 'vendor/autoload.php';
$tipimail = new Tipimail\Tipimail('YOUR_SMTP_USERNAME', 'YOUR_API_KEY');
try {
$result = $tipimail->getSettingsService()->getWebhooksService()->addWithAllEvents('http://www.example.com/example', 'Description');
var_dump($result);
$events = new Tipimail\Settings\Webhooks\WebhookEvents();
$events->enableDelivered();
$events->enableHardbounced();
$result = $tipimail->getSettingsService()->getWebhooksService()->addWithSelectedEvents('http://www.example.com/example', 'Description', $events);
var_dump($result);
}
catch(Tipimail\Exceptions\TipimailException $e) {
echo 'Exception received :', $e->getMessage(), "\n";
}