Webhook
Webhooks are a powerful feature that allows your application to receive real-time notifications about specific events that occur within the Edge platform. By setting up webhooks, you can automate processes, update records, and trigger workflows in your application as soon as an event happens.
What Are Webhooks?
Webhooks are user-defined HTTP callbacks that are triggered by specific events. When one of those events is triggered, Edge will send an HTTP POST request to the webhook URL you specify. This request contains details about the event, allowing your application to handle the event data in real-time.
Webhooks enable your application to respond to events as they happen, ensuring that your system stays up-to-date without the need for constant polling.
Common Use Cases for Webhooks
Payment Notifications
Get notified when a payment is successful or fails, and update your records accordingly.
Account Updates
Receive updates when an account is created, updated, or deleted.
Transaction Events
Monitor transactions in real-time, enabling immediate action or analysis.
Other Custom Events
Set up webhooks for any custom events that are crucial to your business operations.
Setting Up Webhooks on Edge Dashboard
To start using webhooks, you need to configure them through the Edge Dashboard. Follow the steps below to set up your webhooks:
Log in to the Edge Dashboard
Begin by logging in to your Edge account. Once logged in, navigate to the Dashboard.
Navigate to the Webhooks Section
In the Dashboard, find the Webhooks section. This is typically located under the API Settings or Integrations tab.
Create a New Webhook
- Click on “Create Webhook”: This will open a form where you can specify the details of your webhook.
- Enter the Webhook URL: Provide the URL where you want to receive webhook notifications. Ensure that this URL is accessible from the public internet.
- Select Events to Monitor: Choose the specific events you want to receive notifications for. You can select multiple events based on your application’s needs.
- Set Secret Key (Optional): For added security, you can set a secret key that Edge will include in the header of each webhook request. This allows you to verify that the requests are genuinely coming from Edge.
- Save the Webhook: Once you’ve filled in the details, save the webhook configuration.
Test the Webhook
After setting up the webhook, you should test it to ensure it works as expected.
- Send Test Event: Use the Edge Dashboard to send a test event to your webhook URL. This allows you to verify that your server correctly receives and processes the webhook data.
- Verify Response: Check that your application responds with a
200 OK
status code. This indicates that the webhook was received and processed successfully.
Ensure that your server responds quickly to webhook requests. Webhooks that do not receive a 200 OK
response may be retried multiple times by Edge.
Here’s the guide rewritten using the Steps component to clearly outline the process for handling webhooks in your application:
Handling Webhooks in Your Application
When your application receives a webhook, it’s important to handle it efficiently and securely. Follow these steps to manage incoming webhooks:
Step 1: Parse the Incoming Request
Webhooks are sent as HTTP POST requests with a JSON payload. Your application needs to parse this payload to extract the event data.
Step 2: Verify the Webhook
If you have set a secret key, you should verify the signature included in the webhook request headers. This verification ensures that the request is authentic and actually from Edge.
Step 3: Handle the Event
Based on the event type and data, your application should execute the appropriate logic. For example, if you receive a payment.success
event, you might update the transaction status in your database.
Step 4: Respond to the Webhook
Always respond to the webhook request with a 200 OK
status code once your application has processed the event. This response tells Edge that the webhook was received and handled successfully.
Ensure your webhook endpoint is secure. Consider implementing rate limiting and verifying the signature of incoming requests to prevent unauthorized access.
Was this page helpful?