Using action as a key in a query string
I think you're going to have to go up the chain to where the request starts - i.e. the server config. Rewrite all urls matching api?action=... to somewhere else. If you're using nginx it'd be something like

rewrite /api/$arg_action last;