Skip to content

Webhooks

Receive real-time notifications when events occur on Menon Mobility.

Overview

Webhooks allow your application to receive HTTP callbacks when events happen, such as:

  • New listing created or updated
  • Message received
  • Subscription changed
  • Payment processed
  • Booking events

Endpoints Overview

MethodEndpointDescriptionAuth
GET/api/seller/webhooksList your webhooksSeller
POST/api/seller/webhooksCreate webhookSeller
PATCH/api/seller/webhooks/:idUpdate webhookSeller
DELETE/api/seller/webhooks/:idDelete webhookSeller
POST/api/seller/webhooks/:id/testSend test eventSeller

Setting Up Webhooks

Via Dashboard

  1. Go to Dashboard > Settings > API > Webhooks
  2. Click "Add Webhook"
  3. Enter your endpoint URL
  4. Select events to subscribe to
  5. Save and copy the signing secret

Via API

http
POST /api/seller/webhooks
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "url": "https://yourapp.com/webhooks/menon",
  "events": [
    "listing.created",
    "listing.updated",
    "message.received"
  ]
}

Response

json
{
  "success": true,
  "data": {
    "webhook": {
      "id": "wh_abc123",
      "url": "https://yourapp.com/webhooks/menon",
      "events": ["listing.created", "listing.updated", "message.received"],
      "status": "active",
      "secret": "whsec_abc123...",
      "createdAt": "2024-01-15T10:00:00Z"
    }
  }
}

Secret Storage

Store the webhook secret securely. It is only shown once at creation time.

Webhook Events

Listing Events

EventDescription
listing.createdNew listing created
listing.updatedListing updated
listing.publishedListing published
listing.unpublishedListing unpublished
listing.deletedListing deleted
listing.soldListing marked as sold

Message Events

EventDescription
message.receivedNew message received
message.readMessage marked as read
conversation.createdNew conversation started

Inquiry Events

EventDescription
inquiry.createdNew inquiry on listing
inquiry.respondedInquiry responded to

Subscription Events

EventDescription
subscription.createdNew subscription
subscription.updatedPlan changed
subscription.canceledSubscription canceled
subscription.renewedAuto-renewal processed

Payment Events

EventDescription
payment.succeededPayment successful
payment.failedPayment failed
invoice.createdInvoice generated
invoice.paidInvoice paid

User Events

EventDescription
user.createdNew user registered
user.verifiedUser verified

Webhook Payload

Standard Format

All webhooks follow this format:

json
{
  "id": "evt_abc123",
  "type": "listing.created",
  "created_at": "2024-01-15T10:30:00Z",
  "data": {
    // Event-specific data
  }
}

Example: listing.created

json
{
  "id": "evt_abc123",
  "type": "listing.created",
  "created_at": "2024-01-15T10:30:00Z",
  "data": {
    "listing": {
      "id": "lst_xyz",
      "title": "2021 Volvo FH 500",
      "price": 85000,
      "currency": "EUR",
      "category": "trucks",
      "status": "draft",
      "seller_id": "sel_123",
      "created_at": "2024-01-15T10:30:00Z"
    }
  }
}

Example: message.received

json
{
  "id": "evt_def456",
  "type": "message.received",
  "created_at": "2024-01-15T14:30:00Z",
  "data": {
    "message": {
      "id": "msg_789",
      "conversation_id": "conv_123",
      "content": "Is this vehicle still available?",
      "sender": {
        "id": "usr_456",
        "name": "John Smith"
      },
      "listing": {
        "id": "lst_xyz",
        "title": "2021 Volvo FH 500"
      },
      "sent_at": "2024-01-15T14:30:00Z"
    }
  }
}

Example: subscription.created

json
{
  "id": "evt_ghi789",
  "type": "subscription.created",
  "created_at": "2024-01-15T15:00:00Z",
  "data": {
    "subscription": {
      "id": "sub_abc",
      "plan": {
        "id": "plan_professional",
        "name": "Professional"
      },
      "user_id": "usr_123",
      "status": "active",
      "billing_cycle": "monthly",
      "price": {
        "amount": 149,
        "currency": "USD"
      },
      "created_at": "2024-01-15T15:00:00Z"
    }
  }
}

Verifying Webhooks

Signature Verification

Each webhook includes a signature header:

X-Menon-Signature: sha256=abc123...

Verify in Node.js

javascript
const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');

  return `sha256=${expectedSignature}` === signature;
}

// In your webhook handler
app.post('/webhooks/menon', (req, res) => {
  const signature = req.headers['x-menon-signature'];
  const payload = JSON.stringify(req.body);

  if (!verifyWebhook(payload, signature, WEBHOOK_SECRET)) {
    return res.status(401).send('Invalid signature');
  }

  // Process webhook
  const event = req.body;
  console.log('Received:', event.type);

  res.status(200).send('OK');
});

Verify in Python

python
import hmac
import hashlib

def verify_webhook(payload, signature, secret):
    expected = hmac.new(
        secret.encode(),
        payload.encode(),
        hashlib.sha256
    ).hexdigest()
    return f'sha256={expected}' == signature

Handling Webhooks

Best Practices

Return 200 Quickly

Respond with 200 status immediately, then process asynchronously.

Handle Duplicates

Events may be sent multiple times. Use event ID for idempotency.

Verify Signatures

Always verify webhook signatures in production.

Retry Policy

Failed webhooks are retried:

AttemptDelay
1Immediate
21 minute
35 minutes
430 minutes
52 hours
624 hours

After 6 failures, webhook is disabled.

Managing Webhooks

List Webhooks

bash
GET /v1/webhooks
Authorization: Bearer YOUR_API_KEY

Get Webhook

bash
GET /v1/webhooks/wh_abc123
Authorization: Bearer YOUR_API_KEY

Update Webhook

bash
PUT /v1/webhooks/wh_abc123
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "events": ["listing.created", "listing.updated"],
  "status": "active"
}

Delete Webhook

bash
DELETE /v1/webhooks/wh_abc123
Authorization: Bearer YOUR_API_KEY

Webhook Logs

View Delivery Logs

bash
GET /v1/webhooks/wh_abc123/logs
Authorization: Bearer YOUR_API_KEY

Response

json
{
  "success": true,
  "data": {
    "logs": [
      {
        "id": "log_123",
        "event_id": "evt_abc",
        "event_type": "listing.created",
        "status": "delivered",
        "response_code": 200,
        "response_time_ms": 150,
        "delivered_at": "2024-01-15T10:30:01Z"
      },
      {
        "id": "log_124",
        "event_id": "evt_def",
        "event_type": "message.received",
        "status": "failed",
        "response_code": 500,
        "error": "Internal Server Error",
        "retry_count": 2,
        "next_retry": "2024-01-15T10:35:00Z"
      }
    ]
  }
}

Retry Failed Webhook

bash
POST /v1/webhooks/wh_abc123/logs/log_124/retry
Authorization: Bearer YOUR_API_KEY

Testing Webhooks

Send Test Event

bash
POST /v1/webhooks/wh_abc123/test
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "event_type": "listing.created"
}

Using Webhook Tester

  1. Go to Settings > API > Webhooks
  2. Click on webhook
  3. Click "Send Test"
  4. Select event type
  5. View delivery result

Commercial Vehicle Marketplace