組織を作成する

組織Auth0 DashboardまたはManagement APIを使って作成することができます。

利用可能性はAuth0プランによって異なる

この機能が利用できるかどうかは、ご利用のAuth0プラン(または契約)によります。詳細については、「価格設定」をお読みください。

Auth0ダッシュボード

Auth0 Dashboardを使用して組織を作成するには、以下を行います。

  1. [Auth0 Dashboard]>[Organizations(組織)]に移動します。

  2. [Create Organization(Organizationの作成)]を選択します。

  3. 組織についての基本情報を入力してから、[Add Organization(組織の追加)]を選択します。

    フィールド 説明
    Name(名前) 作成したい組織の名前です。これは、エンドユーザーがログインしたい組織を特定するためにpre-login(ログイン前)プロンプトに入力する名前です。一意の論理識別子です。小文字のアルファベット文字、数字、アンダースコア(_)、ダッシュ(-)を使用することができます。先頭に数字を入力することができます。1~50文字でなければなりません。
    Display Name(表示名) 表示のための、ユーザーに分かりやすい名前です。

  4. [Branding(ブランディング)]セクションで組織をカスタマイズしてから、[Save Changes(変更の保存)]を選択します。

    フィールド 説明
    Organization Logo(組織ロゴ) 表示されるロゴです。推奨される最小解像度は200ピクセル(幅)x 200ピクセル(高さ)です。
    Primary Color(主な色) 主な要素の色。
    Page Background Color(ページ背景色) 背景の色。

  5. [Metadata(メタデータ)]セクションで、組織に必要なメタデータのキー/値のペアを追加してから、[Add(追加)]を選択します。

Mangement API

Management APIを使用して組織を作成するには、以下を行います。

組織作成エンドポイントにPOST呼び出しを行います。placeholder値は必ずテナントからの適切な値に置き換えてください。詳細については、以下のパラメーターの表を参照してください。


curl --request POST \
  --url https://%7ByourAuth0Domain/api/v2/organizations \
  --header 'authorization: Bearer {yourMgmtApiAccessToken}' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{ "name": "ORG_NAME", "display_name": "ORG_DISPLAY_NAME", "branding": [ { "logo_url": "{orgLogo}", "colors": [ { "primary": "{orgPrimaryColor}", "page_background": "{orgPageBackground}" } ] } ], "metadata": [ { "{key}": "{value}", "{key}": "{value}", "{key}": "{value}" } ] }, "enabled_connections": [ { "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}" }, { "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}" } ] }'

Was this helpful?

/
var client = new RestClient("https://%7ByourAuth0Domain/api/v2/organizations");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer {yourMgmtApiAccessToken}");
request.AddHeader("cache-control", "no-cache");
request.AddParameter("application/json", "{ \"name\": \"ORG_NAME\", \"display_name\": \"ORG_DISPLAY_NAME\", \"branding\": [ { \"logo_url\": \"{orgLogo}\", \"colors\": [ { \"primary\": \"{orgPrimaryColor}\", \"page_background\": \"{orgPageBackground}\" } ] } ], \"metadata\": [ { \"{key}\": \"{value}\", \"{key}\": \"{value}\", \"{key}\": \"{value}\" } ] }, \"enabled_connections\": [ { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" }, { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" } ] }", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

Was this helpful?

/
package main

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

func main() {

	url := "https://%7ByourAuth0Domain/api/v2/organizations"

	payload := strings.NewReader("{ \"name\": \"ORG_NAME\", \"display_name\": \"ORG_DISPLAY_NAME\", \"branding\": [ { \"logo_url\": \"{orgLogo}\", \"colors\": [ { \"primary\": \"{orgPrimaryColor}\", \"page_background\": \"{orgPageBackground}\" } ] } ], \"metadata\": [ { \"{key}\": \"{value}\", \"{key}\": \"{value}\", \"{key}\": \"{value}\" } ] }, \"enabled_connections\": [ { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" }, { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" } ] }")

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

	req.Header.Add("content-type", "application/json")
	req.Header.Add("authorization", "Bearer {yourMgmtApiAccessToken}")
	req.Header.Add("cache-control", "no-cache")

	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.post("https://%7ByourAuth0Domain/api/v2/organizations")
  .header("content-type", "application/json")
  .header("authorization", "Bearer {yourMgmtApiAccessToken}")
  .header("cache-control", "no-cache")
  .body("{ \"name\": \"ORG_NAME\", \"display_name\": \"ORG_DISPLAY_NAME\", \"branding\": [ { \"logo_url\": \"{orgLogo}\", \"colors\": [ { \"primary\": \"{orgPrimaryColor}\", \"page_background\": \"{orgPageBackground}\" } ] } ], \"metadata\": [ { \"{key}\": \"{value}\", \"{key}\": \"{value}\", \"{key}\": \"{value}\" } ] }, \"enabled_connections\": [ { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" }, { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" } ] }")
  .asString();

Was this helpful?

/
var axios = require("axios").default;

var options = {
  method: 'POST',
  url: 'https://%7ByourAuth0Domain/api/v2/organizations',
  headers: {
    'content-type': 'application/json',
    authorization: 'Bearer {yourMgmtApiAccessToken}',
    'cache-control': 'no-cache'
  },
  data: '{ "name": "ORG_NAME", "display_name": "ORG_DISPLAY_NAME", "branding": [ { "logo_url": "{orgLogo}", "colors": [ { "primary": "{orgPrimaryColor}", "page_background": "{orgPageBackground}" } ] } ], "metadata": [ { "{key}": "{value}", "{key}": "{value}", "{key}": "{value}" } ] }, "enabled_connections": [ { "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}" }, { "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}" } ] }'
};

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 = @{ @"content-type": @"application/json",
                           @"authorization": @"Bearer {yourMgmtApiAccessToken}",
                           @"cache-control": @"no-cache" };

NSData *postData = [[NSData alloc] initWithData:[@"{ "name": "ORG_NAME", "display_name": "ORG_DISPLAY_NAME", "branding": [ { "logo_url": "{orgLogo}", "colors": [ { "primary": "{orgPrimaryColor}", "page_background": "{orgPageBackground}" } ] } ], "metadata": [ { "{key}": "{value}", "{key}": "{value}", "{key}": "{value}" } ] }, "enabled_connections": [ { "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}" }, { "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}" } ] }" dataUsingEncoding:NSUTF8StringEncoding]];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://%7ByourAuth0Domain/api/v2/organizations"]
                                                       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];

Was this helpful?

/
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://%7ByourAuth0Domain/api/v2/organizations",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{ \"name\": \"ORG_NAME\", \"display_name\": \"ORG_DISPLAY_NAME\", \"branding\": [ { \"logo_url\": \"{orgLogo}\", \"colors\": [ { \"primary\": \"{orgPrimaryColor}\", \"page_background\": \"{orgPageBackground}\" } ] } ], \"metadata\": [ { \"{key}\": \"{value}\", \"{key}\": \"{value}\", \"{key}\": \"{value}\" } ] }, \"enabled_connections\": [ { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" }, { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" } ] }",
  CURLOPT_HTTPHEADER => [
    "authorization: Bearer {yourMgmtApiAccessToken}",
    "cache-control: no-cache",
    "content-type: application/json"
  ],
]);

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

payload = "{ \"name\": \"ORG_NAME\", \"display_name\": \"ORG_DISPLAY_NAME\", \"branding\": [ { \"logo_url\": \"{orgLogo}\", \"colors\": [ { \"primary\": \"{orgPrimaryColor}\", \"page_background\": \"{orgPageBackground}\" } ] } ], \"metadata\": [ { \"{key}\": \"{value}\", \"{key}\": \"{value}\", \"{key}\": \"{value}\" } ] }, \"enabled_connections\": [ { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" }, { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" } ] }"

headers = {
    'content-type': "application/json",
    'authorization': "Bearer {yourMgmtApiAccessToken}",
    'cache-control': "no-cache"
    }

conn.request("POST", "%7ByourAuth0Domain/api/v2/organizations", payload, 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://%7ByourAuth0Domain/api/v2/organizations")

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"] = 'application/json'
request["authorization"] = 'Bearer {yourMgmtApiAccessToken}'
request["cache-control"] = 'no-cache'
request.body = "{ \"name\": \"ORG_NAME\", \"display_name\": \"ORG_DISPLAY_NAME\", \"branding\": [ { \"logo_url\": \"{orgLogo}\", \"colors\": [ { \"primary\": \"{orgPrimaryColor}\", \"page_background\": \"{orgPageBackground}\" } ] } ], \"metadata\": [ { \"{key}\": \"{value}\", \"{key}\": \"{value}\", \"{key}\": \"{value}\" } ] }, \"enabled_connections\": [ { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" }, { \"connection_id\": \"{connectionId}\", \"assign_membership_on_login\": \"{assignMembershipOption}\" } ] }"

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

Was this helpful?

/
import Foundation

let headers = [
  "content-type": "application/json",
  "authorization": "Bearer {yourMgmtApiAccessToken}",
  "cache-control": "no-cache"
]

let postData = NSData(data: "{ "name": "ORG_NAME", "display_name": "ORG_DISPLAY_NAME", "branding": [ { "logo_url": "{orgLogo}", "colors": [ { "primary": "{orgPrimaryColor}", "page_background": "{orgPageBackground}" } ] } ], "metadata": [ { "{key}": "{value}", "{key}": "{value}", "{key}": "{value}" } ] }, "enabled_connections": [ { "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}" }, { "connection_id": "{connectionId}", "assign_membership_on_login": "{assignMembershipOption}" } ] }".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://%7ByourAuth0Domain/api/v2/organizations")! 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()

Was this helpful?

/

説明
MGMT_API_ACCESS_TOKEN read:organizationsスコープのあるManagement APIのアクセストークンです。
ORG_NAME 作成したい組織の名前です。これは、エンドユーザーがログインしたい組織を特定するためにpre-login(ログイン前)プロンプトに入力する名前です。一意の論理識別子です。小文字のアルファベット文字、数字、アンダースコア(_)、ダッシュ(-)を使用することができます。先頭に数字を入力することができます。1~50文字でなければなりません。
ORG_DISPLAY_NAME 任意です。ユーザーに分かりやすい組織名で、ログインフローやメールテンプレートに表示することができます。
ORG_LOGO 任意です。組織ロゴのURLです。
ORG_PRIMARY_COLOR 任意です。プライマリー要素の16進数カラーコードです。
ORG_BACKGROUND_COLOR 任意です。背景の16進数カラーコードです。
KEY/VALUE 任意です。組織のメタデータを表す文字列キーと値のペアです。255文字が上限です。メタデータのペアは10が上限です。
CONNECTION_ID 任意です。特定の組織に有効化したい接続のIDです。有効化された接続は組織のログインプロンプトに表示され、ユーザーはそれを通してアプリケーションにアクセスすることができます。
ASSIGN_MEMBERSHIP_OPTION 任意です。有効化された接続でログインしたユーザーに、指定された組織のメンバーシップを自動的に付与するのかを指定します。trueに設定すると、ユーザーに対して自動的にメンバーシップが付与されます。falseに設定すると、メンバーシップはユーザーに自動的に付与されません。

応答ステータスコード

可能性のある応答ステータスコードは以下のとおりです。

ステータスコード エラーコード メッセージ 原因
201 Organization successfully created.(Organizationが正常に作成されました。)
400 invalid_body Invalid request body.(無効な要求本文です。)メッセージは、原因によって異なります。 要求ペイロードが有効ではありません。
400 invalid_query_string Invalid request query string(無効な要求クエリ文字列です)メッセージは、原因によって異なります。 クエリ文字列が有効ではありません。
401 Invalid token.(無効なトークンです。)
401 Invalid signature received for JSON Web Token validation.(JSON Web Tokenの検証に無効な署名を受け取りました。)
401 Client is not global.(クライアントがグローバルではありません。)
403 insufficient_scope Insufficient scope; expected any of: create:organizations.(スコープが不十分です。create:organizationsが必要です。) 渡されたベアラートークンのスコープでは許可されないフィールドの読み込みや書き出しが試行されました。
409 organization_conflict An organization with the same name already exists.(同じ名前の組織が既に存在します。) 同じ名前の組織が既に存在します。
429 Too many requests.Check the X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers.(要求が多すぎます。X-RateLimit-Limit、X-RateLimit-Remaining、X-RateLimit-Resetヘッダーを確認してください。)