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

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

> 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) + "*****MASKED*****";
          }
          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`エンドポイント](/docs/ja-jp/api/management/v2#!/Users/get_users)を使うと、ユーザーのリストを取得できます。このエンドポイントを使用すると、次の操作を実行できます。

* さまざまな基準に基づいて検索する
* 返されるフィールドを選択する
* 返された結果を並べ替える

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

## 要求例

ユーザーを検索するには、[`/api/v2/users`エンドポイント](/docs/ja-jp/api/management/v2#!/Users/get_users)に`GET`要求を送信します。要求には[Management APIのアクセストークン](/docs/ja-jp/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);
  });
  ```

  ```objc Obj-C theme={null}
  #import <Foundation/Foundation.h>

  NSDictionary *headers = @{ @"authorization": @"Bearer {yourMgmtApiAccessToken}" };

  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3"]
                                                         cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                     timeoutInterval:10.0];
  [request setHTTPMethod:@"GET"];
  [request setAllHTTPHeaderFields:headers];

  NSURLSession *session = [NSURLSession sharedSession];
  NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                              completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                  if (error) {
                                                      NSLog(@"%@", error);
                                                  } else {
                                                      NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                      NSLog(@"%@", httpResponse);
                                                  }
                                              }];
  [dataTask resume];
  ```

  ```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
  ```

  ```swift Swift theme={null}
  import Foundation

  let headers = ["authorization": "Bearer {yourMgmtApiAccessToken}"]

  let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/users?q=email%3A%22jane%40exampleco.com%22&search_engine=v3")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "GET"
  request.allHTTPHeaderFields = headers

  let session = URLSession.shared
  let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
    if (error != nil) {
      print(error)
    } else {
      let httpResponse = response as? HTTPURLResponse
      print(httpResponse)
    }
  })

  dataTask.resume()
  ```
</AuthCodeGroup>

成功すると、次のような応答を受け取ります。

```json lines 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": ""
  }
]
```

## クエリの例

以下の例は、<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-jp/glossary?term=management-api" tip="Management API: 顧客が管理タスクを実行できるようにするための製品。" cta="用語集の表示">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}`                                                |
| メールドメインが「xampleco.com」と一致するすべてのユーザーを検索する                                                                                                  | `email.domain:"exampleco.com"`                                             |

## 制限事項

エンドポイントは、クエリに一致するユーザーがさらにいる場合でも、最大50人のユーザーを返します。

50人を超えるユーザーを返す必要がある場合は、`page`パラメータを使用して、より多くの結果ページを表示します。各ページには50人のユーザーが含まれます。たとえば、`&page=2`を指定して51～100人目の結果を表示し、`&page=3`を指定して101～150人目の結果を表示するなどできます。ただし、このエンドポイントは、ページを使用しても、同じ検索条件で合計1000人を超えるユーザーを返すことはありません。

[ユーザー検索エンドポイント](https://auth0.com/docs/api/management/v2/users/get-users)でインデックス作成、クエリ、返却できるユーザーデータには1ユーザーあたり1MBの制限があります。1MBを超えるカスタムメタデータにこれがどのように影響するかについては、「[メタデータフィールド名とデータタイプ](/docs/ja-jp/manage-users/user-accounts/metadata/metadata-fields-data#size-limits-and-storage)」を参照してください。オーバーサイズのユーザープロファイルについては、すべてのユーザー属性を取得するために、[ユーザー取得エンドポイント](https://auth0.com/docs/api/management/v2/users/get-users-by-id)を使用する必要があります。

すべてのユーザーを完全にエクスポートする必要がある場合は、[エクスポートジョブ](/docs/ja-jp/api/management/v2#!/Jobs/post_users_exports)または[ユーザーインポート/エクスポート](/docs/ja-jp/customize/extensions/user-import-export)拡張機能を使用します。

エラー`414 Request-URI Too Large`（要求のURIが長すぎる）が発生した場合は、クエリ文字列がサポートされている長さを超過していることを意味します。その場合には、検索を絞り込みます。

このエンドポイントを次の目的に使用することはお勧め**しません** 。

* 即時一貫性が必要な操作。代わりに、[メールでのユーザー取得エンドポイント](/docs/ja-jp/manage-users/user-search/retrieve-users-with-get-users-by-email-endpoint)または[IDでのユーザー取得エンドポイント](/docs/ja-jp/manage-users/user-search/retrieve-users-with-get-users-by-id-endpoint)を使用してください。
* ユーザーのエクスポート。代わりに、[ユーザーエクスポートエンドポイント](/docs/ja-jp/manage-users/user-migration/bulk-user-exports)を使用してください。
* 認証プロセスの一部としてユーザー検索が必要な操作。代わりに、メールでのユーザー取得エンドポイントまたはIDでのユーザー取得エンドポイントを使用してください。
* メールでの[アカウントリンク](/docs/ja-jp/manage-users/user-accounts/user-account-linking)のユーザー検索。代わりに、メールでのユーザー取得エンドポイントを使用してください。

## もっと詳しく

* [ユーザー検索のクエリ構文](/docs/ja-jp/manage-users/user-search/user-search-query-syntax)
* [検索結果を並べ替える](/docs/ja-jp/manage-users/user-search/sort-search-results)
* [ページ毎に検索結果を表示](/docs/ja-jp/manage-users/user-search/view-search-results-by-page)
* [一括ユーザーエクスポート](/docs/ja-jp/manage-users/user-migration/bulk-user-exports)
* [APIの呼び出しをチェックする](/docs/ja-jp/troubleshoot/authentication-issues/check-api-calls)
