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 protected with action=protect.

Parameters

 * title: The page you want to protect.
 * 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 GNU timestamp format. If set to 'infinite', 'indefinite, 'never', or not set at all, the protection will never expire. 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
In addition to the usual stuff:


 * 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: 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: cantedit
 * info: You can't protect this page because you can't edit it
 * code: create-titleexists
 * info: Existing titles can't be protected with 'create'
 * code: missingtitle-createonly
 * info: Missing titles can only be protected with 'create'