API:Protect

Token
To change a page's protection level, a protect token is required. This token is equal to the edit token and the same for all pages, but changes at every login. A protect token can be obtained as follows:

Protecting pages
Pages can be deleted with action=protect.

Parameters

 * title: The page you want to delete.
 * token: The token obtained in the previous request. Take care to urlencode the '+' as '%2B'.
 * protections: A pipe-separated list of protections, formatted as action=group, e.g. edit=autoconfirmed|move=sysop
 * If you want to remove a protection, use all as group, e.g. edit=all|move=sysop
 * If you leave out an action, the associated value won't be changed. I.e. edit=sysop leaves the move protection untouched.
 * expiry: Expiry timestamp in YYYYMMDDHHMMSS format. If set to 'infinite', 'indefinite' or 'never', the protection never expires. Timestamps like 'next Monday 16:04:57' or '9:28 PM tomorrow' are also allowed.
 * reason: The reason for the (un)protection (optional).
 * cascade: If set, pages transcluded in the protected page will also be protected. If the required user level to edit is lower than the required user level to protect (e.g. edit=autoconfirmed), cascading can't be enabled, and this parameter will be silently ignored.
 * This is to prevent people who shouldn't be able to protect pages from protecting them anyway by transcluding them in a page with cascading protection.

Possible errors
All errors are formatted as:


 * code: notitle
 * info: The title parameter must be set
 * code: notoken
 * info: The token parameter must be set
 * code: noprotections
 * info: The protections parameter must be set
 * code: permissiondenied
 * info: You don't have permission to change protection levels
 * On most wikis, protecting pages is 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
 * 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: invalidexpiry
 * info: Invalid expiry time
 * This means the expiry timestamp was invalidly formatted, or is nonexistent (like November 31 or 24:05).
 * code: pastexpiry
 * info: Expiry time is in the past
 * code: unknownerror
 * info: Unknown error
 * This usually means some very rare coincidence occurred. Try the same request again, and you'll get a sensible error message.