Skip to main content
The Diagnostics API allows you to run network diagnostic tools like traceroutes from Cloudflare’s global network to troubleshoot connectivity issues.

Traceroutes

Run traceroute

Run traceroutes from Cloudflare colos to one or more targets.
for await (const traceroute of client.diagnostics.traceroutes.create({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  targets: ['203.0.113.1', 'cloudflare.com'],
  colos: ['SJC', 'LAX'],
  options: {
    packet_type: 'icmp',
    packets_per_ttl: 3,
    max_ttl: 30,
    wait_time: 5
  }
})) {
  console.log(traceroute.target);
  traceroute.colos?.forEach(colo => {
    console.log(colo.colo?.name, colo.traceroute_time_ms);
  });
}
account_id
string
required
Account identifier
targets
string[]
required
Array of target hostnames, IPv4, or IPv6 addresses to traceroute
colos
string[]
Source colo names. If not specified, all colos will be used. China colos are unavailable for traceroutes
options
object
Traceroute configuration options

Response fields

target
string
The target hostname, IPv4, or IPv6 address
colos
object[]
Traceroute results from each colo

Example response

[
  {
    "target": "cloudflare.com",
    "colos": [
      {
        "colo": {
          "name": "SJC",
          "city": "San Jose"
        },
        "traceroute_time_ms": 45.2,
        "hops": [
          {
            "packets_ttl": 1,
            "packets_sent": 3,
            "packets_lost": 0,
            "nodes": [
              {
                "ip": "192.0.2.1",
                "name": "router1.example.com",
                "asn": "13335",
                "packet_count": 3,
                "min_rtt_ms": 1.2,
                "mean_rtt_ms": 1.5,
                "max_rtt_ms": 2.1,
                "std_dev_rtt_ms": 0.4
              }
            ]
          }
        ]
      }
    ]
  }
]

Endpoint health checks

The Diagnostics API also provides endpoint health check functionality through the endpointHealthchecks sub-resource for monitoring specific endpoints.
const healthchecks = await client.diagnostics.endpointHealthchecks.list({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353'
});

Build docs developers (and LLMs) love