REST API Hooks

See …/developer/rest-api.md for endpoint behavior. This page focuses only on PHP action and filter hooks exposed by Alpaca Issue Tracker’s REST response helpers.

Shared Response Hook

alpaistr_rest_response

Type: Action.

Purpose: Fires for every response created through alpaistr_rest_response(), regardless of whether the result is successful or an error.

Parameters

Parameter Type Description
$action_type string The response action identifier used to build dynamic hook names.
$data mixed The response payload.
$status int The HTTP status code.

alpaca_rest_{$action_type}

Type: Action.

Purpose: Fires for successful REST responses created through alpaistr_rest_response() when the HTTP status code is in the 2xx range.

Parameters

Parameter Type Description
$data mixed The response payload.
$status int The HTTP status code.

Notes: The final action name depends on the $action_type string passed into alpaistr_rest_response(). For example, an action type of submit produces alpaca_rest_submit.

alpaca_rest_error_{$action_type}

Type: Action.

Purpose: Fires for non-2xx REST responses created through alpaistr_rest_response().

Parameters

Parameter Type Description
$data mixed The error payload.
$status int The HTTP status code.

Notes: The final action name depends on the $action_type string passed into alpaistr_rest_response(). For example, an action type of submit can produce alpaca_rest_error_submit for an error response.

Response Object Filter

alpaca_rest_response_object

Type: Filter.

Purpose: Replaces or adjusts the final WP_REST_Response object after Alpaca Issue Tracker has created it.

Parameters

Parameter Type Description
$response WP_REST_Response The response object Alpaca is about to return.
$action_type string The response action identifier.
$data mixed The response payload.
$status int The HTTP status code.

REST Root Resolution

alpaca_rest_api_root

Type: Filter.

Purpose: Overrides the REST API root URL Alpaca Issue Tracker injects into localized front-end settings.

Parameters

Parameter Type Description
$default_root string The default REST root generated by rest_url(). This value is passed as the first filter argument and can be replaced.
$context array Context with default_root and parsed request origin data.