> ## Documentation Index
> Fetch the complete documentation index at: https://translations.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> get_users エンドポイントを使用してユーザー一覧を取得する方法を説明します。

# Get Users エンドポイントを使用してユーザー一覧を取得する

export const AuthCodeGroup = ({children, dropdown}) => {
  const [processedChildren, setProcessedChildren] = useState(children);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      unsubscribe = window.autorun(() => {
        const processChildren = node => {
          if (typeof node === "string") {
            let processedNode = node;
            for (const [key, value] of window.rootStore.variableStore.values.entries()) {
              const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
              processedNode = processedNode.replaceAll(new RegExp(escapedKey, "g"), value);
            }
            return processedNode;
          } else if (Array.isArray(node)) {
            return node.map(processChildren);
          } else if (node && node.props && node.props.children) {
            return {
              ...node,
              props: {
                ...node.props,
                children: processChildren(node.props.children)
              }
            };
          }
          return node;
        };
        setProcessedChildren(processChildren(children));
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  return <CodeGroup dropdown={dropdown}>{processedChildren}</CodeGroup>;
};

export const AuthCodeBlock = ({filename, icon, language, highlight, children}) => {
  const [displayText, setDisplayText] = useState(children);
  const [copyText, setCopyText] = useState(children);
  const wrapperRef = React.useRef(null);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      if (!window.autorun || !window.rootStore) {
        return;
      }
      unsubscribe = window.autorun(() => {
        let processedChildrenForDisplay = children;
        let processedChildrenForCopy = children;
        for (const [key, value] of window.rootStore.variableStore.values.entries()) {
          const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
          let displayValue = value;
          if (key === "{yourClientSecret}" && value !== "{yourClientSecret}") {
            displayValue = value.substring(0, 3) + "*****マスク済み*****";
          }
          processedChildrenForDisplay = processedChildrenForDisplay.replaceAll(new RegExp(escapedKey, "g"), displayValue);
          processedChildrenForCopy = processedChildrenForCopy.replaceAll(new RegExp(escapedKey, "g"), value);
        }
        setDisplayText(processedChildrenForDisplay);
        setCopyText(processedChildrenForCopy);
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  useEffect(() => {
    if (!wrapperRef.current) return;
    const originalWriteText = navigator.clipboard.writeText.bind(navigator.clipboard);
    let isOverriding = false;
    const handleClick = e => {
      const button = e.target.closest('[data-testid="copy-code-button"]');
      if (!button || !wrapperRef.current.contains(button)) return;
      isOverriding = true;
      navigator.clipboard.writeText = text => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
          return originalWriteText(copyText);
        }
        return originalWriteText(text);
      };
      setTimeout(() => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
        }
      }, 100);
    };
    const wrapper = wrapperRef.current;
    wrapper.addEventListener('click', handleClick, true);
    return () => {
      wrapper.removeEventListener('click', handleClick, true);
      if (navigator.clipboard.writeText !== originalWriteText) {
        navigator.clipboard.writeText = originalWriteText;
      }
    };
  }, [copyText]);
  return <div ref={wrapperRef}>
      <CodeBlock filename={filename} icon={icon} language={language} lines highlight={highlight}>
        {displayText}
      </CodeBlock>
    </div>;
};

[`GET /api/v2/users` エンドポイント](https://auth0.com/docs/api/management/v2#!/Users/get_users)を使用すると、ユーザーの一覧を取得できます。このエンドポイントでは、次のことが可能です。

* さまざまな条件で検索する
* 返されるフィールドを選択する
* 返される結果を並べ替える

このエンドポイントは**結果整合性**であるため、既存ユーザーの表示名の変更など、バックオフィス処理に使用することを推奨します。

<div id="request-example">
  ## リクエストの例
</div>

ユーザーを検索するには、[`/api/v2/users` エンドポイント](https://auth0.com/docs/api/management/v2#!/Users/get_users)に `GET` リクエストを送信します。リクエストには、[Management API アクセストークン](/ja/docs/secure/tokens/access-tokens/management-api-access-tokens)を含める必要があります。検索クエリは `q` パラメーターに指定し、`search_engine` パラメーターは `v3` に設定します。

たとえば、メールアドレスが `jane@exampleco.com` に完全に一致するユーザーを検索するには、`q=email:"jane@exampleco.com"` を使用します。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3' \
    --header 'authorization: Bearer {yourMgmtApiAccessToken}'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3");
  var request = new RestRequest(Method.GET);
  request.AddHeader("authorization", "Bearer {yourMgmtApiAccessToken}");
  IRestResponse response = client.Execute(request);
  ```

  ```go Go theme={null}
  package main

  import (
  	"fmt"
  	"net/http"
  	"io/ioutil"
  )

  func main() {

  	url := "https://{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3"

  	req, _ := http.NewRequest("GET", url, nil)

  	req.Header.Add("authorization", "Bearer {yourMgmtApiAccessToken}")

  	res, _ := http.DefaultClient.Do(req)

  	defer res.Body.Close()
  	body, _ := ioutil.ReadAll(res.Body)

  	fmt.Println(res)
  	fmt.Println(string(body))

  }
  ```

  ```java Java theme={null}
  HttpResponse<String> response = Unirest.get("https://{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3")
    .header("authorization", "Bearer {yourMgmtApiAccessToken}")
    .asString();
  ```

  ```javascript Node.JS theme={null}
  var axios = require("axios").default;

  var options = {
    method: 'GET',
    url: 'https://{yourDomain}/api/v2/users',
    params: {q: 'email:"jane@exampleco.com"', search_engine: 'v3'},
    headers: {authorization: 'Bearer {yourMgmtApiAccessToken}'}
  };

  axios.request(options).then(function (response) {
    console.log(response.data);
  }).catch(function (error) {
    console.error(error);
  });
  ```

  ```php PHP theme={null}
  $curl = curl_init();

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
      "authorization: Bearer {yourMgmtApiAccessToken}"
    ],
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);

  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
  ```

  ```python Python theme={null}
  import http.client

  conn = http.client.HTTPSConnection("")

  headers = { 'authorization': "Bearer {yourMgmtApiAccessToken}" }

  conn.request("GET", "/{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3", headers=headers)

  res = conn.getresponse()
  data = res.read()

  print(data.decode("utf-8"))
  ```

  ```ruby Ruby theme={null}
  require 'uri'
  require 'net/http'
  require 'openssl'

  url = URI("https://{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  request = Net::HTTP::Get.new(url)
  request["authorization"] = 'Bearer {yourMgmtApiAccessToken}'

  response = http.request(request)
  puts response.read_body
  ```
</AuthCodeGroup>

成功した場合、次のようなレスポンスが返されます。

```json lines expandable theme={null}
[
  {
    "email": "jane@exampleco.com",
    "email_verified": false,
    "username": "janedoe",
    "phone_number": "+199999999999999",
    "phone_verified": false,
    "user_id": "auth0|5457edea1b8f22891a000004",
    "created_at": "",
    "updated_at": "",
    "identities": [
      {
        "connection": "Initial-Connection",
        "user_id": "5457edea1b8f22891a000004",
        "provider": "auth0",
        "isSocial": false
      }
    ],
    "app_metadata": {},
    "user_metadata": {},
    "picture": "",
    "name": "",
    "nickname": "",
    "multifactor": [
      ""
    ],
    "last_ip": "",
    "last_login": "",
    "logins_count": 0,
    "blocked": false,
    "given_name": "",
    "family_name": ""
  }
]
```

<div id="query-examples">
  ## クエリの例
</div>

以下に、<Tooltip tip="Management API: お客様が管理タスクを実行するための製品。" cta="用語集を表示" href="/ja/docs/glossary?term=Management+API">Management API</Tooltip> で実行できるクエリの例を示します。

| ユースケース                                                                                                                                            | クエリ                                                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| 名前に "john" を含むすべてのユーザーを検索する                                                                                                                       | `name:\*john\*`                                                            |
| 名前が完全に "jane" と一致するすべてのユーザーを検索する                                                                                                                  | `name:"jane"`                                                              |
| 名前が "john" で始まるすべてのユーザーを検索する                                                                                                                      | `name:john*`                                                               |
| 名前が "jane" で始まり "smith" で終わるユーザーを検索する                                                                                                             | `name:jane*smith`                                                          |
| メールアドレスが完全に "[john@exampleco.com](mailto:john@exampleco.com)" と一致するすべてのユーザーを検索する                                                                  | `email:"john@exampleco.com"`                                               |
| `OR` を使用して、メールアドレスが完全に "[john@exampleco.com](mailto:john@exampleco.com)" または "[jane@exampleco.com](mailto:jane@exampleco.com)" と一致するすべてのユーザーを検索する | `email:("john@exampleco.com" OR "jane@exampleco.com")`                     |
| メールアドレスが未検証のユーザーを検索する                                                                                                                             | `email_verified:false OR NOT \_exists_\:email_verified`                    |
| `user_metadata` の `full_name` フィールドの値が "John Smith" であるユーザーを検索する                                                                                  | `user_metadata.full_name:"John Smith"`                                     |
| 特定の接続のユーザーを検索する                                                                                                                                   | `identities.connection:"google-oauth2"`                                    |
| 一度もログインしたことがないすべてのユーザーを検索する                                                                                                                       | `(NOT \_exists_\:logins_count OR logins_count:0)`                          |
| 2018 年より前にログインしたすべてのユーザーを検索する                                                                                                                     | `last_login:[* TO 2017-12-31]`                                             |
| 最終ログインが 2017 年 12 月だったすべてのユーザーを検索する                                                                                                               | `last_login:[2017-11 TO 2017-12]`, `last_login:[2017-12-01 TO 2017-12-31]` |
| ログイン回数が >= 100 かつ \<= 200 のすべてのユーザーを検索する                                                                                                          | `logins_count:[100 TO 200]`                                                |
| ログイン回数が >= 100 のすべてのユーザーを検索する                                                                                                                     | `logins_count:[100 TO *]`                                                  |
| ログイン回数が > 100 かつ \< 200 のすべてのユーザーを検索する                                                                                                            | `logins_count:\{100 TO 200}`                                               |
| メールアドレスのドメインが "exampleco.com" であるすべてのユーザーを検索する                                                                                                    | `email.domain:"exampleco.com"`                                             |

<div id="limitations">
  ## 制限事項
</div>

* クエリに一致するユーザーがさらに存在する場合でも、このエンドポイントが返すユーザーは最大 50 件です。
* 50 件を超えるユーザーを返す必要がある場合は、`page` パラメーターを使用して結果ページを追加で表示します。各ページには 50 人のユーザーが含まれます。たとえば、`&page=2` を指定すると結果 51～100 が表示され、`&page=3` を指定すると結果 101～150 が表示されます。以降も同様です。ただし、ページングを使用しても、このエンドポイントが同じ検索条件で合計 1000 人を超えるユーザーを返すことはありません。
* [ユーザー検索エンドポイント](https://auth0.com/docs/api/management/v2/users/get-users) でインデックス化、クエリ、および返却できるユーザーデータには、ユーザーごとに 1 MB の上限があります。これが 1 MB を超えるカスタムメタデータにどのように影響するかについて詳しくは、[Metadata Field Names and Data Types](/ja/docs/manage-users/user-accounts/metadata/metadata-fields-data#size-limits-and-storage) を参照してください。サイズ上限を超えるユーザープロファイルのすべてのユーザー属性を取得するには、[get user エンドポイント](https://auth0.com/docs/api/management/v2/users/get-users-by-id) を使用する必要があります。
* デフォルトでは、`GET /api/v2/users` エンドポイントは決定的な順序で結果を返すため、同じクエリでは毎回、論理的に同じ順序の結果が返されます。この動作は、`primary_order` クエリパラメーターで制御されます。

  * `primary_order=true` (デフォルト): 同一のクエリでは、結果が常に一貫した順序で返されます。
  * `primary_order=false`: 結果は非決定的な順序で返されるため、複雑なクエリではパフォーマンスが向上する場合があります。
* アプリケーションで検索結果の一貫した順序が不要で、クエリが短くページネーションに依存しない場合は、クエリパフォーマンスを向上させるために `primary_order=false` を設定してください。
* すべてのユーザーの完全なエクスポートが必要な場合は、[export job](https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports) または [User Import / Export](/ja/docs/customize/extensions/user-import-export-extension) 拡張機能を使用してください。
* `414 Request-URI Too Large` エラーが表示された場合は、クエリ文字列がサポートされている長さを超えていることを意味します。この場合は、検索条件を絞り込んでください。

このエンドポイントを次の用途に使用することは**推奨しません**。

* 即時整合性が必要な操作。代わりに、[Get Users by Email エンドポイント](/ja/docs/manage-users/user-search/retrieve-users-with-get-users-by-email-endpoint) または [Get Users by ID エンドポイント](/ja/docs/manage-users/user-search/retrieve-users-with-get-users-by-id-endpoint) を使用してください。
* ユーザーのエクスポート。代わりに、[User Export エンドポイント](/ja/docs/manage-users/user-migration/bulk-user-exports) を使用してください。
* 認証プロセスの一部としてユーザー検索が必要な操作。代わりに、Get Users by Email エンドポイント または Get Users by ID エンドポイント を使用してください。
* メールアドレスによる [Account Linking](/ja/docs/manage-users/user-accounts/user-account-linking) のためのユーザー検索。代わりに、Get Users by Email エンドポイント を使用してください。

<div id="learn-more">
  ## 詳しくはこちら
</div>

* [ユーザー検索クエリの構文](/ja/docs/manage-users/user-search/user-search-query-syntax)
* [検索結果の並べ替え](/ja/docs/manage-users/user-search/sort-search-results)
* [ページ単位での検索結果の表示](/ja/docs/manage-users/user-search/view-search-results-by-page)
* [ユーザーの一括エクスポート](/ja/docs/manage-users/user-migration/bulk-user-exports)
