Not sure why you’d want to do that on console level because it’s much more complicated than UI.
Anyway… Token.create(user_id: 3, persistent: true, action: 'api', label: 'amazing!', preferences: {"permission"=>["ticket.agent"]}, created_at: Time.now, updated_at: Time.now) will create an API token for User-ID 3 which is persistant and has no expiration date. This token has ticket.agent permission.
Note that permission is an array and thus can hold several permissions if needed.
After creation you’ll want to check the name attribute for the token value.