SMS Status Event Webhook Configuration

This section explains how users can configure webhooks in the Easify application to receive SMS status events. It also outlines how to securely verify the integrity of these events using the provided Signature Verification Secret.

Adding a Webhook URL

Steps to Add a Webhook:
  • Go to Settings -> API Settings -> SMS -> Status Update. Easify Sms Webhook Settings
Webhook Event Structure:

When an event is triggered, the application will send a POST request to the configured webhook URL with the following headers and body:

Headers
  • X-Easify-Signature: A Base64-encoded signature of the payload, generated using the verification secret.
  • X-Easify-Timestamp: The UNIX timestamp of the request.
Payload

The POST body contains the event data. Example:

{
  "sms_id": "63f7a88b2e4b6c001f33****",

  "sender": "+1234567***",

  "receiver": "+0987654***",

  "sms_type": "sms",

  "message": "Hai.",

  "media_url": "",

  "status": "Delivered",

  "remarks": "",

  "created_at": "2025-01-16 10:45:00"
}

Steps for Validating the Signature

  1. Extract Header and Payload Information

X-Easify-Signature and X-Easify-Timestamp from the request headers, and the raw JSON payload from the request body.

Read the body as raw bytes. Re-serialising a payload you have already parsed can reorder keys or change escaping, and the signature will no longer match.

  1. Recreate the Signature

Compute an HMAC-SHA256 of the raw payload using your webhook secret. The digest is then written as a lowercase hex string, and it is that hex string which is Base64-encoded. Base64-encoding the raw digest bytes instead is the most common cause of a signature that never matches.

  1. Compare the Signatures

Compare your computed value against the one received in the X-Easify-Signature header using a constant-time comparison.

  1. Validate the Timestamp

To prevent replay attacks, ensure the timestamp in X-Easify-Timestamp is within an acceptable range of the current time (±15 minutes / 900 seconds).

Pass the raw body, both header values and your webhook secret into a helper like the one below, and reject the request unless it returns true.

Validate the webhook signature
php

// Get the raw request body.
// Use the original body for signature verification without modifying it.
$rawBody = file_get_contents('php://input');

// Read the signature and timestamp sent in the webhook headers.
$receivedSignature = $_SERVER['HTTP_X_EASIFY_SIGNATURE'] ?? '';
$receivedTimestamp = (int) ($_SERVER['HTTP_X_EASIFY_TIMESTAMP'] ?? 0);

// Your webhook signing secret from the Easify -> API Settings -> Webhooks -> Secret Key
$webhookSecret = getenv('EASIFY_WEBHOOK_SECRET');

// Reject requests older than 15 minutes to prevent replay attacks.
if (abs(time() - $receivedTimestamp) > 900) {
    http_response_code(408);
    exit;
}

// Generate the expected signature using the webhook secret.
$computedSignature = base64_encode(hash_hmac('sha256', $rawBody, $webhookSecret));

// Compare the received signature with the expected signature.
if (!hash_equals($computedSignature, $receivedSignature)) {
    http_response_code(403);
    exit;
}

// Signature is valid, now decode and handle the event.
$payload = json_decode($rawBody, true);

// ... handle the event ...

http_response_code(200);

Incoming SMS Webhook Configuration

This section explains how users can configure webhooks in the Easify application to handle incoming SMS messages. It also details how to securely verify the authenticity of each request using the provided Signature Verification Secret.

Adding a Webhook URL

Steps to Add a Webhook:
  • Go to Settings -> API Settings -> SMS -> Incoming. Easify Sms Webhook Settings
Webhook Structure:

When an incoming SMS is received, the application will send a POST request to the configured webhook URL with the following headers and body:

Headers
  • X-Easify-Signature: A Base64-encoded signature of the payload, generated using the verification secret.
  • X-Easify-Timestamp: The UNIX timestamp of the request.
Payload

The POST body contains the event data. Example:

{
  "sms_id": 172789,

  "sender": "+1234567***",

  "receiver": "+0987654***",

  "sms_type": "sms",

  "message": "Hai.",

  "media_url": "",

  "created_at": "2025-05-14T05:18:41.000000Z"
}

Steps for Validating the Signature

  1. Extract Header and Payload Information

X-Easify-Signature and X-Easify-Timestamp from the request headers, and the raw JSON payload from the request body.

Read the body as raw bytes. Re-serialising a payload you have already parsed can reorder keys or change escaping, and the signature will no longer match.

  1. Recreate the Signature

Compute an HMAC-SHA256 of the raw payload using your webhook secret. The digest is then written as a lowercase hex string, and it is that hex string which is Base64-encoded. Base64-encoding the raw digest bytes instead is the most common cause of a signature that never matches.

  1. Compare the Signatures

Compare your computed value against the one received in the X-Easify-Signature header using a constant-time comparison.

  1. Validate the Timestamp

To prevent replay attacks, ensure the timestamp in X-Easify-Timestamp is within an acceptable range of the current time (±15 minutes / 900 seconds).

Pass the raw body, both header values and your webhook secret into a helper like the one below, and reject the request unless it returns true.

Validate the webhook signature
php

// Get the raw request body.
// Use the original body for signature verification without modifying it.
$rawBody = file_get_contents('php://input');

// Read the signature and timestamp sent in the webhook headers.
$receivedSignature = $_SERVER['HTTP_X_EASIFY_SIGNATURE'] ?? '';
$receivedTimestamp = (int) ($_SERVER['HTTP_X_EASIFY_TIMESTAMP'] ?? 0);

// Your webhook signing secret from the Easify -> API Settings -> Webhooks -> Secret Key
$webhookSecret = getenv('EASIFY_WEBHOOK_SECRET');

// Reject requests older than 15 minutes to prevent replay attacks.
if (abs(time() - $receivedTimestamp) > 900) {
    http_response_code(408);
    exit;
}

// Generate the expected signature using the webhook secret.
$computedSignature = base64_encode(hash_hmac('sha256', $rawBody, $webhookSecret));

// Compare the received signature with the expected signature.
if (!hash_equals($computedSignature, $receivedSignature)) {
    http_response_code(403);
    exit;
}

// Signature is valid, now decode and handle the event.
$payload = json_decode($rawBody, true);

// ... handle the event ...

http_response_code(200);

pixel for linkedin