API:Edit

Token
To edit a page, an edit token is required. This token is the same for all pages, but changes at every login. If you want to protect against edit conflicts (which is wise), you also need to get the timestamp of the last revision. You can obtain these as follows:

Editing pages
Pages can be edited and created with action=edit.

Parameters

 * : Page to edit
 * : Section to edit. Use 0 for the top section, 'new' for a new section
 * : New page (or section) content
 * : Edit token
 * : Edit comment
 * When using, this will be used for the section title
 * : If set, mark the edit as minor
 * : If set, don't mark the edit as minor, even if you have the "Mark all my edits minor by default" preference enabled
 * : If set, mark the edit as bot
 * : Timestamp of the last revision, used to detect edit conflicts. Leave unset to ignore conflicts
 * : If set, suppress errors about the page having been deleted in the meantime and recreate it
 * : If set, throw an error if the page already exists
 * : Add the page to your watchlist
 * : Remove the page from your watchlist, or don't add it even though you have a preference like "Automatically watch all pages I edit" enabled
 * : CAPTCHA ID from the previous request
 * : Answer to the CAPTCHA

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

CAPTCHAs and extension errors
If an edit requires a CAPTCHA, you'll get something like: In most cases, you won't get a math CAPTCHA, but a URL to an image (in the  field). When you've solved the CAPTCHA, retry the request (in this case with ).

Other extensions that use the APIEditBeforeSave hook may return errors using either the format described above or in the usual error format.

Possible errors
In addition to the usual stuff:
 * code: notitle
 * info: The title parameter must be set
 * code: notext
 * info: The text parameter must be set
 * code: notoken
 * info: The token parameter must be set
 * code: invalidsection
 * info: The section parameter must be set to an integer or 'new'