Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/network-interconnect/api.md
1# CNI API Reference23See [README.md](README.md) for overview.45## Base67```8https://api.cloudflare.com/client/v49Auth: Authorization: Bearer <token>10```1112## SDK Namespaces1314**Primary (recommended):**15```typescript16client.networkInterconnects.interconnects.*17client.networkInterconnects.cnis.*18client.networkInterconnects.slots.*19```2021**Alternate (deprecated):**22```typescript23client.magicTransit.cfInterconnects.*24```2526Use `networkInterconnects` namespace for all new code.2728## Interconnects2930```http31GET /accounts/{account_id}/cni/interconnects # Query: page, per_page32POST /accounts/{account_id}/cni/interconnects # Query: validate_only=true (optional)33GET /accounts/{account_id}/cni/interconnects/{icon}34GET /accounts/{account_id}/cni/interconnects/{icon}/status35GET /accounts/{account_id}/cni/interconnects/{icon}/loa # Returns PDF36DELETE /accounts/{account_id}/cni/interconnects/{icon}37```3839**Create Body:** `account`, `slot_id`, `type`, `facility`, `speed`, `name`, `description`40**Status Values:** `active` | `healthy` | `unhealthy` | `pending` | `down`4142**Response Example:**43```json44{"result": [{"id": "icon_abc", "name": "prod", "type": "direct", "facility": "EWR1", "speed": "10G", "status": "active"}]}45```4647## CNI Objects (BGP config)4849```http50GET /accounts/{account_id}/cni/cnis51POST /accounts/{account_id}/cni/cnis52GET /accounts/{account_id}/cni/cnis/{cni}53PUT /accounts/{account_id}/cni/cnis/{cni}54DELETE /accounts/{account_id}/cni/cnis/{cni}55```5657Body: `account`, `cust_ip`, `cf_ip`, `bgp_asn`, `bgp_password`, `vlan`5859## Slots6061```http62GET /accounts/{account_id}/cni/slots63GET /accounts/{account_id}/cni/slots/{slot}64```6566Query: `facility`, `occupied`, `speed`6768## Health Checks6970Configure via Magic Transit/WAN tunnel endpoints (CNI v2).7172```typescript73await client.magicTransit.tunnels.update(accountId, tunnelId, {74health_check: { enabled: true, target: '192.0.2.1', rate: 'high', type: 'request' },75});76```7778Rates: `high` | `medium` | `low`. Types: `request` | `reply`. See [Magic Transit docs](https://developers.cloudflare.com/magic-transit/how-to/configure-tunnel-endpoints/#add-tunnels).7980## Settings8182```http83GET /accounts/{account_id}/cni/settings84PUT /accounts/{account_id}/cni/settings85```8687Body: `default_asn`8889## TypeScript SDK9091```typescript92import Cloudflare from 'cloudflare';9394const client = new Cloudflare({ apiToken: process.env.CF_TOKEN });9596// List97await client.networkInterconnects.interconnects.list({ account_id: id });9899// Create with validation100await client.networkInterconnects.interconnects.create({101account_id: id,102account: id,103slot_id: 'slot_abc',104type: 'direct',105facility: 'EWR1',106speed: '10G',107name: 'prod-interconnect',108}, {109query: { validate_only: true }, // Dry-run validation110});111112// Create without validation113await client.networkInterconnects.interconnects.create({114account_id: id,115account: id,116slot_id: 'slot_abc',117type: 'direct',118facility: 'EWR1',119speed: '10G',120name: 'prod-interconnect',121});122123// Status124await client.networkInterconnects.interconnects.get(accountId, iconId);125126// LOA (use fetch)127const res = await fetch(`https://api.cloudflare.com/client/v4/accounts/${id}/cni/interconnects/${iconId}/loa`, {128headers: { Authorization: `Bearer ${token}` },129});130await fs.writeFile('loa.pdf', Buffer.from(await res.arrayBuffer()));131132// CNI object133await client.networkInterconnects.cnis.create({134account_id: id,135account: id,136cust_ip: '192.0.2.1/31',137cf_ip: '192.0.2.0/31',138bgp_asn: 65000,139vlan: 100,140});141142// Slots (filter by facility and speed)143await client.networkInterconnects.slots.list({144account_id: id,145occupied: false,146facility: 'EWR1',147speed: '10G',148});149```150151## Python SDK152153```python154from cloudflare import Cloudflare155156client = Cloudflare(api_token=os.environ["CF_TOKEN"])157158# List, create, status (same pattern as TypeScript)159client.network_interconnects.interconnects.list(account_id=id)160client.network_interconnects.interconnects.create(account_id=id, account=id, slot_id="slot_abc", type="direct", facility="EWR1", speed="10G")161client.network_interconnects.interconnects.get(account_id=id, icon=icon_id)162163# CNI objects and slots164client.network_interconnects.cnis.create(account_id=id, cust_ip="192.0.2.1/31", cf_ip="192.0.2.0/31", bgp_asn=65000)165client.network_interconnects.slots.list(account_id=id, occupied=False)166```167168## cURL169170```bash171# List interconnects172curl "https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/cni/interconnects" \173-H "Authorization: Bearer ${CF_TOKEN}"174175# Create interconnect176curl -X POST "https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/cni/interconnects?validate_only=true" \177-H "Authorization: Bearer ${CF_TOKEN}" -H "Content-Type: application/json" \178-d '{"account": "id", "slot_id": "slot_abc", "type": "direct", "facility": "EWR1", "speed": "10G"}'179180# LOA PDF181curl "https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/cni/interconnects/${ICON_ID}/loa" \182-H "Authorization: Bearer ${CF_TOKEN}" --output loa.pdf183```184185## Not Available via API186187**Missing Capabilities:**188- BGP session state query (use Dashboard or BGP logs)189- Bandwidth utilization metrics (use external monitoring)190- Traffic statistics per interconnect191- Historical uptime/downtime data192- Light level readings (contact account team)193- Maintenance window scheduling (notifications only)194195## Resources196197- [API Docs](https://developers.cloudflare.com/api/resources/network_interconnects/)198- [TypeScript SDK](https://github.com/cloudflare/cloudflare-typescript)199- [Python SDK](https://github.com/cloudflare/cloudflare-python)200