Create a Webhook
Creates a Webhook resource.
Creating webhooks
As of this writing, you can create webhooks via API. In future releases, we will allow you to create a webhook via Dashboard.
Endpoint
POST /webhooks
Sample code
- curl
- Node
- PHP
- Python
- Ruby
curl --request POST --location 'https://api.payrexhq.com/webhooks' \
-u replace_with_secret_api_key: \
--data-urlencode 'url=https://my-ecommerce.com/send-shipments' \
--data-urlencode 'description=test description' \
--data-urlencode 'events[]=payment_intent.succeeded'
const client = require('payrex-node')('insert your PayRex Secret API key.');
const webhook = await client.webhooks.create({
url: 'https://my-ecommerce.com/send-shipments',
description: 'test description',
events: ['payment_intent.succeeded'],
});
$client = new \Payrex\PayrexClient('insert your PayRex Secret API key.');
$webhook = $client->webhooks->create([
'url' => 'https://my-ecommerce.com/send-shipments',
'description' => 'test description',
'events' => ['payment_intent.succeeded'],
]);
from payrex import Client as PayrexClient
client = PayrexClient('insert your PayRex Secret API key.')
webhook = client.webhooks.create(
{
'url': 'https://my-ecommerce.com/send-shipments',
'description': 'test description',
'events': ['payment_intent.succeeded']
}
)
client = Payrex::Client.new("insert your PayRex Secret API key.")
webhook = client.webhooks.create(
url: "https://my-ecommerce.com/send-shipments",
description: "test description",
events: ["payment_intent.succeeded"]
)
Parameters
url REQUIRED
The URL where PayRex will send the event that happened from your account. For security purposes, the URL must be using HTTPS protocol.
description optional
An arbitrary string attached to the Webhook. You can use this to give more information about the Webhook resource.
events REQUIRED
An array of strings that defines the list of events the webhook will listen to. To learn about the possible values, please refer to this list.
Returns
Returns a Webhook resource.