Register Webhook Endpoint
REST API endpoint to register and subscribe to webhooks in WSMS.
This endpoint allows you to register and subscribe to webhooks in WSMS. Use it to receive updates or notifications when specific events occur.
Endpoint
POST /wp-json/wpsms/v1/webhook
Authentication
WSMS supports Application Password authentication (WordPress 5.6+).
Creating an Application Password
- Go to Users → Profile in WordPress admin
- Scroll to Application Passwords section
- Enter a name in the New Application Password Name field
- Click Add New Application Password
- Copy the generated password
Use your WordPress username or email as the username with the Application Password.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
webhook_url | string | Yes | The URL to receive webhook notifications |
type | string | Yes | Event type: new_subscriber or new_sms |
Event Types
| Type | Description |
|---|---|
new_subscriber | Triggered when a new subscriber signs up |
new_sms | Triggered when a new SMS is received |
Examples
cURL
curl --location --request POST 'https://site.com/wp-json/wpsms/v1/webhook' \
--header 'Authorization: Basic YOUR_API_KEY' \
--form 'webhook_url="https://your-webhook-url.com"' \
--form 'type="new_sms"'
PHP
<?php
$username = 'your-username';
$password = 'your-application-password';
$auth = base64_encode("$username:$password");
$url = 'https://site.com/wp-json/wpsms/v1/webhook';
$args = array(
'headers' => array(
'Authorization' => 'Basic ' . $auth,
),
'body' => array(
'webhook_url' => 'https://your-webhook-url.com',
'type' => 'new_sms',
),
);
$response = wp_remote_post($url, $args);
Use Cases
- Integrate with Zapier or other automation tools
- Sync new subscribers with external CRM
- Log incoming SMS messages to external systems
- Trigger custom workflows on specific events
Related
- Send SMS Endpoint - Send SMS messages via API
- Newsletter Subscribe Endpoint - Subscribe users to newsletter
Last updated: December 23, 2024