Skip to content
Start here

List all targets

zero_trust.access.infrastructure.targets.list(TargetListParams**kwargs) -> SyncV4PagePaginationArray[TargetListResponse]
GET/accounts/{account_id}/infrastructure/targets

Lists and sorts an account’s targets. Filters are optional and are ANDed together.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
ParametersExpand Collapse
account_id: str

Account identifier

maxLength32
created_after: Optional[Union[str, datetime, null]]

Date and time at which the target was created after (inclusive)

formatdate-time
created_before: Optional[Union[str, datetime, null]]

Date and time at which the target was created before (inclusive)

formatdate-time
direction: Optional[Literal["asc", "desc"]]

The sorting direction.

One of the following:
"asc"
"desc"
hostname: Optional[str]

Hostname of a target

hostname_contains: Optional[str]

Partial match to the hostname of a target

ip_like: Optional[str]

Filters for targets whose IP addresses look like the specified string. Supports * as a wildcard character

ip_v4: Optional[str]

IPv4 address of the target

ip_v6: Optional[str]

IPv6 address of the target

ips: Optional[SequenceNotStr[str]]

Filters for targets that have any of the following IP addresses. Specify ips multiple times in query parameter to build list of candidates.

ipv4_end: Optional[str]

Defines an IPv4 filter range’s ending value (inclusive). Requires ipv4_start to be specified as well.

ipv4_start: Optional[str]

Defines an IPv4 filter range’s starting value (inclusive). Requires ipv4_end to be specified as well.

ipv6_end: Optional[str]

Defines an IPv6 filter range’s ending value (inclusive). Requires ipv6_start to be specified as well.

ipv6_start: Optional[str]

Defines an IPv6 filter range’s starting value (inclusive). Requires ipv6_end to be specified as well.

modified_after: Optional[Union[str, datetime, null]]

Date and time at which the target was modified after (inclusive)

formatdate-time
modified_before: Optional[Union[str, datetime, null]]

Date and time at which the target was modified before (inclusive)

formatdate-time
order: Optional[Literal["hostname", "created_at"]]

The field to sort by.

One of the following:
"hostname"
"created_at"
page: Optional[int]

Current page in the response

formatint32
minimum1
per_page: Optional[int]

Max amount of entries returned per page

formatint32
maximum1000
minimum1
target_ids: Optional[SequenceNotStr[str]]

Filters for targets that have any of the following UUIDs. Specify target_ids multiple times in query parameter to build list of candidates.

virtual_network_id: Optional[str]

Private virtual network identifier of the target

formatuuid
ReturnsExpand Collapse
class TargetListResponse:
id: str

Target identifier

formatuuid
maxLength36
created_at: datetime

Date and time at which the target was created

formatdate-time
hostname: str

A non-unique field that refers to a target

ip: IP

The IPv4/IPv6 address that identifies where to reach a target

ipv4: Optional[IPIPV4]

The target’s IPv4 address

ip_addr: Optional[str]

IP address of the target

virtual_network_id: Optional[str]

(optional) Private virtual network identifier for the target. If omitted, the default virtual network ID will be used.

formatuuid
ipv6: Optional[IPIPV6]

The target’s IPv6 address

ip_addr: Optional[str]

IP address of the target

virtual_network_id: Optional[str]

(optional) Private virtual network identifier for the target. If omitted, the default virtual network ID will be used.

formatuuid
modified_at: datetime

Date and time at which the target was modified

formatdate-time

List all targets

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
page = client.zero_trust.access.infrastructure.targets.list(
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result[0]
print(page.id)
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "created_at": "2019-08-24T14:15:22Z",
      "hostname": "infra-access-target",
      "ip": {
        "ipv4": {
          "ip_addr": "187.26.29.249",
          "virtual_network_id": "c77b744e-acc8-428f-9257-6878c046ed55"
        },
        "ipv6": {
          "ip_addr": "64c0:64e8:f0b4:8dbf:7104:72b0:ec8f:f5e0",
          "virtual_network_id": "c77b744e-acc8-428f-9257-6878c046ed55"
        }
      },
      "modified_at": "2019-08-24T14:15:22Z"
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "created_at": "2019-08-24T14:15:22Z",
      "hostname": "infra-access-target",
      "ip": {
        "ipv4": {
          "ip_addr": "187.26.29.249",
          "virtual_network_id": "c77b744e-acc8-428f-9257-6878c046ed55"
        },
        "ipv6": {
          "ip_addr": "64c0:64e8:f0b4:8dbf:7104:72b0:ec8f:f5e0",
          "virtual_network_id": "c77b744e-acc8-428f-9257-6878c046ed55"
        }
      },
      "modified_at": "2019-08-24T14:15:22Z"
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}