Home API Hub API Webhooks

API Reference

Webhooks & Real-Time Events

Receive instant HTTP callbacks when calls arrive or SMS messages land on your virtual numbers. Build automations, trigger AI agents, and integrate with any backend in real time.

How PBXme Webhooks Work

When an event occurs on your virtual number — an inbound call arrives, a call is answered, or an SMS is received — PBXme sends an HTTP POST request to a URL you specify. Your server receives the event payload, processes it, and responds with HTTP 200. No polling, no delay.

This is the mechanism that powers AI voice agent integrations: the webhook delivers the call to your AI system’s endpoint the moment a caller dials your number.

Event Reference

PBXme fires the following webhook events. Configure the destination URL per number via the dashboard or the DID Forward Setting API.

EventTriggerKey payload fields
incoming_callAn inbound call arrives on your virtual numberdid_number, caller_id, timestamp
call_answeredThe call is picked up at the forwarding destinationdid_number, caller_id, destination, timestamp
call_endedA call on this number terminatesdid_number, caller_id, duration_sec, timestamp
sms_receivedAn inbound SMS arrives on an SMS-enabled numberfrom, to, message, timestamp

Payload Examples & Webhook Handler

Sample payloads sent by PBXme and an Express.js handler that processes both call and SMS events:

Incoming call payload (HTTP POST body):

{
  "event":      "incoming_call",
  "did_number": "+447911123456",
  "caller_id":  "+19175550100",
  "timestamp":  "2024-11-15T14:32:00Z"
}

Inbound SMS payload (HTTP POST body):

{
  "event":     "sms_received",
  "from":      "+19175550100",
  "to":        "+447911123456",
  "message":   "Hello, is this line active?",
  "timestamp": "2024-11-15T14:33:12Z"
}

Express.js webhook handler — handles both calls and SMS:

// npm install express
const express = require("express");
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

app.post("/pbxme/webhook", (req, res) => {
  const payload = req.body;

  switch (payload.event) {

    case "incoming_call":
      console.log(`📞 Inbound call on ${payload.did_number} from ${payload.caller_id}`);
      // → Route to AI agent, trigger IVR, log to CRM, etc.
      break;

    case "call_ended":
      console.log(`📴 Call ended. Duration: ${payload.duration_sec}s`);
      // → Update billing records, trigger follow-up automation
      break;

    case "sms_received":
      console.log(`✉️  SMS from ${payload.from}: "${payload.message}"`);
      // → Forward to support desk, trigger auto-reply, log to CRM
      break;

    default:
      console.log("Unknown event:", payload.event);
  }

  // Always respond 200 to acknowledge receipt
  res.status(200).send("OK");
});

app.listen(3000, () => console.log("Webhook listening on port 3000"));

FAQ — Webhooks

You can set a webhook URL via the PBXme dashboard when configuring your number’s forwarding settings, or programmatically using the DID Forward Setting API endpoint by specifying your URL as the destination with type set to webhook.

PBXme sends webhook events as HTTP POST requests with a JSON or form-encoded body containing the event type and relevant data. Your endpoint should respond with HTTP 200 to acknowledge receipt.

Yes. This is one of the primary use cases. When an inbound call arrives, the webhook fires and your AI agent’s endpoint receives the call details instantly. Combined with SIP forwarding, this enables AI agents to answer calls as soon as they arrive.

    Sales, click to chat