Use a webhook to keep track of changes in verification statuses of your user's addresses.
Integration steps
0
Required
1
Required
2
Optional
3
Required
4
Optional
1. Configure a webhook listener
A webhook listener is a server that listens at a specific URL for incoming HTTP POST notification messages that are triggered when a status change event occurs.
This documentation describes the webhook events sent during the address verification process. There are four main events:
Webhook timeouts When OkHi sends an event to a webhook endpoint, the service must respond within 15 seconds. If OkHi does not receive a response within that period, the system logs a timeout error and retries the event later.
Destination endpoint APIs have fluctuations in availability due to a number of issues ranging from network failures to overload to bugs. OkHi’s internal systems retry failed destination API calls for few minutes with an exponential backoff after each attempt. This substantially improves delivery rates.
Take note that, in the event of a timeout error, where the destination API endpoint does process the event beyond the set time out window. When OkHi retries the event later, the destination API endpoint will end up with a duplicate event.
2. Test your webhook (optional)
Once you have configured your webhook, test it by making a POST request to your webhook similar to the example below. See description of the event parameters here.
curl--location--requestPOST'localhost:3000/webhook' \--header 'Content-Type: application/json' \--header 'okhi-authorization: N2Y2YzQzOGUtNGRkZS00ZDkzLTllZmItN2JmYmYwMjE3OTI5' \--data-raw '{ "event_type": "address.collected", "event_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "api_version": "v3", "event_timestamp": 1686089970, "data": { "usage_types": ["digital_verification"], "user": { "id": "hbZ69KMuYB", "first_name": "Gift", "last_name": "Moore", "phone": "+2347012345678", "email": "gift@okhi.co" }, "metadata": { "org_id": "iNjNabYBcK", "app_id": "NstCO4hx04", "branch_id": "SS3RrryAAT", "user_id": "6719380b20f46199b339f504", "app_user_id": "x123" }, "location": { "ward": "Ikoyi I", "formatted_address": "15 Eletu Ogabi Street, Victoria Island, Eti Osa, Lagos, 106104, Nigeria, Directions: Turn left at the red shop", "post_code": "106104", "street_name": "Eletu Ogabi Street", "property_number": "15", "neighborhood": "Victoria Island", "district": "Eti Osa", "lga": "Eti Osa", "city": "Lagos", "state": "Lagos", "country": "Nigeria", "country_code": "ng", "geo_point": { "lat": 6.4281, "lon": 3.4219 }, "user_id": "6719380b23f45199b339f504", "directions": "Turn left at the red shop", "id": "673499e92cc56b50cbac4894", "url": "https://okhi.me/673499e92cc93b50cbac4894", "plus_code": "6FR5CCHC+6Q", "address_line_1": "15 Eletu Ogabi Street, Victoria Island, Eti Osa, Lagos, 106104, Nigeria", "usage_types": [ "digital_verification" ] } }}'
To register your webhook listener for events, access OkDash by logging in, select "Settings" and proceed to enter your webhook URL.
4. Validate your webhook using real-time data
After successfully subscribing your webhook listener to events, put it to the test by creating a new address and initiating verification. Your webhook will then receive notifications as intended and demonstrate its expected functionality.
Congratulations!
You have a basic webhook endpoint ready to accept verification events from OkHi. Now add the application logic that your business needs to handle the events you care the most about. You can also extend the endpoint with the steps below to verify the authenticity of the requests.
Secure your webhook
Webhook signature verification
When a webhook is sent, the payload is signed with a shared webhook signature key using HMAC-SHA256. The signature is included in the request headers. The receiving server may verify this signature before processing the webhook. Get your webhook signature key from OkDash settings page. See a detailed guide on how to implement this here.
Custom header verification
You can verify webhook event notifications that your listener receives when events occur. To verify event notifications, add a custom header to your webhook by adding it on your app configuration on OkDash Settings. We will then send the custom header along with each webhook event and you can validate the events based on correctness of the custom header.
Events
Event Type: address.collected
Description: Triggered when an address is collected from the user, containing comprehensive details about the address, user, and associated metadata.
Fields Overview:
event_type: Specifies the event type (always "address.collected" for this event).
event_id: Unique identifier for the event instance.
api_version: The API version used.
event_timestamp: Unix timestamp representing when the event occurred (in seconds).
data: Contains the event's main data:
usage_types: Types of usage for the location (e.g., ["digital_verification"]).
user: Details about the user who provided the location.
metadata: Contextual metadata for the event.
location: Comprehensive information about the location.
Note: The app_user_id field within the metadata section is your custom app user ID provided during the collection of location data, which is used to uniquely identify users within your application.
Example Payload:
{"event_type":"address.collected","event_id":"01ARZ3NDEKTSV4RRFFQ69G5FAV","api_version":"v3","event_timestamp":1686089970,"data": {"usage_types": ["digital_verification"],"user": {"id":"hbZ69KMuYB","first_name":"Gift","last_name":"Moore","phone":"+2347012345678","email":"gift@okhi.co" },"metadata": {"org_id":"iNjNabYBcK","app_id":"NstCO4hx04","branch_id":"SS3RrryAAT","user_id":"6719380b20f45199b339f504","app_user_id":"x123", },"location": {"ward":"Ikoyi I","formatted_address":"15 Eletu Ogabi Street, Victoria Island, Eti Osa, Lagos, 106104, Nigeria, Directions: Turn left at the red shop","post_code":"106104","street_name":"Eletu Ogabi Street","property_number":"15","neighborhood":"Victoria Island","district":"Eti Osa","lga":"Eti Osa","city":"Lagos","state":"Lagos","country":"Nigeria","country_code":"ng","geo_point": {"lat":6.4281,"lon":3.4219 },"user_id":"6719380b20f45199b339f504","directions":"Turn left at the red shop","id":"673499e92cc93b50cbac4894","url":"https://okhi.me/674599e92cc93b50cbac4894","plus_code":"6FR5CCHC+6Q","usage_types": ["address_book","digital_verification" ] } }}
Event Type: address_verification.started
Description: Triggered when the address verification process begins, indicating that verification is underway.
Fields Overview:
event_type: Specifies the event type (always "address_verification.started").
event_id: Unique identifier for the event instance.
api_version: The API version used.
event_timestamp: Unix timestamp in milliseconds representing when the event occurred.
data: Contains core information for the event.
address_verification: Details about the verification, including the status.
Description: Triggered once the address verification process has been cancelled eg. when a user opts out of OkHi. This payload provides the final status of the verification.
Fields Overview:
event_type: Specifies the event type (always "address_verification.cancelled").
event_id: Unique identifier for the event instance.
api_version: The API version used.
event_timestamp: Unix timestamp in milliseconds representing when the event occurred.
data: Contains core information for the event.
address_verification: Provides details of the verification, including the final status.