Skip to main content
A network binding joins a function to a WireGuard Interface. When the function deploys, it becomes a peer of that WireGuard Interface, and env.<NAME>.fetch() sends HTTP requests via the interface to its other peers. Each request is recorded in the function’s logs.

Requirements

  • telnyx-edge v0.5.10 or later
  • @telnyx/edge-runtime v0.16.0 or later
  • A Network with a WireGuard Interface in provisioned status
  • A host on the WireGuard Interface running the target HTTP service
The binding’s id is the WireGuard Interface UUID, not the parent Network UUID.

Prepare the target service

Follow the WireGuard Interfaces Quick Start to:
  1. Create a Network with POST /v2/networks.
  2. Create a WireGuard Interface with POST /v2/wireguard_interfaces.
  3. Poll GET /v2/wireguard_interfaces/{id} until its status is provisioned. Provisioning takes a few minutes, and peers cannot be added while the interface is still provisioning.
  4. Register the target host as a peer with POST /v2/wireguard_peers. Save the private_key from the create response; it is returned only once.
  5. Retrieve the peer configuration with GET /v2/wireguard_peers/{id}/config, replace the private-key placeholder, and bring the tunnel up on the target host.
Run the HTTP service on the host’s WireGuard address and a port, for example 172.27.0.2:8787. Allow traffic from the WireGuard subnet in the host firewall.

Declare the binding

Add a [network.<name>] block to func.toml or telnyx.toml. The block name becomes the property on env.
Regenerate the TypeScript declarations after changing the manifest:

Send a request through the binding

Pass a URL with the target host’s WireGuard address to fetch():
fetch() accepts a URL string, URL, or Request, plus an optional RequestInit, and returns a Promise<Response>.

Deploy and verify

Ship the function:
Deploying adds the function to the WireGuard Interface as a peer named func-<function-id>. Call the function’s HTTPS URL, then inspect its logs and deployment history:
Each env.<NAME>.fetch() call appears in the logs with the WireGuard Interface ID:
GET /v2/wireguard_peers?filter[wireguard_interface_id]={id} lists the function peer with the WireGuard Interface’s other peers.