> ## 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.

> Auth0 Dashboard と Management API を使用して Organizations を取得する方法を説明します。

# Organizations を取得する

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

[組織](/docs/ja-jp/manage-users/organizations/organizations-overview)をプログラムから操作する場合、すべての組織の一覧を取得したり、名前または ID を指定して個別の組織を取得したりする必要があることがあります。

<Warning>
  Management API へのアクセスには、confidential なクライアントのみを使用してください。この API の利用には、[Auth0 Management API のレート制限](/docs/ja-jp/troubleshoot/customer-support/operational-policies/rate-limit-policy/management-api-endpoint-rate-limits)が適用されます。
</Warning>

<div id="retrieve-tenant-organizations">
  ## テナントの組織を取得する
</div>

<Tooltip tip="Management API: お客様が管理タスクを実行するためのプロダクトです。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=Management+API">Management API</Tooltip> を使用して、テナントのすべての組織を取得できます。

<Warning>
  1000 件を超える結果を取得するには、checkpoint ページネーションを使用する必要があります。詳細については、API Explorer の [Get Organizations エンドポイント](https://auth0.com/docs/api/management/v2#!/Organizations/get_organizations) を参照してください。
</Warning>

`Get Organizations` エンドポイント に `GET` リクエストを送信します。`MGMT_API_ACCESS_TOKEN` プレースホルダーの値は、必ずご利用の Management API <Tooltip tip="アクセストークン: API へのアクセスに使用される認可資格情報で、opaque 文字列または JWT の形式です。" cta="用語集を見る" href="/docs/ja-jp/glossary?term=Access+Token">アクセストークン</Tooltip> に置き換えてください。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://{yourDomain}/api/v2/organizations' \
    --header 'authorization: Bearer MGMT_API_ACCESS_TOKEN'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{yourDomain}/api/v2/organizations");
  var request = new RestRequest(Method.GET);
  request.AddHeader("authorization", "Bearer MGMT_API_ACCESS_TOKEN");
  IRestResponse response = client.Execute(request);
  ```

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

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

  func main() {

  	url := "https://{yourDomain}/api/v2/organizations"

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

  	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.get("https://{yourDomain}/api/v2/organizations")
    .header("authorization", "Bearer MGMT_API_ACCESS_TOKEN")
    .asString();
  ```

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

  var options = {
    method: 'GET',
    url: 'https://{yourDomain}/api/v2/organizations',
    headers: {authorization: 'Bearer MGMT_API_ACCESS_TOKEN'}
  };

  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/organizations",
    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 MGMT_API_ACCESS_TOKEN"
    ],
  ]);

  $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 MGMT_API_ACCESS_TOKEN" }

  conn.request("GET", "/{yourDomain}/api/v2/organizations", 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/organizations")

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

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

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

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  **Auth0ドメインを確認する**

  Auth0ドメインは、テナント名にリージョンのサブドメイン (テナントが US リージョンにあり、2020 年 6 月以前に作成されている場合を除く) を付け、その後に `.auth0.com` を付与したものです。たとえば、テナント名が `travel0` の場合、Auth0ドメイン名は `travel0.us.auth0.com` になります。 (テナントが US にあり、2020 年 6 月以前に作成されている場合、ドメイン名は `https://travel0.auth0.com` になります。)

  カスタムドメインを使用している場合は、そのカスタムドメイン名を指定してください。
</Callout>

| 値                       | 説明                                                                                                                              |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `MGMT_API_ACCESS_TOKEN` | スコープ `read:organizations` を持つ [Management API のアクセストークン](/docs/ja-jp/secure/tokens/access-tokens/management-api-access-tokens)。 |

<div id="response-status-codes">
  ### レスポンスのステータスコード
</div>

想定されるレスポンスのステータスコードは次のとおりです。

| ステータスコード | エラーコード                 | メッセージ                                                                                | 原因                                                         |
| -------- | ---------------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------- |
| `200`    |                        | 組織の取得に成功しました。                                                                        |                                                            |
| `400`    | `invalid_paging`       | リクエストしたページが、許可されている最大 1000 レコードを超えています。                                              | API は最大 1000 レコードまでしか返さないように制限されています。                      |
| `400`    | `invalid_query_string` | リクエストのクエリ文字列が無効です。メッセージは原因によって異なります。                                                 | クエリ文字列が無効です。                                               |
| `401`    |                        | 無効なトークンです。                                                                           |                                                            |
| `401`    |                        | JSON Web トークンのバリデーションで無効な署名を受信しました。                                                  |                                                            |
| `401`    |                        | クライアントはグローバルではありません。                                                                 |                                                            |
| `403`    | `insufficient_scope`   | スコープが不足しています。必要なスコープのいずれか: `read:organizations`。                                     | 提供された bearer token のスコープでは許可されていないフィールドの読み取りまたは書き込みを試みました。 |
| `429`    |                        | リクエストが多すぎます。X-RateLimit-Limit、X-RateLimit-Remaining、X-RateLimit-Reset ヘッダーを確認してください。 |                                                            |

<div id="retrieve-organization-by-id">
  ## IDで組織を取得する
</div>

Management API を使用して、ID で組織を取得できます。

`Get Organization` エンドポイントに `GET` リクエストを送信します。`ORG_ID` と `MGMT_API_ACCESS_TOKEN` のプレースホルダー値は、それぞれ組織の ID と Management API のアクセストークン に必ず置き換えてください。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://{yourDomain}/api/v2/organizations/ORG_ID' \
    --header 'authorization: Bearer MGMT_API_ACCESS_TOKEN'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{yourDomain}/api/v2/organizations/ORG_ID");
  var request = new RestRequest(Method.GET);
  request.AddHeader("authorization", "Bearer MGMT_API_ACCESS_TOKEN");
  IRestResponse response = client.Execute(request);
  ```

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

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

  func main() {

  	url := "https://{yourDomain}/api/v2/organizations/ORG_ID"

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

  	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.get("https://{yourDomain}/api/v2/organizations/ORG_ID")
    .header("authorization", "Bearer MGMT_API_ACCESS_TOKEN")
    .asString();
  ```

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

  var options = {
    method: 'GET',
    url: 'https://{yourDomain}/api/v2/organizations/ORG_ID',
    headers: {authorization: 'Bearer MGMT_API_ACCESS_TOKEN'}
  };

  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/organizations/ORG_ID",
    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 MGMT_API_ACCESS_TOKEN"
    ],
  ]);

  $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 MGMT_API_ACCESS_TOKEN" }

  conn.request("GET", "/{yourDomain}/api/v2/organizations/ORG_ID", 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/organizations/ORG_ID")

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

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

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

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  **Auth0 ドメイン を確認する**

  Auth0 ドメイン は、テナント名、リージョンのサブドメイン (テナントが US リージョンにあり、2020 年 6 月より前に作成された場合を除く) 、および `.auth0.com` を組み合わせたものです。たとえば、テナント名が `travel0` の場合、Auth0 ドメイン 名は `travel0.us.auth0.com` になります。 (テナントが US にあり、2020 年 6 月より前に作成されている場合、domain 名は `https://travel0.auth0.com` になります。)

  カスタムドメインを使用している場合は、カスタムドメイン名を指定してください。
</Callout>

| 値                       | 説明                                                                                                                              |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `ORG_ID`                | 取得する組織 の ID。                                                                                                                    |
| `MGMT_API_ACCESS_TOKEN` | スコープ `read:organizations` を持つ [Management API のアクセストークン](/docs/ja-jp/secure/tokens/access-tokens/management-api-access-tokens)。 |

<div id="response-status-codes">
  ### レスポンスのステータスコード
</div>

考えられるレスポンスのステータスコードは次のとおりです。

| Status code | Error code             | Message                                                                              | Cause                                                 |
| ----------- | ---------------------- | ------------------------------------------------------------------------------------ | ----------------------------------------------------- |
| `200`       |                        | 組織の取得に成功しました。                                                                        |                                                       |
| `400`       | `invalid_query_string` | リクエストのクエリ文字列が無効です。メッセージは原因によって異なります。                                                 | クエリ文字列が無効です。                                          |
| `401`       |                        | トークンが無効です。                                                                           |                                                       |
| `401`       |                        | JSON Web トークンのバリデーションで受信した署名が無効です。                                                   |                                                       |
| `401`       |                        | クライアントはグローバルではありません。                                                                 |                                                       |
| `403`       | `insufficient_scope`   | スコープが不足しています。次のいずれかが必要です: `read:organizations`。                                      | 指定されたベアラー トークンのスコープでは許可されていないフィールドの読み取りまたは書き込みを試みました。 |
| `429`       |                        | リクエストが多すぎます。X-RateLimit-Limit、X-RateLimit-Remaining、X-RateLimit-Reset ヘッダーを確認してください。 |                                                       |

<div id="retrieve-organization-by-name">
  ## 名前で組織を取得
</div>

Management API を使用すると、名前を指定して組織を取得できます。

`Get Organization by Name` エンドポイントに `GET` リクエストを送信します。`ORG_NAME` と `MGMT_API_ACCESS_TOKEN` のプレースホルダー値は、それぞれ組織名と Management API のアクセストークン に置き換えてください。

<AuthCodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://{yourDomain}/api/v2/organizations/name/ORG_NAME' \
    --header 'authorization: Bearer MGMT_API_ACCESS_TOKEN'
  ```

  ```csharp C# theme={null}
  var client = new RestClient("https://{yourDomain}/api/v2/organizations/name/ORG_NAME");
  var request = new RestRequest(Method.GET);
  request.AddHeader("authorization", "Bearer MGMT_API_ACCESS_TOKEN");
  IRestResponse response = client.Execute(request);
  ```

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

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

  func main() {

  	url := "https://{yourDomain}/api/v2/organizations/name/ORG_NAME"

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

  	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.get("https://{yourDomain}/api/v2/organizations/name/ORG_NAME")
    .header("authorization", "Bearer MGMT_API_ACCESS_TOKEN")
    .asString();
  ```

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

  var options = {
    method: 'GET',
    url: 'https://{yourDomain}/api/v2/organizations/name/ORG_NAME',
    headers: {authorization: 'Bearer MGMT_API_ACCESS_TOKEN'}
  };

  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/organizations/name/ORG_NAME",
    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 MGMT_API_ACCESS_TOKEN"
    ],
  ]);

  $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 MGMT_API_ACCESS_TOKEN" }

  conn.request("GET", "/{yourDomain}/api/v2/organizations/name/ORG_NAME", 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/organizations/name/ORG_NAME")

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

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

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

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  **Auth0 ドメインを確認する**

  Auth0 ドメインは、テナント名、リージョンのサブドメイン (テナントが US リージョンにあり、2020 年 6 月より前に作成されている場合を除く) 、および `.auth0.com` を組み合わせたものです。たとえば、テナント名が `travel0` の場合、Auth0 ドメイン名は `travel0.us.auth0.com` になります。 (テナントが US にあり、2020 年 6 月より前に作成されている場合、ドメイン名は `https://travel0.auth0.com` になります。)

  カスタムドメインを使用している場合は、そのカスタムドメイン名を指定してください。
</Callout>

| 値                       | 説明                                                                                                                              |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `ORG_ NAME`             | 取得する組織の名前。最大 50 文字です。                                                                                                           |
| `MGMT_API_ACCESS_TOKEN` | スコープ `read:organizations` を持つ [Management API のアクセストークン](/docs/ja-jp/secure/tokens/access-tokens/management-api-access-tokens)。 |

### レスポンスステータスコード

返される可能性のあるレスポンスステータスコードは次のとおりです。

| ステータスコード | エラーコード                 | メッセージ                                                                                | 原因                                                         |
| -------- | ---------------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------- |
| `200`    |                        | Organizations を正常に取得しました。                                                            |                                                            |
| `400`    | `invalid_query_string` | リクエストのクエリ文字列が無効です。メッセージは原因に応じて異なります。                                                 | クエリ文字列が無効です。                                               |
| `401`    |                        | 無効なトークンです。                                                                           |                                                            |
| `401`    |                        | JSON Web トークンのバリデーションで無効な署名が検出されました。                                                 |                                                            |
| `401`    |                        | クライアントはグローバルではありません。                                                                 |                                                            |
| `403`    | `insufficient_scope`   | スコープが不足しています。次のいずれかが必要です: `read:organizations`。                                      | 指定された bearer token のスコープでは許可されていないフィールドの読み取りまたは書き込みを試みました。 |
| `429`    |                        | リクエストが多すぎます。X-RateLimit-Limit、X-RateLimit-Remaining、X-RateLimit-Reset ヘッダーを確認してください。 |                                                            |
