Skip to content
Start here

List all targets

client.ZeroTrust.Access.Infrastructure.Targets.List(ctx, params) (*V4PagePaginationArray[AccessInfrastructureTargetListResponse], error)
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
params AccessInfrastructureTargetListParams
AccountID param.Field[string]

Path param: Account identifier

maxLength32
CreatedAfter param.Field[Time]Optional

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

formatdate-time
CreatedBefore param.Field[Time]Optional

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

formatdate-time
Direction param.Field[AccessInfrastructureTargetListParamsDirection]Optional

Query param: The sorting direction.

const AccessInfrastructureTargetListParamsDirectionAsc AccessInfrastructureTargetListParamsDirection = "asc"
const AccessInfrastructureTargetListParamsDirectionDesc AccessInfrastructureTargetListParamsDirection = "desc"
Hostname param.Field[string]Optional

Query param: Hostname of a target

HostnameContains param.Field[string]Optional

Query param: Partial match to the hostname of a target

IPLike param.Field[string]Optional

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

IPV4 param.Field[string]Optional

Query param: IPv4 address of the target

IPV6 param.Field[string]Optional

Query param: IPv6 address of the target

IPs param.Field[[]string]Optional

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

IPV4End param.Field[string]Optional

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

IPV4Start param.Field[string]Optional

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

IPV6End param.Field[string]Optional

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

IPV6Start param.Field[string]Optional

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

ModifiedAfter param.Field[Time]Optional

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

formatdate-time
ModifiedBefore param.Field[Time]Optional

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

formatdate-time

Query param: The field to sort by.

const AccessInfrastructureTargetListParamsOrderHostname AccessInfrastructureTargetListParamsOrder = "hostname"
const AccessInfrastructureTargetListParamsOrderCreatedAt AccessInfrastructureTargetListParamsOrder = "created_at"
Page param.Field[int64]Optional

Query param: Current page in the response

formatint32
minimum1
PerPage param.Field[int64]Optional

Query param: Max amount of entries returned per page

formatint32
maximum1000
minimum1
TargetIDs param.Field[[]string]Optional

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

VirtualNetworkID param.Field[string]Optional

Query param: Private virtual network identifier of the target

formatuuid
ReturnsExpand Collapse
type AccessInfrastructureTargetListResponse struct{…}
ID string

Target identifier

formatuuid
maxLength36
CreatedAt Time

Date and time at which the target was created

formatdate-time
Hostname string

A non-unique field that refers to a target

IP AccessInfrastructureTargetListResponseIP

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

IPV4 AccessInfrastructureTargetListResponseIPIPV4Optional

The target’s IPv4 address

IPAddr stringOptional

IP address of the target

VirtualNetworkID stringOptional

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

formatuuid
IPV6 AccessInfrastructureTargetListResponseIPIPV6Optional

The target’s IPv6 address

IPAddr stringOptional

IP address of the target

VirtualNetworkID stringOptional

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

formatuuid
ModifiedAt Time

Date and time at which the target was modified

formatdate-time

List all targets

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/option"
  "github.com/stainless-sdks/cloudflare-go/zero_trust"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  page, err := client.ZeroTrust.Access.Infrastructure.Targets.List(context.TODO(), zero_trust.AccessInfrastructureTargetListParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "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
  }
}