The token should always be sent as the last parameter, or at least after the $1text parameter.
Link to this page:
https://wiki.pastlives.space/MediaWiki:Apihelp-edit-param-token