API:Delete

From MediaWiki.org
Jump to: navigation, search

Other languages:
български • ‎Deutsch • ‎English • ‎español • ‎日本語 • ‎한국어 • ‎polski • ‎português do Brasil • ‎русский • ‎sicilianu • ‎سنڌي • ‎Türkçe • ‎中文
Tools clipart.png This page is part of the MediaWiki action API documentation.
MediaWiki APIsAPI:Main page

MediaWiki action API

v · d · e

Token[edit]

To delete a page, a CSRF token is required. The CSRF token is the same for all pages, but changes at every login. CSRF tokens can be obtained via action=query&meta=tokens with type=csrf (MW 1.24+). For older versions, you can use API:Tokens (action)API:Tokens (action) or API:InfoAPI:Info to get an edit token.

Deleting pages[edit]

Pages can be deleted with action=delete. In addition to the delete right, other rights may be required, depending on the location and type of page. Deleting a user's .css page, for example, also requires the editusercss right.

Parameters[edit]

One of title or pageid must be set.

  • title: The page you want to delete.
  • pageid: The page id of the page you want to delete. 1.14+
  • token: The CSRF token obtained as per the Tokens section, above. Take care to urlencode the trailing +\ as %2B%5C.
  • reason: The reason for the deletion (optional). If not provided, an automatically generated reason will be used.
  • tags: Change tags to apply to the entry in the deletion log. 1.27+
  • watch: Add the page to your watchlist. 1.13+ (deprecated in 1.17)
  • unwatch: Remove the page from your watchlist. 1.13+ (deprecated in 1.17)
  • watchlist: Add the page to your watchlist. Possible values: watch, unwatch, preferences, nochange. (Default: preferences)
  • oldimage: The name of the old image to delete as provided by action=query&prop=imageinfo&iiprop=archivename. 1.13+

Example[edit]

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

Deleting the Main Page with an auto-generated reason

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 delete pages
Note: On most wikis, deleting pages is restricted to sysops, but other wikis may have stricter rules.
cantdelete Couldn't delete "title". Maybe it was deleted already by someone else

action=delete

(main | delete)
  • This module requires read rights.
  • This module requires write rights.
  • This module only accepts POST requests.
  • Source: MediaWiki
  • License: GPL-2.0+

Delete a page.

Parameters:
title

Title of the page to delete. Cannot be used together with pageid.

pageid

Page ID of the page to delete. Cannot be used together with title.

Type: integer
reason

Reason for the deletion. If not set, an automatically generated reason will be used.

tags

Change tags to apply to the entry in the deletion log.

Values (separate with | or alternative):
watch
Deprecated.

Add the page to the current user's watchlist.

Type: boolean (details)
watchlist

Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.

One of the following values: watch, unwatch, preferences, nochange
Default: preferences
unwatch
Deprecated.

Remove the page from the current user's watchlist.

Type: boolean (details)
oldimage

The name of the old image to delete as provided by action=query&prop=imageinfo&iiprop=archivename.

token

A "csrf" token retrieved from action=query&meta=tokens

This parameter is required.