Send To Step with Rest API V2

Description

This endpoint allows you to send the specified entry to a different step in it’s workflow.

Authentication

See REST API v2 Authentication.

This endpoint requires the gravityflow_admin_actions capability. This can be adjusted using gravityflow_rest_api_capability_send_step filter.

Using the Endpoint

Path and Method

POST /gf/v2/entries/[entry_id]/workflow/steps/[step_id]/send

The path must include the specific entry ID and target step ID that you wish the entry to be sent to.

Request Parameters

There are no required or optional properties for this endpoint.

Response

Success

A successful response will contain a JSON Workflow Status object that provides the workflow status and the current active step (if appropriate).

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_deniedYou are not allowed to start steps.User does not have the required permissions for this endpoint.
404entry_not_foundInvalid entry id. Entry could not be found.Could not find an entry with the specified entry_id.
404step_not_foundInvalid step id. Step could not be found.Could not find a step with the specified step_id.
422invalid_stepStep does not belong to the same form as the entry.Step does not belong to the same form as the entry.
422invalid_stepYou cannot send the workflow to a step that is already the current step.The step_id provided is the same as the entry is currently on. Use the restart endpoint if desired.

Usage

PHP Request

//Update these variables
$entry_id = '1273';
$step_id  = '127';
$domain   = 'https://develop.local';
$auth_value = 'Basic replace-me-with-basic-auth-based-on-user-application-password';

// {@see https://codex.wordpress.org/HTTP_API}
$response = wp_remote_get( $domain . '/wp-json/gravityflow/v2/entries/' . $entry_id . '/workflow/steps/' . $step_id . '/send', array(
    'headers' => array(
        'Authorization' => $auth_value,
    ),
) );

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

See the examples in Workflow Status object.

Since

This endpoint was added in Gravity Flow 3.0.

Source Code

This endpoint is located in the gravityflow/includes/rest-api/v2/ folder with most of the route code in the class-controller-steps.php file.