Create a subscription
curl --request POST \
--url https://external.pleo.io/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json;charset=UTF-8' \
--data '
{
"endpointUrl": "https://example.com/webhook",
"eventTypes": [
"v1.export-job.created"
],
"customHeaders": {
"user": "pass"
},
"endpointAuth": {
"credentials": {
"password": "password",
"token": "token",
"username": "username"
},
"type": "NONE"
},
"status": "ACTIVE"
}
'import requests
url = "https://external.pleo.io/v1/subscriptions"
payload = {
"endpointUrl": "https://example.com/webhook",
"eventTypes": ["v1.export-job.created"],
"customHeaders": { "user": "pass" },
"endpointAuth": {
"credentials": {
"password": "password",
"token": "token",
"username": "username"
},
"type": "NONE"
},
"status": "ACTIVE"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json;charset=UTF-8"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'application/json;charset=UTF-8'
},
body: JSON.stringify({
endpointUrl: 'https://example.com/webhook',
eventTypes: ['v1.export-job.created'],
customHeaders: {user: 'pass'},
endpointAuth: {
credentials: {password: 'password', token: 'token', username: 'username'},
type: 'NONE'
},
status: 'ACTIVE'
})
};
fetch('https://external.pleo.io/v1/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://external.pleo.io/v1/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([
'endpointUrl' => 'https://example.com/webhook',
'eventTypes' => [
'v1.export-job.created'
],
'customHeaders' => [
'user' => 'pass'
],
'endpointAuth' => [
'credentials' => [
'password' => 'password',
'token' => 'token',
'username' => 'username'
],
'type' => 'NONE'
],
'status' => 'ACTIVE'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json;charset=UTF-8"
],
]);
$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://external.pleo.io/v1/subscriptions"
payload := strings.NewReader("{\n \"endpointUrl\": \"https://example.com/webhook\",\n \"eventTypes\": [\n \"v1.export-job.created\"\n ],\n \"customHeaders\": {\n \"user\": \"pass\"\n },\n \"endpointAuth\": {\n \"credentials\": {\n \"password\": \"password\",\n \"token\": \"token\",\n \"username\": \"username\"\n },\n \"type\": \"NONE\"\n },\n \"status\": \"ACTIVE\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json;charset=UTF-8")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://external.pleo.io/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json;charset=UTF-8")
.body("{\n \"endpointUrl\": \"https://example.com/webhook\",\n \"eventTypes\": [\n \"v1.export-job.created\"\n ],\n \"customHeaders\": {\n \"user\": \"pass\"\n },\n \"endpointAuth\": {\n \"credentials\": {\n \"password\": \"password\",\n \"token\": \"token\",\n \"username\": \"username\"\n },\n \"type\": \"NONE\"\n },\n \"status\": \"ACTIVE\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://external.pleo.io/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json;charset=UTF-8'
request.body = "{\n \"endpointUrl\": \"https://example.com/webhook\",\n \"eventTypes\": [\n \"v1.export-job.created\"\n ],\n \"customHeaders\": {\n \"user\": \"pass\"\n },\n \"endpointAuth\": {\n \"credentials\": {\n \"password\": \"password\",\n \"token\": \"token\",\n \"username\": \"username\"\n },\n \"type\": \"NONE\"\n },\n \"status\": \"ACTIVE\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"createdAt": "2022-01-01T00:00:00Z",
"endpointUrl": "https://example.com/webhook",
"eventTypes": "v1.export-job.created",
"id": "123e4567-e89b-12d3-a456-426614174000",
"status": "ACTIVE",
"updatedAt": "2022-01-10T00:00:00Z",
"customHeaders": {
"user": "pass"
},
"deletedAt": "2022-01-01T00:00:00Z",
"deletedBy": "urn:pleo:organisation:12345678-1234-1234-1234-123456789012",
"endpointAuth": {
"credentials": {
"password": "password",
"token": "token",
"username": "username"
},
"type": "NONE"
}
}
}"Bad Request""Cannot create subscription due to infrastructure issue. Please try after some time. If the problem persists, reach out to Pleo customer support."Subscriptions
Create a subscription
Creates a subscription for given event type(s).
POST
/
v1
/
subscriptions
Create a subscription
curl --request POST \
--url https://external.pleo.io/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json;charset=UTF-8' \
--data '
{
"endpointUrl": "https://example.com/webhook",
"eventTypes": [
"v1.export-job.created"
],
"customHeaders": {
"user": "pass"
},
"endpointAuth": {
"credentials": {
"password": "password",
"token": "token",
"username": "username"
},
"type": "NONE"
},
"status": "ACTIVE"
}
'import requests
url = "https://external.pleo.io/v1/subscriptions"
payload = {
"endpointUrl": "https://example.com/webhook",
"eventTypes": ["v1.export-job.created"],
"customHeaders": { "user": "pass" },
"endpointAuth": {
"credentials": {
"password": "password",
"token": "token",
"username": "username"
},
"type": "NONE"
},
"status": "ACTIVE"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json;charset=UTF-8"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'application/json;charset=UTF-8'
},
body: JSON.stringify({
endpointUrl: 'https://example.com/webhook',
eventTypes: ['v1.export-job.created'],
customHeaders: {user: 'pass'},
endpointAuth: {
credentials: {password: 'password', token: 'token', username: 'username'},
type: 'NONE'
},
status: 'ACTIVE'
})
};
fetch('https://external.pleo.io/v1/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://external.pleo.io/v1/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([
'endpointUrl' => 'https://example.com/webhook',
'eventTypes' => [
'v1.export-job.created'
],
'customHeaders' => [
'user' => 'pass'
],
'endpointAuth' => [
'credentials' => [
'password' => 'password',
'token' => 'token',
'username' => 'username'
],
'type' => 'NONE'
],
'status' => 'ACTIVE'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json;charset=UTF-8"
],
]);
$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://external.pleo.io/v1/subscriptions"
payload := strings.NewReader("{\n \"endpointUrl\": \"https://example.com/webhook\",\n \"eventTypes\": [\n \"v1.export-job.created\"\n ],\n \"customHeaders\": {\n \"user\": \"pass\"\n },\n \"endpointAuth\": {\n \"credentials\": {\n \"password\": \"password\",\n \"token\": \"token\",\n \"username\": \"username\"\n },\n \"type\": \"NONE\"\n },\n \"status\": \"ACTIVE\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json;charset=UTF-8")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://external.pleo.io/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json;charset=UTF-8")
.body("{\n \"endpointUrl\": \"https://example.com/webhook\",\n \"eventTypes\": [\n \"v1.export-job.created\"\n ],\n \"customHeaders\": {\n \"user\": \"pass\"\n },\n \"endpointAuth\": {\n \"credentials\": {\n \"password\": \"password\",\n \"token\": \"token\",\n \"username\": \"username\"\n },\n \"type\": \"NONE\"\n },\n \"status\": \"ACTIVE\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://external.pleo.io/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json;charset=UTF-8'
request.body = "{\n \"endpointUrl\": \"https://example.com/webhook\",\n \"eventTypes\": [\n \"v1.export-job.created\"\n ],\n \"customHeaders\": {\n \"user\": \"pass\"\n },\n \"endpointAuth\": {\n \"credentials\": {\n \"password\": \"password\",\n \"token\": \"token\",\n \"username\": \"username\"\n },\n \"type\": \"NONE\"\n },\n \"status\": \"ACTIVE\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"createdAt": "2022-01-01T00:00:00Z",
"endpointUrl": "https://example.com/webhook",
"eventTypes": "v1.export-job.created",
"id": "123e4567-e89b-12d3-a456-426614174000",
"status": "ACTIVE",
"updatedAt": "2022-01-10T00:00:00Z",
"customHeaders": {
"user": "pass"
},
"deletedAt": "2022-01-01T00:00:00Z",
"deletedBy": "urn:pleo:organisation:12345678-1234-1234-1234-123456789012",
"endpointAuth": {
"credentials": {
"password": "password",
"token": "token",
"username": "username"
},
"type": "NONE"
}
}
}"Bad Request""Cannot create subscription due to infrastructure issue. Please try after some time. If the problem persists, reach out to Pleo customer support."Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json;charset=UTF-8
Create Subscription request
The URL where the events should be sent
Example:
"https://example.com/webhook"
Name of the event types you wish to subscribe to. Possible values can be found in the EventType enum.
Name of the event types you wish to subscribe to. Possible values can be found in the EventType enum.
Example:
["v1.export-job.created"]
Key values as headers to be sent to the webhooks vendor
Show child attributes
Show child attributes
Example:
{ "user": "pass" }
Authentication details for the endpoint
Show child attributes
Show child attributes
Status of subscription
Available options:
INACTIVE, ACTIVE Example:
"ACTIVE"
Response
A subscription for webhook notification is successfully created.
Show child attributes
Show child attributes