コンテンツにスキップ

一般的なAPI呼び出し

以下のセクションには、一般的なAPI呼び出しの例リクエストが含まれています。利用可能なAPIエンドポイントのリストについては、エンドポイントを参照してください。

高度なTCP保護のステータスを取得

この例は、高度なTCP保護の現在のステータス(有効または無効)を取得します。

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

高度なTCP保護を有効にする

この例は、高度なTCP保護を有効にします。

リクエスト
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
}'

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

この例は、高度なTCP保護におけるすべての既存のプレフィックスを取得します。

リクエスト
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": "私のプレフィックス",
"excluded": false
}
],
"success": true,
"errors": [],
"messages": []
}

プレフィックスを追加

この例のPOSTリクエストは、2つのプレフィックスを追加します。2番目のプレフィックスは、高度なTCP保護から最初のプレフィックスのサブセットを除外します。

リクエスト
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": "ゲーム範囲",
"excluded": false
},
{
"prefix": "192.0.2.2/26",
"comment": "特定のゲームの範囲",
"excluded": true
}
]'
レスポンス
{
"result": [
{
"id": "<PREFIX_1_ID>",
"prefix": "192.0.2.0/24",
"excluded": false,
"comment": "ゲーム範囲",
"created_on": "<TIMESTAMP>",
"modified_on": "<TIMESTAMP>"
},
{
"id": "<PREFIX_2_ID>",
"prefix": "192.0.2.2/26",
"excluded": true,
"comment": "特定のゲームの範囲",
"created_on": "<TIMESTAMP>",
"modified_on": "<TIMESTAMP>"
}
],
"success": true,
"errors": [],
"messages": []
}

アロウリスト内のすべてのプレフィックスを取得

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

リクエスト
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": "アロウリスト内の単一IPアドレス",
"enabled": true,
"created_on": "<TIMESTAMP>",
"modified_on": "<TIMESTAMP>"
}
],
"success": true,
"errors": [],
"messages": []
}

アロウリストにプレフィックスを追加

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

リクエスト
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": "パートナー範囲",
"enabled": true
}'
レスポンス
{
"result": {
"id": "<ALLOWLIST_PREFIX_1_ID>",
"prefix": "203.0.113.0/26",
"comment": "パートナー範囲",
"enabled": true,
"created_on": "<TIMESTAMP>",
"modified_on": "<TIMESTAMP>"
},
"success": true,
"errors": [],
"messages": []
}

SYNフラッドルールを作成

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

リクエスト
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ボディ内のフィールドに関する詳細情報を確認してください。

状態外TCPルールを作成

この例のPOSTリクエストは、監視モードで地域スコープの状態外TCPルールを作成し、低いレートおよびバースト感度を設定します。

リクエスト
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ボディ内のフィールドに関する詳細情報を確認してください。

SYNフラッドフィルターを作成

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

リクエスト
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ボディ内のフィールドに関する詳細情報を確認してください。

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

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

リクエスト
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ボディ内のフィールドに関する詳細情報を確認してください。