How to programmatically generate user api key

I want to generate API KEY for single user programmatically and I tried something like the following

curl -X POST '<root url>/admin/api/keys' --data 'key%5Bdescription%5D=XXX&key%5Busername%5D=XXX' 

and many other things that I tried.
I got error like this in server log:

Started POST "/admin/api/keys" for 73.225.164.62 at 2020-05-17 06:40:46 +0000
ActionController::RoutingError (No route matches [POST] "/admin/api/keys")

I cannot find any useful document how to do this. Please help.

You can follow my example at Generating User API Keys for testing

Hi

According with the docs it may be possible to create an user api key from an admin user via the rest API
generate api key for a user from an admin user

In previous versions it worked as “admin/users/’+ user_id +’/generate_api_key”. I don’t know why in latest version it changes.

Thank you for your help