API:Undelete

From MediaWiki.org
Jump to: navigation, search
Language:Project:Language policy English  • Deutsch • 日本語 • 한국어
This page is part of the MediaWiki action API documentation.

MediaWiki action API

v · d · e

Token[edit]

You need to obtain an undelete token through list=deletedrevs before you can restore any revisions. This token is equal to the edit token and the same for all pages, but changes at every login. The preferred method to obtain an undelete token depends on the MediaWiki version:

Get an undelete token

Restoring deleted revisions[edit]

Deleted revisions can be restored with action=undelete.

Parameters[edit]

  • title: The page you want to undelete.
  • token: The token obtained in the previous request. Take care to urlencode the '+' as '%2B'.
  • reason: The reason for the undeletion.
  • tags: Tags to apply to the entry in the deletion log. 1.25+
  • timestamps: A pipe-separated list of timestamps of the revisions to restore. If both timestamps and fileids are empty, all will be restored. Maximum number of values is 50 (500 for bots).
  • fileids: A pipe-separated list of IDs of the file revisions to restore. If both timestamps and fileids are empty, all will be restored. Maximum number of values is 50 (500 for bots). 1.24+
  • watchlist: Specify how the watchlist is affected by this edit, set to one of "watch", "unwatch", "preferences", "nochange": (Default: preferences) 1.16+

Example[edit]

Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=undelete requires POST requests; GET requests will cause an error.

Restore the last 5 revisions of the Main Page

Possible errors[edit]

In addition to the usual stuff:

Code Info
notitle The title parameter must be set
notoken The token parameter must be set
permissiondenied You don't have permission to restore deleted revisions
Note: On most wikis, restoring deleted revisions is restricted to sysops, but other wikis may have stricter rules.
cantundelete Couldn't undelete: the requested revisions may not exist, or may have been undeleted already