How webhooks work
A webhook is a URL of your application. Amplia Reg calls this URL when something happens to an order that your application created. For
example, Amplia Reg sends a POST to this URL when the agent approves the order or when the certificate is issued. As a result, your
application knows about each status change and does not have to query the order again and again.
The path of a notification
Agent Amplia Reg Your application
| | |
|-- approves order -->| |
| |-- POST https://your-url --------->| 1. Checks the authentication header
| | { "type": ..., ... } | 2. Responds 2xx
| |<--------------------- 200 OK -----| 3. Processes the event
- An order created by your application changes status, because of an agent, the holder or Amplia Reg itself.
- If the webhook of the application that created the order is enabled at that moment, Amplia Reg records a notification for the application.
- Amplia Reg sends the notification in the background. The notification is a
POSTwith a JSON body to the registered URL, with the secret in the authentication header. - Your application responds. A
2xxresponse ends the delivery.
Which orders trigger notifications
Only the orders that the application created trigger notifications to it. Orders that an agent created in the control panel, or that a different application created, do not. Also, the webhook does not notify changes that occurred before you enabled it.
Every status change triggers an OrderStatusChanged notification, including the order creation. Video identification orders also trigger
an OrderVideoIdentificationCompleted notification when the holder finishes the recording. See the Event reference.
Delivery and retries
Any response other than 2xx, or no response, counts as a failed delivery. When delivery fails, Amplia Reg tries to deliver the
notification again later. The Webhook notifications section of the application shows the number of attempts and the
response or the error of the last attempt.
Amplia Reg reads the webhook settings at the time of each delivery. If you disable the webhook before the delivery, the pending notifications are not delivered.
Retries do not guarantee the delivery. To recover the changes that your application missed, see Recover missed changes.
Ordering and duplicates
Amplia Reg delivers each notification independently, so notifications can arrive out of order, especially after a retry. For example,
the Issued notification can arrive before the WaitingIssue notification. The date field shows when each change occurred.
The same notification can also arrive more than once. If your application processed the notification but the response did not reach Amplia Reg, the delivery counts as failed. Amplia Reg then sends the notification again.
Register and receive webhooks shows how to handle both cases.
New values
Lacuna can add new event types, statuses and reasons to Amplia Reg. If your application ignores an unknown type and treats an unknown
reason as Other, it continues to work after such a change.