env.<NAME>.fetch() sends HTTP requests via the interface to its other peers. Each request is recorded in the function’s logs.
Requirements
telnyx-edgev0.5.10 or later@telnyx/edge-runtimev0.16.0 or later- A Network with a WireGuard Interface in
provisionedstatus - 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:- Create a Network with
POST /v2/networks. - Create a WireGuard Interface with
POST /v2/wireguard_interfaces. - Poll
GET /v2/wireguard_interfaces/{id}until its status isprovisioned. Provisioning takes a few minutes, and peers cannot be added while the interface is still provisioning. - Register the target host as a peer with
POST /v2/wireguard_peers. Save theprivate_keyfrom the create response; it is returned only once. - 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.
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.
Send a request through the binding
Pass a URL with the target host’s WireGuard address tofetch():
fetch() accepts a URL string, URL, or Request, plus an optional RequestInit, and returns a Promise<Response>.
Deploy and verify
Ship the function:func-<function-id>.
Call the function’s HTTPS URL, then inspect its logs and deployment history:
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.