API:Rollback

Rollback
Rolling back a page means undoing the last series of edits by one user. In other words, rollback keeps undoing revision after revision until it encounters one made by someone different. This functionality is identical to the one provided by the [rollback ] links in the graphical interface. The rollback revision will be marked as minor. Optionally, both the rollback and the edits being rolled back can be marked as bot, which hides them from Special:Recentchanges by default.

Token

 * Note: Unlike the other tokens, rollback tokens have not been implemented yet in the trunk.

To rollback a page, a rollback token is required. Unlike most other tokens, rollback tokens aren't universal: they're not only different for every login, but also depend on the title of the page and the name of the user whose edits are to be rolled back. A rollback token can be obtained as follows:

Rolling back pages
Pages can be rolled back with action=rollback.

Parameters

 * title: The page you want to rollback.
 * token: The token obtained in the previous request. Take care to urlencode the '+' as '%2B'.
 * user: The author of the last revision.
 * summary: Edit summary (optional). If not set, a default summary will be used.
 * markbot: If set, both the rollback and the revisions being rolled back will be marked as bot edits.

Returned fields
If rolling back wouldn't change the page, no new revision is made. In this case, revid will be equal to old_revid.
 * revid: The revision ID of the rollback.
 * old_revid: The revision ID of the first (most recent) revision that was rolled back.
 * last_revid: The revision ID of the last (oldest) revision that was rolled back.

Possible errors
All errors are formatted as:


 * code: notitle
 * info: The title parameter must be set
 * code: nouser
 * info: The user parameter must be set
 * code: notoken
 * info: The token parameter must be set
 * code: permissiondenied
 * info: You don't have permission to rollback
 * On most wikis, rollback privileges are restricted to sysops, but other wikis may have stricter rules.
 * code: blocked
 * info: You have been blocked from editing
 * code: readonly
 * info: The wiki is in read-only mode
 * In read-only mode, absolutely nothing can be changed.
 * code: badtoken
 * info: Invalid token
 * Note that since rollback tokens depend on the author of the last revision, tokens will be invalidated if someone else edits the page in the meantime.
 * code: invalidtitle
 * info: bad title ``title ''
 * This means title contains invalid characters or is blank. Note that titles like Talk: and User: are also considered blank.
 * code: missingtitle
 * info: ``title '' doesn't exist
 * code: alreadyrolled
 * info: The edit(s) you tried to rollback is/are already rolled back. The current revision ID is ``curid ''.
 * code: onlyauthor
 * info: ``user '' is the only author of the page
 * If there is only one author, there is no previous version to rollback to.