Test Webhooks
What are webhooks
Webhooks are user-defined HTTP callback that notifies you about any action that has taken place.
Ant uses webhooks to push real-time notifications to your applications. By configuring webhooks, you can receive event notifications and use these notifications to execute actions in your backend systems.
Steps to receive webhooks
You can start receiving event notifications in your applications using the steps in this section:
Create a webhook endpoint.
Send your URL to your customer service
Handle requests from ANT by parsing each event and returning
2xx
response status codes.
Step 1: Create a webhook endpoint
You can build your webhook with code. Here is an example of Java code:
@GetMapping("/ant-sms-deliver")
public ResponseEntity<Object> listenAnt(@RequestParam(name = "smsId") String msgId,
@RequestParam(name = "destination") String destination,
@RequestParam(name = "sendTime") String sendTime,
@RequestParam(name = "sendResult") String sendResult,
@RequestParam(name = "dr") String dr,
@RequestParam(name = "smsCount") String smsCount) {
try {
//todo your code
}catch (Exception e){
ILogger.info("listenAnt err ", e);
}
return new ResponseEntity<>(org.springframework.http.HttpStatus.OK);
}
Step 2: Send your URL to ANT
https://your-server/ant-sms-deliver
Step 3: Handle requests from ANT
Check event objects
Each event is structured as an event object with common properties: smsId
,destination
,sendTime
, sendResult
and smsCount
Your webhook?
smsId=d3b0axxxxx070fb4dce8
&sendTime=1734509284831
&sendResult=SUCCESS
&smsCount=1&dr=000
&destination=002348xxxxx5348
Return a 2xx response
Your endpoint must quickly return a successful HTTP status (e.g., 200
) before any complex logic that could cause a timeout.
Last updated