Get user account ID via API from email/username
Asked by ksa:

Get user account ID via API from email/username


Answers:
author: Diego
body: Hello there, [@ksa](/t5/user/viewprofilepage/user-id/3188598) !

Since GDPR struck,*++many changes were needed++* to make our environment compliant with it. One of those changes includes the *++privacy of user-related information, such as names and emails.++*

Currently, I believe that the *++fastest way to acquire such userIDs++* is by exporting the user list of your instance. This procedure is explained here:
> * ++**[\[Atlassian Cloud\] Export users from a site](https://confluence.atlassian.com/cloud/export-users-from-a-site-833925313.html)**++

If your users are from the *++same domain or from a multitude of domains of which you happen to have access++*, you could verify those in your Organization side. Here is how you verify them:
> * ++**[\[Atlassian Cloud\] Verify a domain for your organization](https://confluence.atlassian.com/cloud/verify-a-domain-for-your-organization-873871234.html)**++

After the domains are verified (if you needed to verify them), we can use our REST API endpoints to get the necessary user info. Here is more information on the tooling to do this:
> * ++**[\[Atlassian Cloud\] Organizations REST API Developer -- Get users in an organization](https://developer.atlassian.com/cloud/admin/organization/rest/#api-orgs-orgId-users-get)**++

I hope this clears the skies for you a little bit, Kasia! Looking forward to your reply.

comments: author: Ryan Hilliker
body: The Organizations REST API Developer - Get users in an organization results in an empty JSON array when using the following API endpoint

<https://api.atlassian.com/admin/v1/orgs/{orgId}/users>


author: Adam Martin
body: I'm seeing the same thing. Anyone figured out what is up?

```
b'{"data":[],"links":{"self":"https://api.atlassian.com/admin/v1/orgs/{orgId}/users"}}'
```

I got a 200 reply, but the data array is empty where there should have been 2800ish users.


author: Adam Martin
body: The org MUST have verified domains for the user pull to work. I switched to an instance that has and then I got the user data.


author: Stephen Sifers
body: Hello All,

To follow-up to resolve the confusion, if you're able to get a 200 and valid response from the endpoint then chances are the Org you're requesting against does not have managed users or a verified domain. More on this may be found at [Organizations REST API - Get users in an organization returns an empty list.](https://community.developer.atlassian.com/t/organizations-rest-api-get-users-in-an-organization-returns-an-empty-list/33657)

To verify your domain and thus manage your accounts, please follow [Verify a domain to manage accounts.](https://support.atlassian.com/user-management/docs/verify-a-domain-to-manage-accounts/)

Regards,  
Stephen Sifers


author: Craig Anderson
body: It would be nice if this was pointed out in the API documentation.


author: Stephen Sifers
body: Hello Kasia, and welcome to the Community!

We appreciate you reaching out in regards to the API changes which return account ID where they used to return username. The information you're referring to can be found within the deprecation notice which is located at [Deprecation notice and migration guide for major changes to Confluence Cloud REST APIs to improve user privacy](https://developer.atlassian.com/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/).

If you want to return to a users User ID then we would suggest using the following endpoints to get a users User ID / Account ID:

1. [GET /wiki/rest/api/user/bulk/migration](https://developer.atlassian.com/cloud/confluence/rest/#api-user-bulk-migration-get)
2. [GET /wiki/rest/api/user](https://developer.atlassian.com/cloud/confluence/rest/#api-user-get)

The first endpoint will allow you to return a user with their account ID. From there, you will pass said account ID over to the second endpoint, which will allow you to return the users User ID then.

I hope this information proves helpful and you're able to access the user information you need via the REST API.

Regards,  
Stephen Sifers

comments: author: David Orazine
body: Stephen,

Those links seem to be old. Do you have updated ones?

Do you suggest I keep a table locally to lookup account IDs?

Thanks,

David


Tags: confluence-cloud