Title: WP_REST_Abilities_V1_Run_Controller::execute_ability
Published: February 24, 2026

---

# WP_REST_Abilities_V1_Run_Controller::execute_ability( WP_REST_Request $request ): 󠀁[WP_REST_Response](https://developer.wordpress.org/reference/classes/wp_rest_response/)󠁿|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#wp--skip-link--target)

Executes an ability.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#parameters)󠁿

 `$request`[WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/)
required

Full details about the request.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#return)󠁿

 [WP_REST_Response](https://developer.wordpress.org/reference/classes/wp_rest_response/)
|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) Response
object on success, or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
object on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#source)󠁿

    ```php
    public function execute_ability( $request ) {
    	$ability = wp_get_ability( $request['name'] );
    	if ( ! $ability ) {
    		return new WP_Error(
    			'rest_ability_not_found',
    			__( 'Ability not found.' ),
    			array( 'status' => 404 )
    		);
    	}

    	$input  = $this->get_input_from_request( $request );
    	$result = $ability->execute( $input );
    	if ( is_wp_error( $result ) ) {
    		return $result;
    	}

    	return rest_ensure_response( $result );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php#L82)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php#L82-L99)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_ability()](https://developer.wordpress.org/reference/functions/wp_get_ability/)`wp-includes/abilities-api.php` |

Retrieves a registered ability.

  | 
| [WP_REST_Abilities_V1_Run_Controller::get_input_from_request()](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/get_input_from_request/)`wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php` |

Extracts input parameters from the request.

  | 
| [rest_ensure_response()](https://developer.wordpress.org/reference/functions/rest_ensure_response/)`wp-includes/rest-api.php` |

Ensures a REST response is a response object (for consistency).

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 4 more](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_abilities_v1_run_controller/execute_ability/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.9.0](https://developer.wordpress.org/reference/since/6.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_abilities_v1_run_controller%2Fexecute_ability%2F)
before being able to contribute a note or feedback.