Skip to content

Filter resources by tag

Last updated View as MarkdownAgent setup

The GET /accounts/{account_id}/tags/resources endpoint supports tag filtering via the tag query parameter. Multiple tag parameters combine with AND logic. For the full endpoint specification, refer to the Resource Tagging API reference.

Filter types

Key-only filter

Match resources that have a specific tag key, regardless of value.

# All resources with an "environment" tag (any value)
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/resources?tag=environment" \
  -H "Authorization: Bearer $API_TOKEN"

Key-value filter

Match resources where a tag key has a specific value.

# All resources with environment=production
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/resources?tag=environment=production" \
  -H "Authorization: Bearer $API_TOKEN"

Multiple values (OR)

Match resources where a tag key has any of the specified values. Separate values with commas.

# environment=production OR environment=staging
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/resources?tag=environment=production,staging" \
  -H "Authorization: Bearer $API_TOKEN"

Maximum of 10 OR values per filter (error code 1013 if exceeded).

Negate key

Match resources that do not have a specific tag key.

# All resources without an "archived" tag
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/resources?tag=!archived" \
  -H "Authorization: Bearer $API_TOKEN"

Negate key-value

Match resources where a tag key does not have a specific value.

# All resources where region is NOT us-west-1
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/resources?tag=region!=us-west-1" \
  -H "Authorization: Bearer $API_TOKEN"

Combining filters

Multiple tag parameters combine with AND logic. All conditions must match.

# Production resources in US regions, excluding archived
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/resources?tag=environment=production&tag=region=us-west-1,us-east-1&tag=!archived" \
  -H "Authorization: Bearer $API_TOKEN"

Maximum of 20 tag filters per query (error code 1010 if exceeded).

Discover available tags

List all tag keys

curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/keys" \
  -H "Authorization: Bearer $API_TOKEN"

List values for a key

curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/values/environment" \
  -H "Authorization: Bearer $API_TOKEN"

Optionally filter by resource type:

curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/values/environment?type=worker" \
  -H "Authorization: Bearer $API_TOKEN"

Pagination

All list endpoints use cursor-based pagination with a fixed page size of 100 results.

When the response includes a non-null result_info.cursor, pass it as a query parameter to get the next page:

curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/tags/resources?tag=environment=production&cursor=$CURSOR" \
  -H "Authorization: Bearer $API_TOKEN"

When cursor is null, you have reached the last page. Pagination works seamlessly with tag filters.

Was this helpful?