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

  1. Go to Users → Profile in WordPress admin
  2. Scroll to Application Passwords section
  3. Enter a name in the New Application Password Name field
  4. Click Add New Application Password
  5. Copy the generated password

Use your WordPress username or email as the username with the Application Password.

Request Parameters

ParameterTypeRequiredDescription
webhook_urlstringYesThe URL to receive webhook notifications
typestringYesEvent type: new_subscriber or new_sms

Event Types

TypeDescription
new_subscriberTriggered when a new subscriber signs up
new_smsTriggered 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

Last updated: December 23, 2024