
This question has been answered by sottwell. See the first response.
If the user is logged in, MODX supplies a token that can be accessed with the getUserToken class method. See https://rtfm.modx.com/revolution/2.x/developing-in-modx/advanced-development/validating-requests-tokens-and-nonces
You might be interested in AjaxForm, which has a built-in "action key" that acts in much the same way. https://github.com/bezumkin/AjaxForm