# How to Obtain User ID, Open ID, and Union ID?

This article describes two convenient methods for obtaining user IDs.

## Method 1: Get three types of IDs through the API Explorer

The API Explorer provides the ability to obtain user IDs with one click. You can quickly obtain the IDs of specified users in the enterprise through visual operations.
The privatized environment does not support the API Explorer.

1. Log in to the [API Explorer](https://open.feishu.cn/api-explorer).

2. Find [Send message](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/create)interface in the API list on the left.

3. In the **Query Parameters** tab, set **user_id_type** to **user_id**, **open_id** or **union_id**, then click **Copy open_id**.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/225581d83523e5c7ea776df424cc1984_d069X059iy.png?height=778&lazyload=true&maxWidth=550&width=736)

4. In the popup window, search for or select the specified user, and click **Copy Member ID** to obtain the user's ID.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/1400c94668919d00f55485fe735d3f58_999PKiuq8f.png?height=638&lazyload=true&maxWidth=550&width=806)

## Method 2: Obtain three types of IDs by calling OpenAPI

By calling the [API for obtaining user ID by phone number or email](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/contact-v3/user/batch_get_id), you can obtain the three types of user IDs in batch based on **phone number**/**email**.

### Prerequisites

- Created an application
- Enabled the permission to "Obtain user ID by phone number or email"
- If User ID needs to be obtained, the permission for "Obtain user User ID" also needs to be enabled.
For information on how to enable permissions, refer to [How to Apply for Required Permissions for an Application](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-fix-the-99991672-error#0acf431b).

### Procedure

1. Open the [API Debugging Console](https://open.feishu.cn/api-explorer/cli_a278b89588fb100d?apiName=batch_get_id&from=op_doc_tab&project=contact&resource=user&version=v3). In the left API directory, locate **Address Book** > **Obtain user ID by phone number or email** and click on it to switch the current debug API to "Obtain user ID by phone number or email".

You can use the search box at the top of the API list to quickly locate it.

2. Click on **View Authentication Credentials** in the left pane of the API Debugging Console, and then click on the tenant_access_token to obtain it.

If the previously obtained token has expired, click the refresh icon to obtain a new authentication token.

3. Click on the right parameter list, and set the **user_id_type** parameter in the **query parameter** to the desired ID type.

Supports three types: user_id, open_id, and union_id.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/c7d140d56fe3277e4022674fa44ab9af_zJ7GSKgEWT.png?height=806&lazyload=true&maxWidth=600&width=2154)

4. Switch to the **Request Body** tab, delete the example ID in the request body, and modify it to the phone number or email address you want to query.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/d9707e973dd5018c6705d16c32b8e424_7FoTxONCbi.png?height=794&lazyload=true&maxWidth=600&width=2258)

5. Click **Start Debugging** on the right side. After a successful invocation, the User ID being queried can be obtained in the **Response Body** below.
   The type of user ID returned in the response body is determined by the **user_id_type** parameter set in the query parameter.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/4f639223a607061a5cbf1b0403a00617_kr9cEIYyAR.png?height=1132&lazyload=true&maxWidth=600&width=2114

## Method 3: View User ID in the admin console
Applicable to users with **Tenant Admin** permissions.

1. Log in to the [admin console](https://admin.feishu.cn/), and navigate to **Organization Structure** > **Members and Departments** to view user details. The value of the **User ID** field is the User ID.

![image.png](//sf3-cn.feishucdn.com/obj/open-platform-opendoc/37bb642b45cb82ad3ae9b8df0cf4ef30_A37cApDkPY.png?height=1542&lazyload=true&maxWidth=600&width=2882)
