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

GET /api/v2/usersエンドポイントを使うと、ユーザーのリストを取得できます。このエンドポイントを使用すると、次の操作を実行できます。

  • さまざまな基準に基づいて検索する

  • 返されるフィールドを選択する

  • 返された結果を並べ替える

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

要求例

ユーザーを検索するには、/api/v2/usersエンドポイントGET要求を送信します。要求にはManagement APIのアクセストークンが含まれている必要があります。検索クエリをqパラメータに渡し、search_engineパラメータをv3に設定します。

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


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

Was this helpful?

/
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);

Was this helpful?

/
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))

}

Was this helpful?

/
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();

Was this helpful?

/
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);
});

Was this helpful?

/
#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];

Was this helpful?

/
$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;
}

Was this helpful?

/
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"))

Was this helpful?

/
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

Was this helpful?

/
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()

Was this helpful?

/

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

[
  {
    "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": ""
  }
]

Was this helpful?

/

クエリの例

以下の例は、Management APIを使用して実行できるクエリの種類を紹介するものです。

ユースケース クエリ
名前に「john」を含むすべてのユーザーを検索する name:*john*
名前が「jane」と一致するすべてのユーザーを検索する name:"jane"
名前が「john」で始まるすべてのユーザーを検索する name:john*
名前が「jane」で始まり「smith」で終わるすべてのユーザーを検索する name:jane*smith
メールアドレスが「john@exampleco.com」と一致するすべてのユーザーを検索する email:"john@exampleco.com"
ORを使用して、メールアドレスが「john@exampleco.com」または「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人を超えるユーザーを返すことはありません。

ユーザー検索エンドポイントでインデックス作成、クエリ、返却できるユーザーデータには1ユーザーあたり1MBの制限があります。1MBを超えるカスタムメタデータにこれがどのように影響するかについては、「メタデータフィールド名とデータタイプ」を参照してください。オーバーサイズのユーザープロファイルについては、すべてのユーザー属性を取得するために、ユーザー取得エンドポイントを使用する必要があります。

すべてのユーザーを完全にエクスポートする必要がある場合は、エクスポートジョブまたはユーザーインポート/エクスポート拡張機能を使用します。

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

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

もっと詳しく