Skip to content

非公式 / UnofficialCloudflare, Inc. 非提携。アカウント情報は入力しないでください。Not affiliated with Cloudflare, Inc. Do not enter Cloudflare credentials here.Official docsこのサイトについてプライバシー

よく使う API 呼び出し

最終更新 Markdown で表示Agent セットアップ

次のセクションは、よく使う API 呼び出しのリクエスト例です。利用可能な API エンドポイントの一覧は Endpoints を参照してください。

Advanced TCP Protection の状態を取得する

この例は、Advanced TCP Protection の現在の状態(有効または無効)を取得します。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/tcp_protection_status \
--header "Authorization: Bearer <API_TOKEN>"
レスポンス例json
{
  "result": {
    "enabled": false
  },
  "success": true,
  "errors": [],
  "messages": []
}

Advanced TCP Protection を有効にする

この例は、Advanced TCP Protection を有効にします。

リクエストbash
curl --request PATCH \
https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/tcp_protection_status \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
  "enabled": true
}'

既存のプレフィックスを取得する

この例は、Advanced TCP Protection にある既存のプレフィックスをすべて取得します。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/prefixes \
--header "Authorization: Bearer <API_TOKEN>"
{
  "result": [
    {
      "prefix": "203.0.113/24",
      "comment": "My prefix",
      "excluded": false
    }
  ],
  "success": true,
  "errors": [],
  "messages": []
}

プレフィックスを追加する

この例の POST リクエストは、2 つのプレフィックスを追加します。2 つ目のプレフィックスは、1 つ目のプレフィックスの一部を Advanced TCP Protection から除外します。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/prefixes/bulk \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '[
  {
    "prefix": "192.0.2.0/24",
    "comment": "Game ranges",
    "excluded": false
  },
  {
    "prefix": "192.0.2.2/26",
    "comment": "Range for a specific game",
    "excluded": true
  }
]'
{
  "result": [
    {
      "id": "<PREFIX_1_ID>",
      "prefix": "192.0.2.0/24",
      "excluded": false,
      "comment": "Game ranges",
      "created_on": "<TIMESTAMP>",
      "modified_on": "<TIMESTAMP>"
    },
    {
      "id": "<PREFIX_2_ID>",
      "prefix": "192.0.2.2/26",
      "excluded": true,
      "comment": "Range for a specific game",
      "created_on": "<TIMESTAMP>",
      "modified_on": "<TIMESTAMP>"
    }
  ],
  "success": true,
  "errors": [],
  "messages": []
}

許可リスト内のすべてのプレフィックスを取得する

この例は、許可リスト内のすべてのプレフィックスを取得します。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/allowlist \
--header "Authorization: Bearer <API_TOKEN>"
{
  "result": [
    {
      "id": "<ALLOWLIST_PREFIX_ID>",
      "prefix": "192.0.2.127",
      "comment": "Single IP address in allowlist",
      "enabled": true,
      "created_on": "<TIMESTAMP>",
      "modified_on": "<TIMESTAMP>"
    }
  ],
  "success": true,
  "errors": [],
  "messages": []
}

許可リストにプレフィックスを追加する

この例の POST リクエストは、アカウントの許可リストにプレフィックスを追加します。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/allowlist \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
  "prefix": "203.0.113.0/26",
  "comment": "Partner range",
  "enabled": true
}'
{
  "result": {
    "id": "<ALLOWLIST_PREFIX_1_ID>",
    "prefix": "203.0.113.0/26",
    "comment": "Partner range",
    "enabled": true,
    "created_on": "<TIMESTAMP>",
    "modified_on": "<TIMESTAMP>"
  },
  "success": true,
  "errors": [],
  "messages": []
}

SYN flood ルールを作成する

この例の POST リクエストは、監視モードで地域スコープ(西ヨーロッパ)の SYN flood ルールを作成します。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/syn_protection/rules \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
  "scope": "region",
  "name": "WEUR",
  "mode": "monitoring",
  "rate_sensitivity": "medium",
  "burst_sensitivity": "medium"
}'
{
  "result": {
    "id": "<SYN_FLOOD_RULE_ID>",
    "scope": "region",
    "name": "WEUR",
    "mode": "monitoring",
    "rate_sensitivity": "medium",
    "burst_sensitivity": "medium",
    "created_on": "<TIMESTAMP>",
    "modified_on": "<TIMESTAMP>"
  },
  "success": true,
  "errors": [],
  "messages": []
}

JSON 本文のフィールドの詳細は JSON objects を参照してください。

状態外 TCP ルールを作成する

この例の POST リクエストは、監視モードで地域スコープ、かつ rate と burst の感度が低の、状態外 TCP ルールを作成します。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/tcp_flow_protection/rules \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
  "scope": "region",
  "name": "WEUR",
  "mode": "monitoring",
  "rate_sensitivity": "low",
  "burst_sensitivity": "low"
}'
{
  "result": {
    "id": "<OOS_TCP_RULE_ID>",
    "scope": "region",
    "name": "WEUR",
    "mode": "monitoring",
    "rate_sensitivity": "low",
    "burst_sensitivity": "low",
    "created_on": "<TIMESTAMP>",
    "modified_on": "<TIMESTAMP>"
  },
  "success": true,
  "errors": [],
  "messages": []
}

JSON 本文のフィールドの詳細は JSON objects を参照してください。

SYN flood フィルターを作成する

この例の POST リクエストは、SYN flood の フィルター を作成し、特定の宛先 IP アドレス範囲に対して SYN flood 保護を監視モードに設定します。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/syn_protection/filters \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
  "expression": "ip.dst in { 192.0.2.0/24 }",
  "mode": "monitoring"
}'
{
  "result": {
    "id": "<SYN_FLOOD_FILTER_ID>",
    "expression": "ip.dst in { 192.0.2.0/24 }",
    "mode": "monitoring",
    "created_on": "<TIMESTAMP>",
    "modified_on": "<TIMESTAMP>"
  },
  "success": true,
  "errors": [],
  "messages": []
}

JSON 本文のフィールドの詳細は JSON objects を参照してください。

状態外 TCP フィルターを作成する

この例の POST リクエストは、状態外 TCP の フィルター を作成し、特定の宛先 IP アドレスとポートの範囲に対して状態外 TCP 保護を無効にします。

リクエストbash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/advanced_tcp_protection/configs/tcp_flow_protection/filters \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
  "expression": "ip.dst in { 203.0.113.0/24 } and tcp.dstport in { 8000..8081 }",
  "mode": "disabled"
}'
{
  "result": {
    "id": "<OOS_TCP_FILTER_ID>",
    "expression": "ip.dst in { 203.0.113.0/24 } and tcp.dstport in { 8000..8081 }",
    "mode": "disabled",
    "created_on": "<TIMESTAMP>",
    "modified_on": "<TIMESTAMP>"
  },
  "success": true,
  "errors": [],
  "messages": []
}

JSON 本文のフィールドの詳細は JSON objects を参照してください。

役に立ちましたか?