Skip to main content

Credentials


Create Tunnel Credential

Create a new tunnel authtoken credential. This authtoken credential can be used to start a new tunnel session. The response to this API call is the only time the generated token is available. If you need it for future use, you must save it securely yourself.

Request

POST /credentials

Example Request

curl \
-X POST \
-H "Authorization: Bearer {API_KEY}" \
-H "Content-Type: application/json" \
-H "Ngrok-Version: 2" \
-d '{"description":"development cred for alan@example.com"}' \
https://api.ngrok.com/credentials

Parameters

   
descriptionstringhuman-readable description of who or what will use the credential to authenticate. Optional, max 255 bytes.
metadatastringarbitrary user-defined machine-readable data of this credential. Optional, max 4096 bytes.
aclList<string>optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains, addresses, and labels the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules for domains may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. Bind rules for labels may specify a wildcard key and/or value to match multiple labels. For example, you may specify a rule of bind:*=example which will allow x=example, y=example, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions.

Response

Returns a 201 response on success

Example Response

{
"id": "cr_2IEh2EYZF5XxPRAtzSSSnBGadhz",
"uri": "https://api.ngrok.com/credentials/cr_2IEh2EYZF5XxPRAtzSSSnBGadhz",
"created_at": "2022-11-29T20:07:20Z",
"description": "development cred for alan@example.com",
"token": "2IEh2EYZF5XxPRAtzSSSnBGadhz_Q43RCqus6mgsAjtVbB8Y",
"acl": []
}

Fields

   
idstringunique tunnel credential resource identifier
uristringURI of the tunnel credential API resource
created_atstringtimestamp when the tunnel credential was created, RFC 3339 format
descriptionstringhuman-readable description of who or what will use the credential to authenticate. Optional, max 255 bytes.
metadatastringarbitrary user-defined machine-readable data of this credential. Optional, max 4096 bytes.
tokenstringthe credential's authtoken that can be used to authenticate an ngrok agent. This value is only available one time, on the API response from credential creation, otherwise it is null.
aclList<string>optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains, addresses, and labels the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules for domains may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. Bind rules for labels may specify a wildcard key and/or value to match multiple labels. For example, you may specify a rule of bind:*=example which will allow x=example, y=example, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions.

Delete Tunnel Credential

Delete a tunnel authtoken credential by ID

Request

DELETE /credentials/{id}

Example Request

curl \
-XDELETE \
-H "Authorization: Bearer {API_KEY}" \
-H "Ngrok-Version: 2" \
https://api.ngrok.com/credentials/cr_2IEh2EYZF5XxPRAtzSSSnBGadhz

Response

Returns a 204 response with no body on success

Get Tunnel Credential

Get detailed information about a tunnel authtoken credential

Request

GET /credentials/{id}

Example Request

curl \
-H "Authorization: Bearer {API_KEY}" \
-H "Ngrok-Version: 2" \
https://api.ngrok.com/credentials/cr_2IEh2EYZF5XxPRAtzSSSnBGadhz

Response

Returns a 200 response on success

Example Response

{
"id": "cr_2IEh2EYZF5XxPRAtzSSSnBGadhz",
"uri": "https://api.ngrok.com/credentials/cr_2IEh2EYZF5XxPRAtzSSSnBGadhz",
"created_at": "2022-11-29T20:07:20Z",
"description": "device alpha-2",
"metadata": "{\"device_id\": \"d5111ba7-0cc5-4ba3-8398-e6c79e4e89c2\"}",
"token": null,
"acl": []
}

Fields

   
idstringunique tunnel credential resource identifier
uristringURI of the tunnel credential API resource
created_atstringtimestamp when the tunnel credential was created, RFC 3339 format
descriptionstringhuman-readable description of who or what will use the credential to authenticate. Optional, max 255 bytes.
metadatastringarbitrary user-defined machine-readable data of this credential. Optional, max 4096 bytes.
tokenstringthe credential's authtoken that can be used to authenticate an ngrok agent. This value is only available one time, on the API response from credential creation, otherwise it is null.
aclList<string>optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains, addresses, and labels the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules for domains may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. Bind rules for labels may specify a wildcard key and/or value to match multiple labels. For example, you may specify a rule of bind:*=example which will allow x=example, y=example, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions.

List Tunnel Credentials

List all tunnel authtoken credentials on this account

Request

GET /credentials

Example Request

curl \
-H "Authorization: Bearer {API_KEY}" \
-H "Ngrok-Version: 2" \
https://api.ngrok.com/credentials

Response

Returns a 200 response on success

Example Response

{
"credentials": [
{
"id": "cr_2IEh2EYZF5XxPRAtzSSSnBGadhz",
"uri": "https://api.ngrok.com/credentials/cr_2IEh2EYZF5XxPRAtzSSSnBGadhz",
"created_at": "2022-11-29T20:07:20Z",
"description": "development cred for alan@example.com",
"token": null,
"acl": []
},
{
"id": "cr_2IEh2DUO4UQZl2xbDevf0RFAr4v",
"uri": "https://api.ngrok.com/credentials/cr_2IEh2DUO4UQZl2xbDevf0RFAr4v",
"created_at": "2022-11-29T20:07:20Z",
"description": "for device #132",
"token": null,
"acl": [
"bind:1.tcp.ngrok.io:20002",
"bind:132.devices.company.com"
]
},
{
"id": "cr_2IEh28qVlq0vvLbSDUgmVilM7WV",
"uri": "https://api.ngrok.com/credentials/cr_2IEh28qVlq0vvLbSDUgmVilM7WV",
"created_at": "2022-11-29T20:07:19Z",
"description": "credential for \"api-examples-7f38be7f74422f33@example.com\"",
"token": "2IEh28qVlq0vvLbSDUgmVilM7WV_5Kuj8yfxMrv4qEZEK8oh6",
"acl": []
}
],
"uri": "https://api.ngrok.com/credentials",
"next_page_uri": null
}

Fields

   
credentialsCredentialthe list of all tunnel credentials on this account
uristringURI of the tunnel credential list API resource
next_page_uristringURI of the next page, or null if there is no next page

Credential fields

   
idstringunique tunnel credential resource identifier
uristringURI of the tunnel credential API resource
created_atstringtimestamp when the tunnel credential was created, RFC 3339 format
descriptionstringhuman-readable description of who or what will use the credential to authenticate. Optional, max 255 bytes.
metadatastringarbitrary user-defined machine-readable data of this credential. Optional, max 4096 bytes.
tokenstringthe credential's authtoken that can be used to authenticate an ngrok agent. This value is only available one time, on the API response from credential creation, otherwise it is null.
aclList<string>optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains, addresses, and labels the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules for domains may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. Bind rules for labels may specify a wildcard key and/or value to match multiple labels. For example, you may specify a rule of bind:*=example which will allow x=example, y=example, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions.

Update Tunnel Credential

Update attributes of an tunnel authtoken credential by ID

Request

PATCH /credentials/{id}

Example Request

curl \
-XPATCH \
-H "Authorization: Bearer {API_KEY}" \
-H "Content-Type: application/json" \
-H "Ngrok-Version: 2" \
-d '{"description":"device alpha-2","metadata":"{\"device_id\": \"d5111ba7-0cc5-4ba3-8398-e6c79e4e89c2\"}"}' \
https://api.ngrok.com/credentials/cr_2IEh2EYZF5XxPRAtzSSSnBGadhz

Parameters

   
idstring
descriptionstringhuman-readable description of who or what will use the credential to authenticate. Optional, max 255 bytes.
metadatastringarbitrary user-defined machine-readable data of this credential. Optional, max 4096 bytes.
aclList<string>optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains, addresses, and labels the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules for domains may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. Bind rules for labels may specify a wildcard key and/or value to match multiple labels. For example, you may specify a rule of bind:*=example which will allow x=example, y=example, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions.

Response

Returns a 200 response on success

Example Response

{
"id": "cr_2IEh2EYZF5XxPRAtzSSSnBGadhz",
"uri": "https://api.ngrok.com/credentials/cr_2IEh2EYZF5XxPRAtzSSSnBGadhz",
"created_at": "2022-11-29T20:07:20Z",
"description": "device alpha-2",
"metadata": "{\"device_id\": \"d5111ba7-0cc5-4ba3-8398-e6c79e4e89c2\"}",
"token": null,
"acl": []
}

Fields

   
idstringunique tunnel credential resource identifier
uristringURI of the tunnel credential API resource
created_atstringtimestamp when the tunnel credential was created, RFC 3339 format
descriptionstringhuman-readable description of who or what will use the credential to authenticate. Optional, max 255 bytes.
metadatastringarbitrary user-defined machine-readable data of this credential. Optional, max 4096 bytes.
tokenstringthe credential's authtoken that can be used to authenticate an ngrok agent. This value is only available one time, on the API response from credential creation, otherwise it is null.
aclList<string>optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains, addresses, and labels the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules for domains may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. Bind rules for labels may specify a wildcard key and/or value to match multiple labels. For example, you may specify a rule of bind:*=example which will allow x=example, y=example, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions.