Create a webhook
1 min
POST
https://api.campaign.episerver.net/rest/{clientId}/webhooks
Path Parameters
- clientIdinteger<int64>requiredDescriptionFormatint64
Header Parameters
- acceptstringDescriptionDefaultapplication/jsonAllowedapplication/jsonapplication/vnd.optivo.broadmail.v1+json
Form Parameters
- basicAuthUsernamestringDescription
- basicAuthPasswordstringDescription
- typestring<open | click | sent | bounce | unsubscribe | spamcomplaint | singleoptin | confirmedoptin | doubleoptin | blocklist | archive | filteredbyblocklist>requiredDescriptionAllowedopenclicksentbounceunsubscribespamcomplaintsingleoptinconfirmedoptindoubleoptinblocklistarchivefilteredbyblocklist
- formatstring<json>requiredDescriptionAllowedjson
- authenticationstringDescription
- targetUrlstringrequiredDescription
Responses
201
- RestWebhook
- idinteger<int64>DescriptionFormatint64
- typestring<open | click | sent | bounce | unsubscribe | spamcomplaint | webhooknode | singleoptin | confirmedoptin | doubleoptin | blocklist | archived | filteredbyblocklist>DescriptionAllowedopenclicksentbounceunsubscribespamcomplaintwebhooknodesingleoptinconfirmedoptindoubleoptinblocklistarchivedfilteredbyblocklist
- statusstring<created | activated | deactivated | deleted | suspended>DescriptionAllowedcreatedactivateddeactivateddeletedsuspended
- formatstring<json>DescriptionAllowedjson
- targetUrlstringDescription
- authenticationWebhookAuthenticationDescription
- typestringrequired
- createdstring<date-time>DescriptionFormatdate-time
- modifiedstring<date-time>DescriptionFormatdate-time
400
- RestWebhook
- idinteger<int64>DescriptionFormatint64
- typestring<open | click | sent | bounce | unsubscribe | spamcomplaint | webhooknode | singleoptin | confirmedoptin | doubleoptin | blocklist | archived | filteredbyblocklist>DescriptionAllowedopenclicksentbounceunsubscribespamcomplaintwebhooknodesingleoptinconfirmedoptindoubleoptinblocklistarchivedfilteredbyblocklist
- statusstring<created | activated | deactivated | deleted | suspended>DescriptionAllowedcreatedactivateddeactivateddeletedsuspended
- formatstring<json>DescriptionAllowedjson
- targetUrlstringDescription
- authenticationWebhookAuthenticationDescription
- typestringrequired
- createdstring<date-time>DescriptionFormatdate-time
- modifiedstring<date-time>DescriptionFormatdate-time
curl
curl --request POST \
--url https://api.campaign.episerver.net/rest/{clientId}/webhooks \
--header 'accept: application/json' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'type=open' \
--data 'format=json' \
--data 'targetUrl=string'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/x-www-form-urlencoded");
var urlencoded = new URLSearchParams();
urlencoded.append("type", "open");
urlencoded.append("format", "json");
urlencoded.append("targetUrl", "string");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://api.campaign.episerver.net/rest/{clientId}/webhooks", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "net/http"
url = URI("https://api.campaign.episerver.net/rest/{clientId}/webhooks")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/x-www-form-urlencoded"
request.body = "type=open&format=json&targetUrl=string"
response = https.request(request)
puts response.read_body
python
import requests
url = "https://api.campaign.episerver.net/rest/{clientId}/webhooks"
payload = 'type=open&format=json&targetUrl=string'
headers = {
'accept': 'application/json',
'content-type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// The webhook was created successfully.
{
"id": "",
"type": "",
"status": "",
"format": "",
"targetUrl": "",
"authentication": {
"type": ""
},
"created": "",
"modified": ""
}400
// The webhook could not be created (either url, type or format was wrong).
{
"id": "",
"type": "",
"status": "",
"format": "",
"targetUrl": "",
"authentication": {
"type": ""
},
"created": "",
"modified": ""
}