API:Block

Token
To block or unblock a user, a token is required. This token is equal to the edit token and the same for all blocks, but changes at every login. For MediaWiki 1.24 onwards, the needed token can be obtained via meta=tokens with the type set to. For MediaWiki 1.20–1.23, see API:Tokens (action); for older versions, see API:Info or use the now-removed  parameter.

Blocking users
Users can be blocked with action=block. This must be sent as a POST request. As such, don't forget to append an  to parameters with no value (e.g., , not just  ).

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

Possible errors
In addition to the usual stuff:

Unblocking users
Users can be unblocked with action=unblock.

Parameters
Only one of id, user , or userid must be specified.

Possible errors
In addition to the usual stuff: