Create Event Subscription
curl --request POST \
--url https://api.yapily.com/notifications/event-subscriptions \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"eventTypeId": "payment.status.completed",
"notification": {
"type": "WEBHOOK",
"url": "https://httpbin.com/new_endpoint"
}
}
'import requests
url = "https://api.yapily.com/notifications/event-subscriptions"
payload = {
"eventTypeId": "payment.status.completed",
"notification": {
"type": "WEBHOOK",
"url": "https://httpbin.com/new_endpoint"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
eventTypeId: 'payment.status.completed',
notification: {type: 'WEBHOOK', url: 'https://httpbin.com/new_endpoint'}
})
};
fetch('https://api.yapily.com/notifications/event-subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.yapily.com/notifications/event-subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'eventTypeId' => 'payment.status.completed',
'notification' => [
'type' => 'WEBHOOK',
'url' => 'https://httpbin.com/new_endpoint'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.yapily.com/notifications/event-subscriptions"
payload := strings.NewReader("{\n \"eventTypeId\": \"payment.status.completed\",\n \"notification\": {\n \"type\": \"WEBHOOK\",\n \"url\": \"https://httpbin.com/new_endpoint\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.yapily.com/notifications/event-subscriptions")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"eventTypeId\": \"payment.status.completed\",\n \"notification\": {\n \"type\": \"WEBHOOK\",\n \"url\": \"https://httpbin.com/new_endpoint\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yapily.com/notifications/event-subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"eventTypeId\": \"payment.status.completed\",\n \"notification\": {\n \"type\": \"WEBHOOK\",\n \"url\": \"https://httpbin.com/new_endpoint\"\n }\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"tracingId": "<string>"
},
"data": {
"eventTypeId": "payment.status.completed",
"applicationId": "2698db90-6635-4f76-b673-5ce8e2aeda0e",
"created": "28-07-2021 15:47:03",
"notification": {
"type": "WEBHOOK",
"url": "https://httpbin.com/new_endpoint"
}
},
"links": {},
"forwardedData": [
{
"headers": {},
"url": "<string>"
}
],
"raw": [
{
"request": {
"method": "<string>",
"url": "<string>",
"requestInstant": "2023-11-07T05:31:56Z",
"headers": {},
"body": {},
"bodyParameters": {},
"startTime": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z"
},
"duration": "<string>",
"headers": {},
"resultCode": 123,
"result": {}
}
]
}Notifications
Create Event Subscription
Used to subscribe to notifications relating to a specified event type.
Create Event Subscription
curl --request POST \
--url https://api.yapily.com/notifications/event-subscriptions \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"eventTypeId": "payment.status.completed",
"notification": {
"type": "WEBHOOK",
"url": "https://httpbin.com/new_endpoint"
}
}
'import requests
url = "https://api.yapily.com/notifications/event-subscriptions"
payload = {
"eventTypeId": "payment.status.completed",
"notification": {
"type": "WEBHOOK",
"url": "https://httpbin.com/new_endpoint"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
eventTypeId: 'payment.status.completed',
notification: {type: 'WEBHOOK', url: 'https://httpbin.com/new_endpoint'}
})
};
fetch('https://api.yapily.com/notifications/event-subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.yapily.com/notifications/event-subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'eventTypeId' => 'payment.status.completed',
'notification' => [
'type' => 'WEBHOOK',
'url' => 'https://httpbin.com/new_endpoint'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.yapily.com/notifications/event-subscriptions"
payload := strings.NewReader("{\n \"eventTypeId\": \"payment.status.completed\",\n \"notification\": {\n \"type\": \"WEBHOOK\",\n \"url\": \"https://httpbin.com/new_endpoint\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.yapily.com/notifications/event-subscriptions")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"eventTypeId\": \"payment.status.completed\",\n \"notification\": {\n \"type\": \"WEBHOOK\",\n \"url\": \"https://httpbin.com/new_endpoint\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yapily.com/notifications/event-subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"eventTypeId\": \"payment.status.completed\",\n \"notification\": {\n \"type\": \"WEBHOOK\",\n \"url\": \"https://httpbin.com/new_endpoint\"\n }\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"tracingId": "<string>"
},
"data": {
"eventTypeId": "payment.status.completed",
"applicationId": "2698db90-6635-4f76-b673-5ce8e2aeda0e",
"created": "28-07-2021 15:47:03",
"notification": {
"type": "WEBHOOK",
"url": "https://httpbin.com/new_endpoint"
}
},
"links": {},
"forwardedData": [
{
"headers": {},
"url": "<string>"
}
],
"raw": [
{
"request": {
"method": "<string>",
"url": "<string>",
"requestInstant": "2023-11-07T05:31:56Z",
"headers": {},
"body": {},
"bodyParameters": {},
"startTime": "2023-11-07T05:31:56Z",
"startedAt": "2023-11-07T05:31:56Z"
},
"duration": "<string>",
"headers": {},
"resultCode": 123,
"result": {}
}
]
}Learn more: Webhooks & Notifications
Authorizations
Use HTTP Basic Authentication with your Application ID as username and Application Secret as password. Manage credentials in the Yapily Console. See Authentication for details.
Headers
The sub-application ID to which event type is being subscribed to
Body
application/json
Unique identifier of the event type (for which notifications will be sent).
Allowed values: payment.status, payment.status.completed, payment.isoStatus
Example:
"payment.status.completed"
Subscription details for how and where to receive notifications.
Show child attributes
Show child attributes
Was this page helpful?
⌘I