HTTP, DNS and certificate management. Each function lists its parameters, defaults and return value.
HTTP client functions.
Scope: Network
Function Description 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().
Parameter Type Default Description urlstring — Request URL (required) headersmap — Request headers queryParamsmap — URL query parameters
Parameter Type Default Description authTypestring — Auth type: "basic", "bearer", "apikey", "digest" authUsernamestring — Username for basic/digest auth authPasswordstring — Password for basic/digest auth authTokenstring — Token for bearer/apikey auth authHeaderstring "Authorization"Custom header name for API key
Parameter Type Default Description timeoutint 30Request timeout in seconds insecureSkipVerifybool falseSkip TLS certificate verification
Field Type Description successbool Whether request succeeded (2xx status) statusCodeint HTTP status code bodystring Response body headersmap Response headers latencyint Request latency in milliseconds
Perform an HTTP GET request.
let resp = http . get ( { url: " https://api.example.com/users " } )
log ( " Status: " + resp . statusCode )
log ( " Body: " + resp . body )
url: " https://api.example.com/data " ,
headers: { " Accept " : " application/json " },
url: " https://api.example.com/search " ,
Perform an HTTP POST request.
Parameter Type Default Description bodyany — Request body (string, map, or JSON-serializable value) formDatamap — Form data for application/x-www-form-urlencoded
url: " https://api.example.com/users " ,
headers: { " Content-Type " : " application/json " }
url: " https://example.com/login " ,
url: " https://api.example.com/data " ,
Perform an HTTP PUT request. Same parameters as http.post().
url: " https://api.example.com/users/123 " ,
body: { name: " Alice Updated " },
headers: { " Content-Type " : " application/json " },
Perform an HTTP PATCH request. Same parameters as http.post().
url: " https://api.example.com/users/123 " ,
Perform an HTTP DELETE request. Same parameters as http.get().
url: " https://api.example.com/users/123 " ,
Perform a custom HTTP request with full control over method, body, files, redirects, and output.
Parameter Type Default Description methodstring "GET"HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS) urlstring — Request URL (required) bodyany — Request body headersmap — Request headers queryParamsmap — URL query parameters formDatamap — Form data filesarray — Files to upload (array of {paramName, filePath, fileName, contentType}) authTypestring — Authentication type authUsernamestring — Auth username authPasswordstring — Auth password authTokenstring — Auth token authHeaderstring — Custom auth header timeoutint 30Timeout in seconds insecureSkipVerifybool falseSkip TLS verification followRedirectsbool trueFollow HTTP redirects maxRedirectsint 10Maximum redirects to follow retryEnabledbool trueEnable automatic retries retryCountint 3Number of retries outputPathstring — Save response body to file
// Custom request with files
let resp = http . request ( {
url: " https://api.example.com/upload " ,
filePath: " /tmp/data.csv " ,
let resp = http . request ( {
url: " https://example.com/large-file.zip "
log ( " Content-Length: " + resp . headers [ " Content-Length " ])
url: " https://example.com/report.pdf " ,
outputPath: " /tmp/report.pdf "
Download a file from a URL.
Parameter Type Default Description urlstring — URL to download from (required) outputPathstring — Local path to save file (required) headersmap — Request headers authTypestring — Authentication type authTokenstring — Auth token timeoutint 30Timeout in seconds
Field Type Description successbool Whether download succeeded statusCodeint HTTP status code latencyint Download latency in milliseconds
url: " https://example.com/release-v1.0.tar.gz " ,
outputPath: " /tmp/release.tar.gz "
url: " https://api.example.com/artifacts/build.zip " ,
outputPath: " /tmp/build.zip " ,
Upload a file to a URL.
Parameter Type Default Description urlstring — URL to upload to (required) filePathstring — Local file path to upload (required) paramNamestring "file"Form field name headersmap — Request headers authTypestring — Authentication type authTokenstring — Auth token
Field Type Description successbool Whether upload succeeded statusCodeint HTTP status code bodystring Response body
url: " https://api.example.com/files " ,
filePath: " /tmp/report.pdf " ,
// Upload with custom param name
url: " https://api.example.com/images " ,
filePath: " /tmp/photo.jpg " ,
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
Function Description 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
Parameter Type Required Description providerstring yes cloudflare / route53 / gcloud / azure / digitalocean / godaddycredentialsmap yes Provider-specific (see below) zonestring yes Zone name (example.com) timeoutint or string no Wall-clock cap
Field Type Description typestring DNS record type (uppercased internally) namestring Relative to zone (www); @ for apex valuestring Record value. For MX: hostname. For SRV: "port target" ttlint or string TTL ("5m" or seconds) priorityint MX or SRV priority weightint SRV weight
Parameter Type Description typestring Optional filter by record type namestring Optional filter by record name
credentials: { api_token: cfToken },
log ( " A records: " + zone . records . length )
credentials: { api_token: cfToken },
{ type: " TXT " , name: " @ " , value: " v=spf1 -all " }
// Add a record without disturbing other TXTs at the same name
credentials: { api_token: cfToken },
{ 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).
credentials: { api_token: cfToken },
{ type: " A " , name: " stale " , value: " 192.0.2.99 " }
// Delete every record at a name regardless of type/value:
credentials: { api_token: cfToken },
{ name: " old-subdomain " } // type, value left zero
System-resolver query. No provider credentials needed.
Parameter Type Description namestring FQDN (required) typestring A / AAAA / CNAME / TXT / MX / NS / SRV (required)serverstring Resolver override (1.1.1.1:53) timeoutint or string Default 5s
// Confirm propagation via Cloudflare's public resolver
if ( r . records . length === 0 ) {
throw " DNS not propagated yet "
log ( " resolved to " + r . records [ 0 ] . value )
Key Description api_tokenCloudflare API token (required)
Key Description access_keyAWS access key (optional — env / IAM role fallback) secret_keyAWS secret key session_tokenSTS session token (optional) regionAWS region profileNamed AWS profile
Key Description 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.
Key Description 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.
Key Description api_tokenDO personal access token (required)
Key Description 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.
Function Description 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.
Parameter Type Default Description caURLstring LE production ACME directory URL. Shortcuts: letsencrypt, staging, zerossl emailstring — Account contact email (required for obtain/renew/revoke) storagestring $XDG_DATA_HOME/letsencryptFilesystem path keyTypestring ECDSA-P256ECDSA-P256 / ECDSA-P384 / RSA-2048 / RSA-4096 / ED25519timeoutint or string — Wall-clock cap
Used by obtain and renew.
Parameter Type Default Description challengestring "dns-01""dns-01" / "http-01" / "tls-alpn-01"mustStaplebool false Set OCSP must-staple
Parameter Type Description dnsProviderstring One of the six libdns providers (see dns.md) dnsCredentialsmap Provider credentials (same shape as the dns namespace) dnsPropagationint or string Propagation delay before asking the CA to verify dnsResolvers[]string Resolvers used to verify propagation (e.g. ["1.1.1.1:53"])
Parameter Type Default Description httpAddressstring ":80"Bind address
Parameter Type Default Description tlsAddressstring ":443"Bind address
Parameter Type Required Description domains[]string yes First is CN; the rest become SANs on the same cert
subject, issuer, domains,
notBefore, notAfter, // RFC 3339
serial, fingerprint, // "sha256:<hex>"
certPath, keyPath, fullchainPath
let r = letsencrypt . obtain ( {
storage: " /var/lib/letsencrypt " ,
domains: [ " example.com " , " www.example.com " , " api.example.com " ] ,
dnsProvider: " cloudflare " ,
dnsCredentials: { api_token: cfToken }
log ( " issued: " + r . cert . domains . join ( " , " ))
domains: [ " app.example.com " ],
// Staging (test against LE staging, no rate-limit pressure)
domains: [ " dev.example.com " ],
dnsProvider: " cloudflare " ,
dnsCredentials: { api_token: cfToken }
Same parameters as obtain, plus:
Parameter Type Description forcebool Renew regardless of the renewal window
domains: [ " example.com " , " www.example.com " ],
dnsProvider: " cloudflare " ,
dnsCredentials: { api_token: cfToken }
Parameter Type Description domainstring First domain of the cert (looked up via storage) certPathstring Or an explicit cert PEM path reasonint RFC 5280 reason code (default 0 — unspecified)
Common reasons: 0 unspecified, 1 keyCompromise, 3 affiliationChanged,
4 superseded, 5 cessationOfOperation.
domain: " oops.example.com " ,
reason: 1 , // keyCompromise
dnsProvider: " cloudflare " ,
dnsCredentials: { api_token: cfToken }
Parameter Type Description domainstring Look up via storage certPathstring Or 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 " } )
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.