Create webhook
Creates a new webhook with specified URL and topic.
Endpoint
Section titled “Endpoint”HTTP method: POST
https://api.sender.net/v2/account/webhooks
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
url | string required | Webhook endpoint URL. |
topic | string required | Available topics to create webhook: |
relation_id | string | Relation ID is required only if topic is groups/new-subscriber or groups/unsubscribed. Please provide the group which want to be tracked. |
Request Examples
Section titled “Request Examples”const url = new URL("https://api.sender.net/v2/account/webhooks");
let headers = { "Authorization": "Bearer [your-token]", "Content-Type": "application/json", "Accept": "application/json",};
let bodyContent = { "url": "https://webhook.site/da83f596-5bc3-48d3-8bab-f8203a5847af", "topic": "groups/new-subscriber", "relation_id": "eZVD4w"};
fetch(url, { method: "POST", headers, body: JSON.stringify(bodyContent)}).then(response => response.json()).then(data => console.log(data)).catch(error => console.error('Error:', error));$client = new \GuzzleHttp\Client();
$json = [ "url" => "https =>//webhook.site/da83f596-5bc3-48d3-8bab-f8203a5847af", "topic" => "groups/new-subscriber", "relation_id" => "eZVD4w"];
$response = $client->post( 'https://api.sender.net/v2/account/webhooks', [ 'headers' => [ 'Authorization' => 'Bearer [your-token]', 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'json' => $json ]);
$body = $response->getBody()->getContents();$data = json_decode($body, true);print_r($data);import requestsimport json
url = "https://api.sender.net/v2/account/webhooks"
headers = { "Authorization": "Bearer [your-token]", "Content-Type": "application/json", "Accept": "application/json",}
payload = { "url": "https://webhook.site/da83f596-5bc3-48d3-8bab-f8203a5847af", "topic": "groups/new-subscriber", "relation_id": "eZVD4w"}
response = requests.request('POST', url, headers=headers, json=payload)
print(response.json())curl -X POST \"https://api.sender.net/v2/account/webhooks" \-H "Authorization: Bearer [your-token]" \-H "Content-Type: application/json" \-H "Accept: application/json" \-d '{"url":"https://webhook.site/da83f596-5bc3-48d3-8bab-f8203a5847af","topic":"groups/new-subscriber","relation_id":"eZVD4w"}'Response
Section titled “Response”{ "id": "QbY0Wa", "account_id": "Eqqve", "url": "https://webhook.site/da83f596-5bc3-48d3-8bab-f8203a5847af", "topic": "groups/new-subscriber", "group": "eZVD4w", "total_deliveries": 0, "total_failures": 0, "response_time": 0, "status": "ACTIVE"}