Skip to main content

Overview

Spectrum extends Cloudflare’s DDoS protection and performance to any TCP or UDP-based application. Use the Spectrum API to manage application configurations and view analytics.

Initialize the client

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: 'your-api-token',
});

Apps

Manage Spectrum applications for TCP/UDP proxying.

Create an app

Create a new Spectrum application.
const app = await client.spectrum.apps.create({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
  dns: {},
  protocol: 'tcp/22',
  traffic_type: 'direct',
});
zone_id
string
required
Zone identifier
protocol
string
required
The port configuration at Cloudflare’s edge. May specify a single port (e.g., "tcp/1000") or a range (e.g., "tcp/1000-2000")
dns
object
required
The name and type of DNS record for the Spectrum application
traffic_type
'direct' | 'http' | 'https'
required
Determines how data travels from the edge to your origin:
  • direct - Send traffic directly to origin
  • http - Apply HTTP features
  • https - Apply HTTPS features
origin_dns
object
The name and type of DNS record for the origin
origin_port
number | string
The destination port at the origin. Can be a single port or range
edge_ips
object
The anycast edge IP configuration for this application
argo_smart_routing
boolean
Enable Argo Smart Routing (TCP applications with direct traffic only)
ip_firewall
boolean
Enable IP Access Rules for this application
proxy_protocol
'off' | 'v1' | 'v2' | 'simple'
Enable Proxy Protocol to the origin
tls
'off' | 'flexible' | 'full' | 'strict'
TLS encryption mode between Cloudflare and origin
id
string
App identifier
created_on
string
When the application was created
modified_on
string
When the application was last modified

Update an app

Update an existing Spectrum application.
const app = await client.spectrum.apps.update(
  '023e105f4ecef8ad9ca31a8372d0c353',
  {
    zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
    dns: {},
    protocol: 'tcp/22',
    traffic_type: 'direct',
  }
);

List apps

Retrieve a list of all Spectrum applications in a zone.
const apps = await client.spectrum.apps.list({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
});

Get an app

Get the configuration of a specific Spectrum application.
const app = await client.spectrum.apps.get(
  appId,
  { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }
);

Delete an app

Delete a Spectrum application.
await client.spectrum.apps.delete(
  appId,
  { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }
);

Analytics

View analytics for Spectrum applications.
const analytics = client.spectrum.analytics;
The analytics resource provides methods to retrieve traffic and performance metrics for your Spectrum applications.

Types

DNS

The name and type of DNS record for the Spectrum application.
name
string
The name of the DNS record associated with the application
type
'CNAME' | 'ADDRESS'
The type of DNS record

EdgeIPs

The anycast edge IP configuration. Dynamic configuration:
type
'dynamic'
Dynamically allocated edge IPs using Spectrum anycast IPs
connectivity
'all' | 'ipv4' | 'ipv6'
The IP versions supported for inbound connections
Static configuration:
type
'static'
Statically allocated edge IPs using customer IPs
ips
string[]
The array of customer owned IPs broadcast via anycast

OriginDNS

The name and type of DNS record for the origin.
name
string
The name of the DNS record associated with the origin
type
'' | 'A' | 'AAAA' | 'SRV'
The type of DNS record. Empty string specifies A/AAAA combination
ttl
number
The TTL of DNS resolution in seconds

Build docs developers (and LLMs) love