Setting up Your Application Webhook Endpoint

To integrate webhooks into your application, follow these steps to set up an HTTP or HTTPS endpoint function that can accept webhook requests with a POST method:

  • Choose HTTP or HTTPS: Initially, when developing your endpoint function on your local machine, it can use HTTP. However, once it's publicly accessible, your webhook endpoint function must use HTTPS for security reasons.
  • Handle POST Requests: Configure your endpoint function to handle POST requests specifically. Webhook requests are typically sent via the POST method.
  • Expect JSON Payload: Design your endpoint function to expect a JSON payload consisting of an event object. This JSON payload will contain the data associated with the webhook event.
  • Quick Response: Ensure your endpoint function quickly returns a successful status code (200) upon receiving a webhook request.

Example endpoint

This code snippet is a webhook function configured to check that the event type was received, to handle the event, and return a 200 response.

# Django 

from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status


@api_view(["POST"])
def listen_webhook(req):
    """ 
    Listen Webhook
    """
    webhook_payload = req.data

    event = webhook_payload["event"]

    if event == "form.created":
        account_id = webhook_payload["account"]["id"]
        form_id = webhook_payload["form"]["id"]
    elif event == "form.submit":
        account_id = webhook_payload["account"]["id"]
        form_id = webhook_payload["form"]["id"]
        form_submission_id = webhook_payload["form_submission"]["id"]

    # handle your application logics here using the webhook payload data

    response = {}	
    response[“status”] = “success”

    return Response(response, status=status.HTTP_200_OK)
                    
# Laravel

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class ListenWebhookController extends Controller
{
    public function listenWebhook(Request $request)
    {
        $webhookPayload = $request->all();

        $event = $webhookPayload["event"];

        if ($event == "form.created") {
            $accountId = $webhookPayload["account"]["id"];
            $formId = $webhookPayload["form"]["id"];
        } elseif ($event == "form.submit") {
            $accountId = $webhookPayload["account"]["id"];
            $formId = $webhookPayload["form"]["id"];
            $formSubmissionId = $webhookPayload["form_submission"]["id"];
        }

        # handle your application logics here using the webhook payload data

        $response = [];
        $response["status"] = "success";

        return response()->json($response, 200);
    }
}
                    

Popular APIs to Use on Webhook Integration

How can I retrieve all submitted values using a form submission ID?

To retrieve all submitted values using a form submission ID, you can utilize the Builder / Get Single Submitted Entry Details API. This API allows you to fetch detailed information about a specific form submission, providing access to all the submitted values associated with that submission.

How do I retrieve selected field submitted values using a form submission ID?

You can obtain selected field submitted values using a form submission ID and field slugs by utilizing the Form Builder / Get Single Submitted Entry Details Via Field Slug API. This API enables you to specify the form submission ID and the specific field slugs for which you want to retrieve submitted values, providing targeted access to the requested information.