Title: WP_REST_Application_Passwords_Controller::update_item
Published: December 9, 2020
Last modified: May 20, 2026

---

# WP_REST_Application_Passwords_Controller::update_item( 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_application_passwords_controller/update_item/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/update_item/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/update_item/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/update_item/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/update_item/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/update_item/?output_format=md#changelog)

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

Updates an application password.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/update_item/?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_application_passwords_controller/update_item/?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_application_passwords_controller/update_item/?output_format=md#source)󠁿

    ```php
    public function update_item( $request ) {
    	$user = $this->get_user( $request );

    	if ( is_wp_error( $user ) ) {
    		return $user;
    	}

    	$item = $this->get_application_password( $request );

    	if ( is_wp_error( $item ) ) {
    		return $item;
    	}

    	$prepared = $this->prepare_item_for_database( $request );

    	if ( is_wp_error( $prepared ) ) {
    		return $prepared;
    	}

    	$saved = WP_Application_Passwords::update_application_password( $user->ID, $item['uuid'], wp_slash( (array) $prepared ) );

    	if ( is_wp_error( $saved ) ) {
    		return $saved;
    	}

    	$fields_update = $this->update_additional_fields_for_object( $item, $request );

    	if ( is_wp_error( $fields_update ) ) {
    		return $fields_update;
    	}

    	$item = WP_Application_Passwords::get_user_application_password( $user->ID, $item['uuid'] );

    	/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php */
    	do_action( 'rest_after_insert_application_password', $item, $request, false );

    	$request->set_param( 'context', 'edit' );
    	return $this->prepare_item_for_response( $item, $request );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php#L318)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php#L318-L356)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/update_item/?output_format=md#hooks)󠁿

 [do_action( ‘rest_after_insert_application_password’, array $item, WP_REST_Request $request, bool $creating )](https://developer.wordpress.org/reference/hooks/rest_after_insert_application_password/)

Fires after a single application password is completely created or updated via the
REST API.

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

| Uses | Description | 
| [WP_REST_Application_Passwords_Controller::get_user()](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/get_user/)`wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php` |

Gets the requested user.

  | 
| [WP_REST_Application_Passwords_Controller::get_application_password()](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/get_application_password/)`wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php` |

Gets the requested application password for a user.

  | 
| [WP_REST_Application_Passwords_Controller::prepare_item_for_database()](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/prepare_item_for_database/)`wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php` |

Prepares an application password for a create or update operation.

  | 
| [WP_REST_Application_Passwords_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_application_passwords_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php` |

Prepares the application password for the REST response.

  | 
| [WP_Application_Passwords::update_application_password()](https://developer.wordpress.org/reference/classes/wp_application_passwords/update_application_password/)`wp-includes/class-wp-application-passwords.php` |

Updates an application password.

  | 
| [WP_Application_Passwords::get_user_application_password()](https://developer.wordpress.org/reference/classes/wp_application_passwords/get_user_application_password/)`wp-includes/class-wp-application-passwords.php` |

Gets a user’s application password with the given UUID.

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

Adds slashes to a string or recursively adds slashes to strings within an array.

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

Calls the callback functions that have been added to an action hook.

  | 
| [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.

  |

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

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

| Version | Description | 
| [5.6.0](https://developer.wordpress.org/reference/since/5.6.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_application_passwords_controller%2Fupdate_item%2F)
before being able to contribute a note or feedback.