Create a webhook
curl --request POST \
--url https://api.example.com/webhooks \
--header 'ApiKey: <apikey>' \
--header 'Content-Type: application/json' \
--header 'Environment: <environment>' \
--header 'MerchantId: <merchantid>' \
--data '
{
"url": "https://my.webhook.target",
"events": [
"payment.created",
"payment_intent.created"
],
"description": "This is a webhook trigger upon payment & payment_intent creation",
"metadata": {}
}
'import requests
url = "https://api.example.com/webhooks"
payload = {
"url": "https://my.webhook.target",
"events": ["payment.created", "payment_intent.created"],
"description": "This is a webhook trigger upon payment & payment_intent creation",
"metadata": {}
}
headers = {
"ApiKey": "<apikey>",
"MerchantId": "<merchantid>",
"Environment": "<environment>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
ApiKey: '<apikey>',
MerchantId: '<merchantid>',
Environment: '<environment>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://my.webhook.target',
events: ['payment.created', 'payment_intent.created'],
description: 'This is a webhook trigger upon payment & payment_intent creation',
metadata: {}
})
};
fetch('https://api.example.com/webhooks', 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.example.com/webhooks",
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([
'url' => 'https://my.webhook.target',
'events' => [
'payment.created',
'payment_intent.created'
],
'description' => 'This is a webhook trigger upon payment & payment_intent creation',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"ApiKey: <apikey>",
"Content-Type: application/json",
"Environment: <environment>",
"MerchantId: <merchantid>"
],
]);
$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.example.com/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://my.webhook.target\",\n \"events\": [\n \"payment.created\",\n \"payment_intent.created\"\n ],\n \"description\": \"This is a webhook trigger upon payment & payment_intent creation\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("ApiKey", "<apikey>")
req.Header.Add("MerchantId", "<merchantid>")
req.Header.Add("Environment", "<environment>")
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.example.com/webhooks")
.header("ApiKey", "<apikey>")
.header("MerchantId", "<merchantid>")
.header("Environment", "<environment>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://my.webhook.target\",\n \"events\": [\n \"payment.created\",\n \"payment_intent.created\"\n ],\n \"description\": \"This is a webhook trigger upon payment & payment_intent creation\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["ApiKey"] = '<apikey>'
request["MerchantId"] = '<merchantid>'
request["Environment"] = '<environment>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://my.webhook.target\",\n \"events\": [\n \"payment.created\",\n \"payment_intent.created\"\n ],\n \"description\": \"This is a webhook trigger upon payment & payment_intent creation\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "wh_z1urYtVFgEebtcj8fxp4v",
"createdAt": "2020-10-15T12:09:49.355Z",
"updatedAt": "2020-10-15T12:09:49.355Z",
"mode": "live",
"events": [
"payment.created",
"payment_intent.created"
],
"metadata": {},
"status": "enabled",
"url": "https://my.webhook.target",
"description": "This is a webhook trigger upon payment & payment_intent creation",
"secret": "5257a869e7ecebeda32affa62cd..."
}{
"status": 401,
"error": {
"type": "authorization_error",
"code": "wrong_credentials",
"message": "L'ID marchand et/ou la clé d'API sont incorrects."
}
}{
"type": "internal_error",
"code": [
"internal_error",
"wrong_credentials",
"not_granted",
"live_mode_not_granted",
"merchant_inactive"
],
"message": "An error occurred on our system. Please try again later."
}Webhooks
Create a webhook
POST
/
webhooks
Create a webhook
curl --request POST \
--url https://api.example.com/webhooks \
--header 'ApiKey: <apikey>' \
--header 'Content-Type: application/json' \
--header 'Environment: <environment>' \
--header 'MerchantId: <merchantid>' \
--data '
{
"url": "https://my.webhook.target",
"events": [
"payment.created",
"payment_intent.created"
],
"description": "This is a webhook trigger upon payment & payment_intent creation",
"metadata": {}
}
'import requests
url = "https://api.example.com/webhooks"
payload = {
"url": "https://my.webhook.target",
"events": ["payment.created", "payment_intent.created"],
"description": "This is a webhook trigger upon payment & payment_intent creation",
"metadata": {}
}
headers = {
"ApiKey": "<apikey>",
"MerchantId": "<merchantid>",
"Environment": "<environment>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
ApiKey: '<apikey>',
MerchantId: '<merchantid>',
Environment: '<environment>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://my.webhook.target',
events: ['payment.created', 'payment_intent.created'],
description: 'This is a webhook trigger upon payment & payment_intent creation',
metadata: {}
})
};
fetch('https://api.example.com/webhooks', 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.example.com/webhooks",
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([
'url' => 'https://my.webhook.target',
'events' => [
'payment.created',
'payment_intent.created'
],
'description' => 'This is a webhook trigger upon payment & payment_intent creation',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"ApiKey: <apikey>",
"Content-Type: application/json",
"Environment: <environment>",
"MerchantId: <merchantid>"
],
]);
$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.example.com/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://my.webhook.target\",\n \"events\": [\n \"payment.created\",\n \"payment_intent.created\"\n ],\n \"description\": \"This is a webhook trigger upon payment & payment_intent creation\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("ApiKey", "<apikey>")
req.Header.Add("MerchantId", "<merchantid>")
req.Header.Add("Environment", "<environment>")
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.example.com/webhooks")
.header("ApiKey", "<apikey>")
.header("MerchantId", "<merchantid>")
.header("Environment", "<environment>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://my.webhook.target\",\n \"events\": [\n \"payment.created\",\n \"payment_intent.created\"\n ],\n \"description\": \"This is a webhook trigger upon payment & payment_intent creation\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["ApiKey"] = '<apikey>'
request["MerchantId"] = '<merchantid>'
request["Environment"] = '<environment>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://my.webhook.target\",\n \"events\": [\n \"payment.created\",\n \"payment_intent.created\"\n ],\n \"description\": \"This is a webhook trigger upon payment & payment_intent creation\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "wh_z1urYtVFgEebtcj8fxp4v",
"createdAt": "2020-10-15T12:09:49.355Z",
"updatedAt": "2020-10-15T12:09:49.355Z",
"mode": "live",
"events": [
"payment.created",
"payment_intent.created"
],
"metadata": {},
"status": "enabled",
"url": "https://my.webhook.target",
"description": "This is a webhook trigger upon payment & payment_intent creation",
"secret": "5257a869e7ecebeda32affa62cd..."
}{
"status": 401,
"error": {
"type": "authorization_error",
"code": "wrong_credentials",
"message": "L'ID marchand et/ou la clé d'API sont incorrects."
}
}{
"type": "internal_error",
"code": [
"internal_error",
"wrong_credentials",
"not_granted",
"live_mode_not_granted",
"merchant_inactive"
],
"message": "An error occurred on our system. Please try again later."
}Headers
Body
application/json
The list of events to enable for this endpoint.
Available options:
receipt.created, sms.created, sms.sent, sms.received, sms.failed, transfer.created, transfer.processing, transfer.succeeded, transfer.failed, transfer_irt.created, transfer_irt.processing, transfer_irt.succeeded, transfer_irt.failed, deposit.created, deposit.pending, deposit.success, deposit.failed, payment_intent.created, payment_intent.processing, payment_intent.succeeded, payment_intent.action_required, payment_intent.payment_failed, payment.created, payment.pending, payment.succeeded, payment.action_required, payment.failed, provisioning.created, provisioning.succeeded, provisioning.failed, refund.created, refund.pending, refund.pending_manual, refund.failed, refund.successful, payment_refund.created, payment_refund.pending, payment_refund.pending_manual, payment_refund.failed, payment_refund.successful, transaction.payment_collected, transaction.deposit, provider.wave, payment_links.created, payment_links.expired, payment_links.completed, payment_links.closed, payment_links.paid, submerchant.created, submerchant.updated, bill_payment.collected, bill_payment.succeeded, bill_payment.settlement_failed, sender.created, sender.approved, sender.rejected, sender.review_required, sender.disabled, cross_border_transaction.successful, cross_border_transaction.failed, cross_border_transaction.compliance_review, cross_border_transaction.created, cross_border_transaction.pending, cross_border_transaction.pending_manual, cross_border_transaction.cancelled, subscription.created, subscription.cancelled, subscription.suspended, settlement_request.submitted, settlement_request.processing, settlement_request.funds_sent, settlement_request.confirmed, settlement_request.rejected Example:
["payment.created", "payment_intent.created"]
Response
Datetime in UTC timezone at which this object was created. Follows the Datetime ISO.
Example:
"2020-10-15T12:09:49.355Z"
Datetime in UTC timezone at which this object was updated. Follows the Datetime ISO.
Example:
"2020-10-15T12:09:49.355Z"
Mode in which this Webhook exists. The sandbox mode can be used during the integration phase and is available as soon as the merchant account is created. No real transactions are made in this mode. The live mode has to be used to make real transactions.
Available options:
live, sandbox Example:
"live"
