I tried with https://<instance>/rest/api/2/user/assignable/search?project=<project key>
it is giving me all the assigned users. But I want to get all the active and inactive users from all the projects the user has access to.
If you have managed accounts on your Jira Cloud, you don't need to use the API to get the full list of users of the site.
Go to Settings->User Management->Export users. From there you can follow the options to get a full CSV with all the users of your instance.
For more information check this link on the Atlassian KB https://support.atlassian.com/organization-administration/docs/export-users-from-a-site/
In case you'd like to export only the users for a specific project, I would suggest doing a script on your preferred programing lenguage and retrieve the paginated data using the REST API and then ordering it as you like.
Renzo from Servicerocket.