How do I automate the import of puppet env's from a smart proxy in foreman?

Problem: I want to run an API or a script to import puppet env’s instead of going to the GUI dropdown Import-> Import from smart proxy -> Select env -> update
Is there a way to do this from the CLI or an API?

There is hammer proxy import-classes command that uses /api/smart_proxies/:id/import_puppetclasses API endpoint.

What is :id in this case? Because this can be done in Python too.
I tried the API endpoint with :id 84 and it did not work. Or am I missing something?

EDIT: This worked in Python with :id 84
Thanks!
I will try with Hammer CLI to see if its faster cause it has more options

Can I import puppet classes for a specific Environment only? Also there is the fact that I dont see my env or env id if its not imported.
Is there any work around to this?

:id is the id of proxy which you want to import from. There is an endpoint for a specific environment as well, you can view the API documentation on your Foreman instance under /apidoc.html

If the environment does not exist, then maybe creating it and then importing classes into it might work.