始める
Cloudflareのプロビジョニング機能にアクセスすることで、Cloudflareアカウントをより簡単に作成および管理できます。以下の手順に従って、アカウント、ユーザー、およびサービスをプロビジョニングするためのAPI呼び出しを開始します。
テナントAPIを使用する前に、アカウントを作成、メールアドレスを確認、および請求情報を追加する必要があります。
Cloudflareとのパートナー契約に署名した後、Cloudflareは特定の権利をあなたのアカウントに追加し、カスタムアカウントをプロビジョニングおよび管理できるようにします。パートナー契約に署名したが、アカウントがまだ有効化されていない場合は、partners@cloudflare.comに連絡してください。
テナントAPIへのリクエストを認証するために、APIキーを取得する必要があります。
Cloudflare APIの使用に関する詳細は、API概要を参照してください。
Each customer or team that uses Cloudflare should have their own account. This ensures proper security and access of resources. Each account acts as a container of zones and other resources. Depending on your needs, you may even provision multiple accounts for a single customer or team.
When you create an account with the Tenant API, your Cloudflare user owns that account from creation, ongoing management, and finally deletion.
To create an account under your tenant using the dashboard:
- Log into the Cloudflare dashboard ↗.
- Go to Tenants > Managed Accounts.
- Select Create Account.
- Enter the Account Name, Account Description, and Tenant Unit.
- Choose the appropriate account subscription.
- Select Add Account.
To create an account using the API, make a POST request to the /accounts endpoint and include the following values:
-
namestring- The name of the account that is displayed in the Cloudflare dashboard.
-
typeenum- Valid values are
standard(default) andenterprise. For self-serve customers, usestandard. For enterprise customers, useenterprise.
- Valid values are
-
unitobject-
Information related to the tenant unit.
-
idstring- (optional) ID of the unit to create this account on. Needs to be specified if user administers multiple tenants. Unit ID is the
unit_tagfrom your tenant details.
- (optional) ID of the unit to create this account on. Needs to be specified if user administers multiple tenants. Unit ID is the
-
All KYC parameters are text fields, have a 120 character limit, and are optional unless enforced by the Tenant.
-
business_namestring- (optional) The name of the business associated with this account.
-
business_addressstring- (optional) The address of the business associated with this account.
-
business_emailstring- (optional) The email of the business associated with this account.
-
business_phonestring- (optional) The phone number of the business associated with this account.
-
external_metadatastring- (optional) External metadata for this account.
curl "https://api.cloudflare.com/client/v4/accounts" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "name": "<ACCOUNT_NAME>", "type": "standard"}'A successful request will return an HTTP status of 200 and the following response body:
{ "result": { "id": "2bab6ace8c72ed3f09b9eca6db1396bb", "name": "<ACCOUNT_NAME>", "type": "standard", "settings": { "enforce_twofactor": false } }, "success": true, "errors": [], "messages": []}A request with a unit ID:
curl "https://api.cloudflare.com/client/v4/accounts" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "name": "<ACCOUNT_NAME>", "type": "standard", "unit": { "id": "1a2b3c4d5e6f7g8h" }}'A request with a unit ID and KYC:
curl "https://api.cloudflare.com/client/v4/accounts" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "name": "<ACCOUNT_NAME>", "type": "standard", "business_name": "Cloudflare", "business_email": "email@business.com", "business_address": "San Francisco", "business_phone": "1234567890", "external_metadata": "{'\''testKey'\'': '\''testValue'\''}", "unit": { "id": "1a2b3c4d5e6f7g8h" }}'アカウントを作成したので、顧客にCloudflareへの直接アクセスを提供するか、顧客が操作できるインターフェースを構築する必要があります。
最初の方法では、顧客がCloudflareのすべての側面を制御できるようになりますが、後者の方法では、顧客のCloudflare体験をあなたが制御するダッシュボードに統合できます。
アカウントにユーザーアクセスを付与すると、Cloudflareはユーザーに招待状を送信し、アカウントにアクセスできるようにします。すでにCloudflareユーザーを持っていない場合、Cloudflareはユーザー作成のプロセスを案内します。作成後、アカウントおよびすでに作成されたゾーンにアクセスできるようになります。
顧客に個別のアカウントへのアクセスを提供したい場合は、チームメンバーを招待するのときと同じです。
APIを使用してCloudflareダッシュボードへのアクセスを付与することもできます。
curl 'https://api.cloudflare.com/client/v4/accounts/<CUSTOMER_ACCOUNT_ID>/members' \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "email": "<CUSTOMER_EMAIL>", "roles": ["<USER_ROLE>"]}'ほとんどの場合、Administratorの役割を持つ新しいユーザーを作成することをお勧めします。この役割は常にID 05784afa30c1afe1440e79d9351c7430を持ちます。
顧客がエンタープライズプランに加入している場合、より広範なユーザー役割にアクセスできます。利用可能な役割の完全なリストを取得するには、APIにGETリクエストを送信してください。
顧客がCloudflareを使用する方法をより制御したい場合や、顧客がすでに知っている既存のダッシュボードを使用させたい場合は、Cloudflare APIを使用してこの体験を構築してください。
これは、顧客の代理でCloudflareにAPI呼び出しを行うことを意味します。APIによってレート制限を受けないようにするために、Cloudflareは各顧客のためにアカウントとユーザーを作成することを推奨します。顧客Aによって行われた変更はユーザーAを通じて、顧客Bによって行われた変更はユーザーBを通じて行われるべきです。
インターフェースを介してアクセスを付与するには、サービスユーザーを作成する必要があります。誰もダッシュボードにログインしないためです。この方法を使用する予定がある場合、CloudflareはこのユーザーとしてAPI呼び出しを行うためにAPIキーを表示できるようにします。
curl "https://api.cloudflare.com/client/v4/users" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "email": "<ID@example.com>"}'{ "result": { "id": "60758bd48392a06215ae817bc35084b6", "email": "<ID@example.com>", "first_name": null, "last_name": null, "username": "17bd2796b374cec14976ac3bced85c05", "telephone": null, "country": null, "created_on": "2019-02-21T23:20:28.645256Z", "modified_on": "2019-02-21T23:20:28.645256Z", "two_factor_authentication": { "enabled": false, "locked": false }, "api_key": "xxx" }, "success": true, "errors": [], "messages": []}顧客アカウントと顧客ユーザー(またはサービスユーザー)を持っているので、ゾーンを作成する必要があります。
これを行うには、/zonesエンドポイントにPOSTリクエストを送信します(ステップ1で受け取った顧客アカウントIDを含めます)。
curl "https://api.cloudflare.com/client/v4/zones" \--header "X-Auth-Email: <EMAIL>" \--header "X-Auth-Key: <API_KEY>" \--header "Content-Type: application/json" \--data '{ "name": "example.com", "account": { "id": "<CUSTOMER_ACCOUNT_ID>" }}'顧客のためにゾーンがプロビジョニングされたので、リセラー契約に基づいて適切なゾーンプランを追加できます。
To create a zone subscription, typically used to upgrade a zone’s plan from PARTNERS_FREE to a paid Zone plan, send a POST request to the /zones/{zone_id}/subscription endpoint and include the following values:
-
rate_planobject- Contains the zone plan corresponding to what customers would order in the dashboard. For a list of available values, refer to Zone subscriptions.
-
component_valuesarray- Additional services depending on your reseller agreement, such as additional
page_rules.
- Additional services depending on your reseller agreement, such as additional
-
frequencystring- How often the subscription is renewed automatically (defaults to
"monthly").
- How often the subscription is renewed automatically (defaults to
curl 'https://api.cloudflare.com/client/v4/zones/{zone_id}/subscription' \--header "Authorization: Bearer <API_TOKEN>" \--header "Content-Type: application/json" \--data '{ "rate_plan": { "id": "<RATE_PLAN>" }, "frequency": "annual"}'curl 'https://api.cloudflare.com/client/v4/zones/{zone_id}/subscription' \--header "Authorization: Bearer <API_TOKEN>" \--header "Content-Type: application/json" \--data '{ "rate_plan": { "id": "PARTNERS_BIZ" }, "component_values": [ { "name": "page_rules", "value": 50 } ]}契約に応じて、他のアドオンサービスを再販することが許可される場合があります。これらはアカウントレベルのサブスクリプションとしてプロビジョニングされます。
To create an account subscription, send a POST request to the /accounts/{account_id}/subscriptions endpoint and include the following values:
-
rate_planobject- Contains the account subscription corresponding to a specific add-on service. For a list of available values, refer to Available subscriptions.
-
component_valuesarray- Additional services depending on your reseller agreement, such as additional endpoints for load balancing or additional seats for Cloudflare Zero Trust. If not included, the subscription includes the default values associated with each purchase.
-
frequencystring- How often the subscription is renewed automatically (defaults to
"monthly").
- How often the subscription is renewed automatically (defaults to
curl 'https://api.cloudflare.com/client/v4/accounts/{account_id}/subscriptions' \--header "Authorization: Bearer <API_TOKEN>" \--header "Content-Type: application/json" \--data '{ "rate_plan": { "id": "<RATE_PLAN_NAME>" }}'必要なサブスクリプションを追加したら、あなたまたは顧客はさまざまなサービスを構成し、アカウントおよびゾーン設定を微調整できます。
構成は、アカウントにアクセスできる人(および正しいユーザー権限を持つ人)によって行うことができます。このプロセスは、他のCloudflareアカウントの構成と異なりません。追加のガイダンスについては、製品ドキュメントを参照してください。