Cloudflare Docs
Rules
Rules
Edit this page
Report an issue with this page
Log into the Cloudflare dashboard
Set theme to dark (⇧+D)

Configure a rule via API

You can configure Cloud Connector rules using the Cloudflare API.

​​ Required permissions

The API token used in API requests to manage Cloud Connector rules must have at least the following permission:

  • Zone > Cloud Connector > Write

​​ Endpoints

To obtain the complete endpoint, append the Cloud Connector endpoints listed below to the Cloudflare API base URL:

https://api.cloudflare.com/client/v4

The {zone_id} argument is the zone ID (a hexadecimal string). You can find this value in the Cloudflare dashboard.

The following table summarizes the available operations.

OperationVerb + Endpoint
List Cloud Connector rulesGET zones/{zone_id}/cloud_connector/rules
Create/update/delete Cloud Connector rulesPUT /zones/{zone_id}/cloud_connector/rules

​​ Example API calls

​​ List of Cloud Connector rules

The following example returns a list of existing Cloud Connector rules:

curl https://api.cloudflare.com/client/v4/zones/{zone_id}/cloud_connector/rules \
--header "Authorization: Bearer <API_TOKEN>"
Example response
{
"result": [
{
"id": "<RULE_1_ID>",
"provider": "aws_s3",
"expression": "http.request.uri.path wildcard \"/images/*\"",
"description": "Connect to S3 bucket containing images",
"enabled": true,
"parameters": {
"host": "examplebucketwithimages.s3.north-eu.amazonaws.com"
}
}
],
"success": true,
"errors": [],
"messages": []
}

​​ Create/update/delete Cloud Connector rules

The following example request will replace all existing Cloud Connector rules with a single rule:

curl --request PUT \
"https://api.cloudflare.com/client/v4/zones/{zone_id}/cloud_connector/rules" \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '[
{
"expression": "http.request.uri.path wildcard \"/images/*\"",
"provider": "aws_s3",
"description": "Connect to S3 bucket containing images",
"parameters": {
"host": "examplebucketwithimages.s3.north-eu.amazonaws.com"
}
}
]'

The required body parameters for each rule are: expression, provider, and parameters.host.

The provider value must be one of the following: aws_s3, azure_storage and gcp_storage.