Skip to main content
These resources are in the Node.js SDK only. In Go, Python, and Rust, call the same routes with the raw request method.

Servers

Link a machine you run to Pxxl, watch it, and run actions on it. See bring your own server for what linking does and which plans include it. pxxl.servers uses the client’s teamId by default. list() and create() also accept their own teamId.
An action is restart, stop, start, logs, prune, or update. Pass app (a container or project name) to act on one app instead of the whole server. runAction() queues the action and checks its status every 1.5 seconds until it finishes or timeoutMs passes. The default timeout is 120 seconds. It returns the latest status either way, so check status on the result. runOp() runs read operations by default. Pass change: true for operations that change the server. It waits for the result unless you pass wait: false.

Network checks and plan limits

API keys need the all or tools scope for tools, tunnels, and webhooks. Creating or connecting needs a read-and-write key.

Tunnels

A tunnel gives an app on your machine a public HTTPS URL. The connection goes out over HTTPS, so it works behind NAT and firewalls, and WebSockets work too. See tunnels for the dashboard and CLI.
expose() reuses the tunnel with that name, or creates it. Without a name it uses your machine name and the port, such as my-laptop-3000.

Connection options

number | string
required
The local service: a port such as 3000, or a URL such as http://localhost:8080. expose() takes it as its first argument.
string | object
Ask visitors to sign in first. Pass "user:password" or an object with username and password.
object
Headers added to every request sent to your app.
object
Headers added to every response sent back to visitors.
string
default:"rewrite"
The Host header your app sees. rewrite uses the target’s host, preserve keeps the public host, and any other value is sent as is.
boolean
default:"true"
Accept a self-signed certificate on an https target.
boolean
default:"true"
Reconnect when the connection drops. Retries back off up to 30 seconds.
AbortSignal
Close the tunnel when the signal aborts.

The connection

connect() and expose() return a TunnelConnection. When retrying cannot help, such as a revoked key, a missing tunnel, or a plan limit, the tunnel stops with a TunnelFatalError. Its status field holds the HTTP status.

Tunnel operations

create() and rotate() return a tunnel token and ready-made install and connect commands for the pxxl-tunnel client. The SDK’s own connection uses your API key instead.

Webhooks

A webhook endpoint gives you a URL that records every request sent to it. You can forward requests from Pxxl, replay them, or stream them to your machine. See webhooks for the dashboard and CLI.

Endpoint fields

string
required
Name of the endpoint. Methods that take idOrName accept it.
string
Public URL that Pxxl forwards each request to.
object
Headers added to forwarded requests.
number
Status code the endpoint returns to the sender.
boolean
Pauses the endpoint. pause() and resume() set it for you.

Listen on your machine

listen() checks the endpoint for new requests and passes each one to onRequest. With forward, it also sends the request to that URL from your machine, so localhost works.
string
URL to send each new request to. The request’s own path and query are added to it.
boolean
default:"false"
Send every request to forward exactly, without adding the request’s path.
object
Extra headers on each forwarded request.
boolean
default:"false"
Also deliver requests that arrived before you started listening.
number
default:"1500"
How often to check for new requests. The minimum is 500.
AbortSignal
Stop listening when the signal aborts.
function
Called with request and, when forwarding, delivery (url, status, durationMs, error).
function
Called when a check fails. Listening keeps going.
listen() returns endpoint, stop(), and closed, a promise that resolves after you stop. Forwarded requests carry an X-Pxxl-Webhook-Request header with the request ID.

Webhook operations

replay() sends the request again from Pxxl, to the endpoint’s forwardUrl or to the url you pass. That URL must be public. Use listen() to deliver to localhost.