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

# ユーザーのインポート中にルート属性を設定する

> Auth0 Management APIを使用して、ユーザーのインポート中にルート属性を設定する方法について説明します。

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()) {
              processedNode = processedNode.replace(new RegExp(key, "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 [processedChildren, setProcessedChildren] = useState(children);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      unsubscribe = window.autorun(() => {
        let processedChildren = children;
        for (const [key, value] of window.rootStore.variableStore.values.entries()) {
          processedChildren = processedChildren.replace(new RegExp(key, "g"), value);
        }
        setProcessedChildren(processedChildren);
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  return <CodeBlock filename={filename} icon={icon} language={language} lines highlight={highlight}>
      {processedChildren}
    </CodeBlock>;
};

このガイドでは、Auth0の<Tooltip data-tooltip-id="react-containers-DefinitionTooltip-0" href="/docs/ja-JP/ja-jp/glossary?term=management-api" tip="Management API: 顧客が管理タスクを実行できるようにするための製品。" cta="用語集の表示">Management API</Tooltip>を使用して、インポート中にユーザーのルート属性を設定する方法について説明します。これにより、ユーザーをインポートする際に、ルート属性の設定に必要なAPI呼び出しの数を最小限に抑えることができます。インポート可能な属性については、「[正規化ユーザープロファイルの構造](/docs/ja-JP/ja-jp/manage-users/user-accounts/user-profiles/user-profile-structure)」を参照してください。

`POST`呼び出しを[ユーザーインポートのジョブ作成エンドポイント](/docs/ja-JP/ja-jp/api/management/v2#!/Jobs/post_users_imports)に対して行います。`MGMT_API_ACCESS_TOKEN`、`CONNECTION_ID`、`JSON_USER_FILE_PATH`のプレースホルダーをそれぞれManagement APIのアクセストークン、接続ID、ユーザーファイル名に置き換えます。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://{yourDomain}/api/v2/jobs/usersimports' \
    --header 'authorization: Bearer MGMT_API_ACCESS_TOKEN' \
    --header 'content-type: multipart/form-data ' \
    --data '{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{yourDomain}/api/v2/jobs/usersimports");
  var request = new RestRequest(Method.POST);
  request.AddHeader("content-type", "multipart/form-data ");
  request.AddHeader("authorization", "Bearer MGMT_API_ACCESS_TOKEN");
  request.AddParameter("multipart/form-data ", "{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }", ParameterType.RequestBody);
  IRestResponse response = client.Execute(request);
  ```

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

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

  func main() {

  	url := "https://{yourDomain}/api/v2/jobs/usersimports"

  	payload := strings.NewReader("{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }")

  	req, _ := http.NewRequest("POST", url, payload)

  	req.Header.Add("content-type", "multipart/form-data ")
  	req.Header.Add("authorization", "Bearer MGMT_API_ACCESS_TOKEN")

  	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.post("https://{yourDomain}/api/v2/jobs/usersimports")
    .header("content-type", "multipart/form-data ")
    .header("authorization", "Bearer MGMT_API_ACCESS_TOKEN")
    .body("{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }")
    .asString();
  ```

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

  var options = {
    method: 'POST',
    url: 'https://{yourDomain}/api/v2/jobs/usersimports',
    headers: {
      'content-type': 'multipart/form-data ',
      authorization: 'Bearer MGMT_API_ACCESS_TOKEN'
    },
    data: '{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }'
  };

  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 = @{ @"content-type": @"multipart/form-data ",
                             @"authorization": @"Bearer MGMT_API_ACCESS_TOKEN" };

  NSData *postData = [[NSData alloc] initWithData:[@"{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }" dataUsingEncoding:NSUTF8StringEncoding]];

  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/jobs/usersimports"]
                                                         cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                     timeoutInterval:10.0];
  [request setHTTPMethod:@"POST"];
  [request setAllHTTPHeaderFields:headers];
  [request setHTTPBody:postData];

  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/jobs/usersimports",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }",
    CURLOPT_HTTPHEADER => [
      "authorization: Bearer MGMT_API_ACCESS_TOKEN",
      "content-type: multipart/form-data "
    ],
  ]);

  $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("")

  payload = "{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }"

  headers = {
      'content-type': "multipart/form-data ",
      'authorization': "Bearer MGMT_API_ACCESS_TOKEN"
      }

  conn.request("POST", "/{yourDomain}/api/v2/jobs/usersimports", payload, 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/jobs/usersimports")

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

  request = Net::HTTP::Post.new(url)
  request["content-type"] = 'multipart/form-data '
  request["authorization"] = 'Bearer MGMT_API_ACCESS_TOKEN'
  request.body = "{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }"

  response = http.request(request)
  puts response.read_body
  ```

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

  let headers = [
    "content-type": "multipart/form-data ",
    "authorization": "Bearer MGMT_API_ACCESS_TOKEN"
  ]

  let postData = NSData(data: "{ "connection_id": "CONNECTION_ID", "users": "JSON_USER_FILE_PATH" }".data(using: String.Encoding.utf8)!)

  let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/jobs/usersimports")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "POST"
  request.allHTTPHeaderFields = headers
  request.httpBody = postData as Data

  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>

<table class="table">
  <thead>
    <tr>
      <th><strong>値</strong></th>
      <th><strong>説明</strong></th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`MGMT_API_ACCESS_TOKEN`</td>
      <td>`create:users`の<Tooltip id="react-containers-DefinitionTooltip-1">スコープ</Tooltip>を持つ<a href="/docs/ja-JP/ja-jp/api/management/v2/tokens">Management APIアクセストークン</a>です。</td>
    </tr>

    <tr>
      <td>`CONNECTION_ID`</td>
      <td>ユーザーが挿入される接続のIDです。この情報は<a href="/docs/ja-JP/ja-jp/api/management/v2#!/Connections/get_connections">全接続取得エンドポイント</a>を使用して取得できます。</td>
    </tr>

    <tr>
      <td>`JSON_USER_FILE_PATH`</td>
      <td>インポートするユーザーを含むファイルのファイル名です。JSON形式のファイルにユーザーのルート属性を含める必要があります。利用可能な属性のリストについては、「<a href="/docs/ja-JP/ja-jp/users/references/user-profile-structure#attributes">ユーザープロファイル属性</a>」を参照してください。ファイル形式の例については、「<a href="/docs/ja-JP/ja-jp/users/references/bulk-import-database-schema-examples">ユーザーの一括インポートのデータベーススキーマと例</a>」を参照してください。</td>
    </tr>
  </tbody>
</table>

<div id="learn-more">
  ## もっと詳しく
</div>

* [ユーザープロファイルの構造](/docs/ja-JP/ja-jp/manage-users/user-accounts/user-profiles/user-profile-structure)
* [ユーザーのルート属性を更新する](/docs/ja-JP/ja-jp/manage-users/user-accounts/user-profiles/root-attributes/update-root-attributes-for-users)
* [ユーザーのサインアップ時にルート属性を設定する](/docs/ja-JP/ja-jp/manage-users/user-accounts/user-profiles/root-attributes/set-root-attributes-during-user-sign-up)
