Create a new Caddy API client
Client configuration options
Adapt a configuration from one format to another Commonly used to convert Caddyfile to JSON configuration.
The configuration content to adapt
The adapter to use (e.g., "caddyfile", "json", "yaml", "nginx", "apache")
The adapted configuration as validated JSON
Add a route to a server
Server name
Route configuration
True if route was added, false if already exists
Add multiple routes to a server (convenience method to avoid loops) This method adds routes one at a time and handles idempotency for each.
Performance: Fetches existing routes once and caches them to avoid N+1 API calls.
Server name
Array of routes to add
Object with counts of added and skipped routes
Apply a full configuration to Caddy
Replaces the entire running Caddy configuration with the provided config object. This is the primary method for applying loaded or modified configurations.
Full Caddy configuration object
Get routes for a specific server
Server name (e.g., "https_server")
Array of routes, validated against Caddy route schema
Get configuration for a specific server
Server name
Server configuration object, validated against Caddy schema
Get reverse proxy upstream status Returns the current state of all configured upstream servers.
Array of upstream server status objects, validated
Get Caddy version information
Version information object with version string and additional metadata
Insert a route at a specific position in the server's route list
Server name
Route to insert
Where to insert the route
void
Replace all routes for a server (PATCH)
Server name
Array of routes
Reload Caddy configuration
Remove routes matching a hostname
Hostname to match
Server name
Number of routes removed
Replace a route by its
Server name
Route
New route configuration
true if route was found and replaced, false otherwise
Client for interacting with Caddy Admin API