ngrok Agent API
If you want to programmatically control the ngrok agent, the Agent SDKs are usually a more flexible and powerful choice.
Overview
The ngrok agent exposes an HTTP API that enables programmatic access of:
- Collect status and metrics information
- Collect and replay captured requests
- Start and stop tunnels dynamically
Base URL and Authentication
Base URL | http://127.0.0.1:4040/api |
Authentication | None |
The ngrok agent API is exposed as part of ngrok's local web inspection interface. Because it is served on a local interface, the API has no authentication. The Base URL will change if you override web_addr
in your configuration file.
Access the root API resource of a running ngrok agent
Loading…
Supported Content Types
Request parameters must be encoded to the API using application/json
. Ensure that your client sets the request's Content-Type
header appropriately. All responses returned by the API are application/json
.
Versioning and API Stability
The ngrok agent API guarantees that breaking changes to the API will never be made unless the caller explicitly opts in to a newer version. The mechanism by which a caller opts into a new version of the API will be determined in the future when it becomes necessary. Examples of non-breaking changes to the API that will not be opt-in include the following.
- The addition of new resources
- The addition of new methods to existing resources
- The addition of new fields on existing resource representations
- Bug fixes which change the API to match documented behavior
List Tunnels
Returns a list of running tunnels with status and metrics information.
Request
GET/api/tunnels
Response
Parameters
tunnels | list of all running tunnels. See the Tunnel detail resource for docs on the parameters of each tunnel object |
Example Response
Loading…
Start tunnel
Dynamically starts a new tunnel on the ngrok agent. The request body parameters are the same as those you would use to define the tunnel in the configuration file.
Request
POST/api/tunnels
Parameters
Parameter names and behaviors are identical to those those defined in the configuration file. Use the tunnel definitions section as a reference for configuration parameters and their behaviors.
Example request body
Loading…
Response
201 status code with a response body describing the started tunnel. See the Tunnel detail resource for docs on the parameters of the response object