Process Incoming Webhook with Rest API v2

Description

Processes an incoming webhook for a specific entry that is on an Incoming Webhook step.

Authentication

For available methods to authenticate to the API, refer to our REST API v2 Authentication guide.

By default the permissions are checked based on API key/secret values from the step settings as well as associated entry ID and step status to confirm a valid request status. This can be adjusted using the gravityflowincomingwebhook_check_permissions filter.

Using the Endpoint

Path and Method

POST /wp-json/gf/v2/entries/[entry_id]/workflow-hooks

Request Parameters

KeyTypeLocationRequiredDescription
entry_idintegerPathRequiredThe ID of the entry
workflow-api-keystringQueryRequiredAPI key configured in the step
workflow-api-secretstringQueryRequiredAPI secret configured in the step
[custom]Webhook specificBodyOptionalThe specific parameters depend on the field mappings configured for the webhook

Response

Success

Response CodeMessage
200complete

Failure

A failed response will provide a JSON string of the error code and message.

KeyTypeDescription
codestringError code.
messagestringHuman-readable error message.
data[status]integerHTTP response status code

There are several failure scenarios which could be returned depending on request data provided.

Response Code
and data[status]
Error CodeMessageDetails
401 / 403permission_deniedSorry, you are not allowed to do that.User does not have the required permissions for this endpoint.

Usage

PHP Request

<?php

//Replace these variables with values relevant to your site.
$website_url = 'https://example.com/';
$entry_id = 123;
$api_key = string;
$api_secret = string;

$response = wp_remote_post( ' . $website_url . $api_key . $api_secret, array(
    'headers' => array(
        'Content-Type' => 'application/json; charset=utf-8',
    ),
    'body' => $json,
) );

if ( ! is_wp_error( $response ) ) {
    // The request went through successfully, check the response code against
    // what we're expecting
    if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
        // Do something with the response
        // $body = wp_remote_retrieve_body( $response );
        // $headers = wp_remote_retrieve_headers( $response );
    } else {
        // The response code was not what we were expecting, record the message
        $error_message = wp_remote_retrieve_response_message( $response );
    }
} else {
    // There was an error making the request
    $error_message = $response->get_error_message();
}

API Response

complete

Since

This endpoint was added in Gravity Flow Incoming Webhook 1.3.1

Source Code

This endpoint is located in the gravityflowincomingwebhook/includes/class-step-incoming-webhook.php file.