Contents
On this page
Create Webhook - Plugixa POS for WooCommerce
POST /plugixa-pos/v1/webhooks
Add a webhook. The signing secret is in the answer, and only this once: store it.
Needs a user with the plugixa_pos_manage_settings capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators hold it; other roles only when you grant it.
Request
POST https://your-site.example/wp-json/plugixa-pos/v1/webhooks
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Up to 120 characters. |
url |
string |
Yes | An https:// address on a public host. Private and local network addresses are refused. |
events |
string[] |
Yes | One or more of sale.completed, sale.refunded, layaway.payment, layaway.refunded, register.opened, register.closed, cash.movement, quote.created, quote.converted, stock.adjusted. |
active |
boolean |
No | Send or pause. Defaults to true. |
{
"name": "Accounting sync",
"url": "https://hooks.example.com/pos",
"events": ["sale.completed", "sale.refunded"]
}
Responses
201 Created. data is the webhook plus secret.
{
"success": true,
"data": {
"id": 1,
"name": "Accounting sync",
"url": "https://hooks.example.com/pos",
"events": ["sale.completed", "sale.refunded"],
"active": true,
"failure_count": 0,
"last_status": 0,
"last_sent_at": null,
"signing": true,
"deliveries": {
"pending": 0,
"delivered": 0,
"failed": 0
},
"secret": "whsec_8c1f2e7a9b4d6f03a5e2c8b1d7f4a9e6b2c4d6e8f0a1b3c5"
}
}
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_pos_invalid |
No name, or no known event. |
422 |
plugixa_pos_webhook_url |
The address is not allowed. The message says why (not https, not found, private network). |
500 |
plugixa_pos_secrets |
The server cannot encrypt the secret (OpenSSL missing). |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-pos/v1/webhooks" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Accounting sync","url":"https://hooks.example.com/pos","events":["sale.completed","sale.refunded"]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-pos/v1/webhooks');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Accounting sync',
'url' => 'https://hooks.example.com/pos',
'events' => ['sale.completed', 'sale.refunded'],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-pos/v1/webhooks', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: 'Accounting sync', url: 'https://hooks.example.com/pos', events: ['sale.completed', 'sale.refunded'] }),
});
const { data } = await response.json();
Quick Links
Share