Skip to main content
Webhooks notify your application when events occur in the Sohar platform. They use HTTPS and deliver JSON payloads so you can respond to updates in real time.
1

Create a Local Endpoint

In your application, create a route that accepts POST requests. Below is an example using Node.js with Express:
const express = require('express');
const app = express();

app.use(express.json());

app.post('/webhooks', (req, res) => {
  const event = req.body;
  console.log(event);
  res.status(200).end();
});

app.listen(3000, () => console.log('Listening on port 3000'));
Whenever you receive an event, respond with HTTP 200 OK to acknowledge receipt.
You can create a tunnel to your localhost server using a tool like ngrok. For example: https://fa8b-9-27-207-123.ngrok-free.app/webhooks
2

Register Your Endpoint

You must use production credentials to call the Create Webhook and register your endpoint, which will generate an endpointId. With these credentials, call the Create Event API to subscribe your endpoint to events. For testing, the sandbox.verification.updated event is recommended.
Even though webhooks are managed by production credentials, all webhook endpoints can subscribe to production and sandbox events.
3

Test Your Endpoint

Send a few test requests to confirm that your endpoint receives events. If your endpoint is subscribed to the sandbox.verification.updated event, you can call the Create Verification API with sandbox credentials and sandbox values for testing purposes.
4

Deploy Your Endpoint

After testing, deploy your endpoint to your production environment. Use the Create Webhook API to register your production URL so that live events can be delivered.