Skip to content
Talk to our solutions team

Network

HTTP, DNS and certificate management. Each function lists its parameters, defaults and return value.

HTTP client functions.

Scope: Network

FunctionDescription
http.get()Perform an HTTP GET request
http.post()Perform an HTTP POST request
http.put()Perform an HTTP PUT request
http.patch()Perform an HTTP PATCH request
http.delete()Perform an HTTP DELETE request
http.request()Perform a custom HTTP request with full control
http.download()Download a file from a URL
http.upload()Upload a file to a URL

These parameters are shared across http.get(), http.post(), http.put(), http.patch(), and http.delete().

ParameterTypeDefaultDescription
urlstringRequest URL (required)
headersmapRequest headers
queryParamsmapURL query parameters
ParameterTypeDefaultDescription
authTypestringAuth type: "basic", "bearer", "apikey", "digest"
authUsernamestringUsername for basic/digest auth
authPasswordstringPassword for basic/digest auth
authTokenstringToken for bearer/apikey auth
authHeaderstring"Authorization"Custom header name for API key
ParameterTypeDefaultDescription
timeoutint30Request timeout in seconds
insecureSkipVerifyboolfalseSkip TLS certificate verification
FieldTypeDescription
successboolWhether request succeeded (2xx status)
statusCodeintHTTP status code
bodystringResponse body
headersmapResponse headers
latencyintRequest latency in milliseconds

Perform an HTTP GET request.

// Simple GET
let resp = http.get({ url: "https://api.example.com/users" })
log("Status: " + resp.statusCode)
log("Body: " + resp.body)
// With headers and auth
let resp = http.get({
url: "https://api.example.com/data",
headers: { "Accept": "application/json" },
authType: "bearer",
authToken: "my-token"
})
// With query parameters
let resp = http.get({
url: "https://api.example.com/search",
queryParams: {
q: "hello",
limit: "10"
}
})

Perform an HTTP POST request.

ParameterTypeDefaultDescription
bodyanyRequest body (string, map, or JSON-serializable value)
formDatamapForm data for application/x-www-form-urlencoded
// POST JSON
let resp = http.post({
url: "https://api.example.com/users",
body: { name: "Alice", email: "[email protected]" },
headers: { "Content-Type": "application/json" }
})
// POST form data
let resp = http.post({
url: "https://example.com/login",
formData: {
username: "admin",
password: "secret"
}
})
// POST with auth
let resp = http.post({
url: "https://api.example.com/data",
body: { key: "value" },
authType: "basic",
authUsername: "user",
authPassword: "pass"
})

Perform an HTTP PUT request. Same parameters as http.post().

// Update a resource
let resp = http.put({
url: "https://api.example.com/users/123",
body: { name: "Alice Updated" },
headers: { "Content-Type": "application/json" },
authType: "bearer",
authToken: "my-token"
})

Perform an HTTP PATCH request. Same parameters as http.post().

// Partial update
let resp = http.patch({
url: "https://api.example.com/users/123",
body: { email: "[email protected]" },
authType: "bearer",
authToken: "my-token"
})

Perform an HTTP DELETE request. Same parameters as http.get().

// Delete a resource
let resp = http.delete({
url: "https://api.example.com/users/123",
authType: "bearer",
authToken: "my-token"
})

Perform a custom HTTP request with full control over method, body, files, redirects, and output.

ParameterTypeDefaultDescription
methodstring"GET"HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
urlstringRequest URL (required)
bodyanyRequest body
headersmapRequest headers
queryParamsmapURL query parameters
formDatamapForm data
filesarrayFiles to upload (array of {paramName, filePath, fileName, contentType})
authTypestringAuthentication type
authUsernamestringAuth username
authPasswordstringAuth password
authTokenstringAuth token
authHeaderstringCustom auth header
timeoutint30Timeout in seconds
insecureSkipVerifyboolfalseSkip TLS verification
followRedirectsbooltrueFollow HTTP redirects
maxRedirectsint10Maximum redirects to follow
retryEnabledbooltrueEnable automatic retries
retryCountint3Number of retries
outputPathstringSave response body to file
// Custom request with files
let resp = http.request({
method: "POST",
url: "https://api.example.com/upload",
files: [
{
paramName: "file",
filePath: "/tmp/data.csv",
contentType: "text/csv"
}
],
authType: "bearer",
authToken: "my-token"
})
// HEAD request
let resp = http.request({
method: "HEAD",
url: "https://example.com/large-file.zip"
})
log("Content-Length: " + resp.headers["Content-Length"])
// Save response to file
http.request({
method: "GET",
url: "https://example.com/report.pdf",
outputPath: "/tmp/report.pdf"
})

Download a file from a URL.

ParameterTypeDefaultDescription
urlstringURL to download from (required)
outputPathstringLocal path to save file (required)
headersmapRequest headers
authTypestringAuthentication type
authTokenstringAuth token
timeoutint30Timeout in seconds
FieldTypeDescription
successboolWhether download succeeded
statusCodeintHTTP status code
latencyintDownload latency in milliseconds
// Download a file
http.download({
url: "https://example.com/release-v1.0.tar.gz",
outputPath: "/tmp/release.tar.gz"
})
// Download with auth
http.download({
url: "https://api.example.com/artifacts/build.zip",
outputPath: "/tmp/build.zip",
authType: "bearer",
authToken: "my-token"
})

Upload a file to a URL.

ParameterTypeDefaultDescription
urlstringURL to upload to (required)
filePathstringLocal file path to upload (required)
paramNamestring"file"Form field name
headersmapRequest headers
authTypestringAuthentication type
authTokenstringAuth token
FieldTypeDescription
successboolWhether upload succeeded
statusCodeintHTTP status code
bodystringResponse body
// Upload a file
let resp = http.upload({
url: "https://api.example.com/files",
filePath: "/tmp/report.pdf",
authType: "bearer",
authToken: "my-token"
})
// Upload with custom param name
let resp = http.upload({
url: "https://api.example.com/images",
filePath: "/tmp/photo.jpg",
paramName: "image",
headers: { "X-Upload-Type": "profile" }
})

DNS record CRUD via libdns + system-resolver lookup.

Six providers in v1: cloudflare, route53, gcloud, azure, digitalocean, godaddy. Provider credentials are shared with the letsencrypt namespace’s DNS-01 challenge.

Scope: Network

FunctionDescription
dns.list()Read records in a zone (optional filters)
dns.set()Upsert by (name, type) — replaces existing RRset
dns.append()Add records without touching existing ones
dns.delete()Remove records by exact match
dns.lookup()Query via system resolver — no provider creds
ParameterTypeRequiredDescription
providerstringyescloudflare / route53 / gcloud / azure / digitalocean / godaddy
credentialsmapyesProvider-specific (see below)
zonestringyesZone name (example.com)
timeoutint or stringnoWall-clock cap
FieldTypeDescription
typestringDNS record type (uppercased internally)
namestringRelative to zone (www); @ for apex
valuestringRecord value. For MX: hostname. For SRV: "port target"
ttlint or stringTTL ("5m" or seconds)
priorityintMX or SRV priority
weightintSRV weight
ParameterTypeDescription
typestringOptional filter by record type
namestringOptional filter by record name
let zone = dns.list({
provider: "cloudflare",
credentials: { api_token: cfToken },
zone: "example.com",
type: "A"
})
log("A records: " + zone.records.length)
dns.set({
provider: "cloudflare",
credentials: { api_token: cfToken },
zone: "example.com",
records: [
{ type: "TXT", name: "@", value: "v=spf1 -all" }
]
})
// Add a record without disturbing other TXTs at the same name
dns.append({
provider: "cloudflare",
credentials: { api_token: cfToken },
zone: "example.com",
records: [
{ type: "TXT", name: "_dmarc", value: "v=DMARC1; p=none;" }
]
})

Records are matched by name + type + ttl + value. Leave any of those zero to match by the remaining fields (libdns convention).

dns.delete({
provider: "cloudflare",
credentials: { api_token: cfToken },
zone: "example.com",
records: [
{ type: "A", name: "stale", value: "192.0.2.99" }
]
})
// Delete every record at a name regardless of type/value:
dns.delete({
provider: "cloudflare",
credentials: { api_token: cfToken },
zone: "example.com",
records: [
{ name: "old-subdomain" } // type, value left zero
]
})

System-resolver query. No provider credentials needed.

ParameterTypeDescription
namestringFQDN (required)
typestringA / AAAA / CNAME / TXT / MX / NS / SRV (required)
serverstringResolver override (1.1.1.1:53)
timeoutint or stringDefault 5s
// Confirm propagation via Cloudflare's public resolver
let r = dns.lookup({
name: "www.example.com",
type: "A",
server: "1.1.1.1:53",
timeout: "10s"
})
if (r.records.length === 0) {
throw "DNS not propagated yet"
}
log("resolved to " + r.records[0].value)
KeyDescription
api_tokenCloudflare API token (required)
KeyDescription
access_keyAWS access key (optional — env / IAM role fallback)
secret_keyAWS secret key
session_tokenSTS session token (optional)
regionAWS region
profileNamed AWS profile
KeyDescription
projectGCP project ID (required)
service_account_json_pathPath to SA JSON
service_account_jsonInline SA JSON (written to a temp file)

Falls back to Application Default Credentials when neither is set.

KeyDescription
subscription_idRequired
resource_groupRequired
tenant_idService-principal tenant
client_idService-principal client
client_secretService-principal secret

Omit the service-principal triple to use managed identity / Azure CLI.

KeyDescription
api_tokenDO personal access token (required)
KeyDescription
api_keyGoDaddy API key (required)
api_secretGoDaddy API secret (required)

ACME certificate management via certmagic. Default CA is Let’s Encrypt; the caURL parameter accepts any ACME-compatible directory.

DNS-01 challenges reuse the six libdns providers wired into the dns namespace, so credentials shapes are shared between them.

Scope: Network

Replaces the old acme namespace. lego is no longer a dependency.

FunctionDescription
letsencrypt.obtain()Issue a certificate (or load from storage if already present)
letsencrypt.renew()Renew an existing certificate
letsencrypt.revoke()Revoke a certificate at the CA
letsencrypt.info()Read X.509 details from a cached cert
letsencrypt.list()Enumerate cached certs

Every function accepts these in addition to its own surface.

ParameterTypeDefaultDescription
caURLstringLE productionACME directory URL. Shortcuts: letsencrypt, staging, zerossl
emailstringAccount contact email (required for obtain/renew/revoke)
storagestring$XDG_DATA_HOME/letsencryptFilesystem path
keyTypestringECDSA-P256ECDSA-P256 / ECDSA-P384 / RSA-2048 / RSA-4096 / ED25519
timeoutint or stringWall-clock cap

Used by obtain and renew.

ParameterTypeDefaultDescription
challengestring"dns-01""dns-01" / "http-01" / "tls-alpn-01"
mustStapleboolfalseSet OCSP must-staple
ParameterTypeDescription
dnsProviderstringOne of the six libdns providers (see dns.md)
dnsCredentialsmapProvider credentials (same shape as the dns namespace)
dnsPropagationint or stringPropagation delay before asking the CA to verify
dnsResolvers[]stringResolvers used to verify propagation (e.g. ["1.1.1.1:53"])
ParameterTypeDefaultDescription
httpAddressstring":80"Bind address
ParameterTypeDefaultDescription
tlsAddressstring":443"Bind address
ParameterTypeRequiredDescription
domains[]stringyesFirst is CN; the rest become SANs on the same cert
{
success: bool,
cert: {
subject, issuer, domains,
notBefore, notAfter, // RFC 3339
serial, fingerprint, // "sha256:<hex>"
daysRemaining,
certPath, keyPath, fullchainPath
},
error
}
// DNS-01 with SAN
let r = letsencrypt.obtain({
storage: "/var/lib/letsencrypt",
domains: ["example.com", "www.example.com", "api.example.com"],
challenge: "dns-01",
dnsProvider: "cloudflare",
dnsCredentials: { api_token: cfToken }
})
log("issued: " + r.cert.domains.join(", "))
// HTTP-01
letsencrypt.obtain({
domains: ["app.example.com"],
challenge: "http-01"
})
// Staging (test against LE staging, no rate-limit pressure)
letsencrypt.obtain({
caURL: "staging",
domains: ["dev.example.com"],
challenge: "dns-01",
dnsProvider: "cloudflare",
dnsCredentials: { api_token: cfToken }
})

Same parameters as obtain, plus:

ParameterTypeDescription
forceboolRenew regardless of the renewal window
letsencrypt.renew({
domains: ["example.com", "www.example.com"],
force: true,
challenge: "dns-01",
dnsProvider: "cloudflare",
dnsCredentials: { api_token: cfToken }
})
ParameterTypeDescription
domainstringFirst domain of the cert (looked up via storage)
certPathstringOr an explicit cert PEM path
reasonintRFC 5280 reason code (default 0 — unspecified)

Common reasons: 0 unspecified, 1 keyCompromise, 3 affiliationChanged, 4 superseded, 5 cessationOfOperation.

letsencrypt.revoke({
domain: "oops.example.com",
reason: 1, // keyCompromise
challenge: "dns-01",
dnsProvider: "cloudflare",
dnsCredentials: { api_token: cfToken }
})
ParameterTypeDescription
domainstringLook up via storage
certPathstringOr an explicit cert path

Returns the same cert shape as obtain. Touches no network.

let r = letsencrypt.info({
storage: "/var/lib/letsencrypt",
domain: "www.example.com"
})
log(r.cert.domains[0] + " expires in " + r.cert.daysRemaining + " days")

No verb-specific parameters. When caURL is set, lists only certs for that CA.

let r = letsencrypt.list({ storage: "/var/lib/letsencrypt" })
for (let c of r.certs) {
log(c.domains.join(", ") + "" + c.daysRemaining + " days left")
}
  • obtain is idempotent: if a cert already exists in storage and isn’t within its renewal window, the call is a no-op and returns the existing cert info.
  • renew only renews when the cert is within its renewal window; pass force: true to override.
  • For Let’s Encrypt production, every successful issuance counts against your per-domain rate limit (50/week as of writing). Use the staging CA shortcut to test without pressure.
  • Storage uses certmagic’s filesystem backend. The lib-storage adapter is out of scope for v1.