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

NameTypeDescription
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.
owner_idstringIf supplied at credential creation, ownership will be assigned to the specified User or Bot. Only admins may specify an owner other than themselves. Defaults to the authenticated User or Bot.

Response

Returns a 201 response on success

Example Response

{
"acl": [],
"created_at": "2024-05-23T20:36:00Z",
"description": "development cred for alan@example.com",
"id": "cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2",
"owner_id": "usr_2gsqJQHeG64zEjjv6U3JEYSmao6",
"token": "2gsqJTuvpdCmEhRT4PDpiE1B4D2_769XcGCA9cTDfM7Z4Tb26",
"uri": "https://api.ngrok.com/credentials/cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2"
}

Fields

NameTypeDescription
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.
owner_idstringIf supplied at credential creation, ownership will be assigned to the specified User or Bot. Only admins may specify an owner other than themselves. Defaults to the authenticated User or Bot.

Delete Tunnel Credential

Delete a tunnel authtoken credential by ID

Request

DELETE /credentials/{id}

Example Request

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

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 \
-X GET \
-H "Authorization: Bearer {API_KEY}" \
-H "Ngrok-Version: 2" \
https://api.ngrok.com/credentials/cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2

Response

Returns a 200 response on success

Example Response

{
"acl": [],
"created_at": "2024-05-23T20:36:00Z",
"description": "device alpha-2",
"id": "cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2",
"metadata": "{\"device_id\": \"d5111ba7-0cc5-4ba3-8398-e6c79e4e89c2\"}",
"owner_id": "usr_2gsqJQHeG64zEjjv6U3JEYSmao6",
"token": null,
"uri": "https://api.ngrok.com/credentials/cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2"
}

Fields

NameTypeDescription
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.
owner_idstringIf supplied at credential creation, ownership will be assigned to the specified User or Bot. Only admins may specify an owner other than themselves. Defaults to the authenticated User or Bot.

List Tunnel Credentials

List all tunnel authtoken credentials on this account

Request

GET /credentials

Example Request

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

Response

Returns a 200 response on success

Example Response

{
"credentials": [
{
"acl": [],
"created_at": "2024-05-23T20:36:00Z",
"description": "development cred for alan@example.com",
"id": "cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2",
"owner_id": "usr_2gsqJQHeG64zEjjv6U3JEYSmao6",
"token": null,
"uri": "https://api.ngrok.com/credentials/cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2"
},
{
"acl": [],
"created_at": "2024-05-23T20:35:59Z",
"description": "credential for \"api-examples-ce12d36d2e406466@example.com\"",
"id": "cr_2gsqJTj7UNKR5IUNGQkvldMGPmt",
"owner_id": "usr_2gsqJQHeG64zEjjv6U3JEYSmao6",
"token": null,
"uri": "https://api.ngrok.com/credentials/cr_2gsqJTj7UNKR5IUNGQkvldMGPmt"
},
{
"acl": ["bind:1.tcp.ngrok.io:20002", "bind:132.devices.company.com"],
"created_at": "2024-05-23T20:36:00Z",
"description": "for device #132",
"id": "cr_2gsqJPMY3shL1wqwC2Ep2au3i9X",
"owner_id": "usr_2gsqJQHeG64zEjjv6U3JEYSmao6",
"token": null,
"uri": "https://api.ngrok.com/credentials/cr_2gsqJPMY3shL1wqwC2Ep2au3i9X"
}
],
"next_page_uri": null,
"uri": "https://api.ngrok.com/credentials"
}

Fields

NameTypeDescription
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

NameTypeDescription
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.
owner_idstringIf supplied at credential creation, ownership will be assigned to the specified User or Bot. Only admins may specify an owner other than themselves. Defaults to the authenticated User or Bot.

Update Tunnel Credential

Update attributes of an tunnel authtoken credential by ID

Request

PATCH /credentials/{id}

Example Request

curl \
-X PATCH \
-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_2gsqJTuvpdCmEhRT4PDpiE1B4D2

Parameters

NameTypeDescription
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

{
"acl": [],
"created_at": "2024-05-23T20:36:00Z",
"description": "device alpha-2",
"id": "cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2",
"metadata": "{\"device_id\": \"d5111ba7-0cc5-4ba3-8398-e6c79e4e89c2\"}",
"owner_id": "usr_2gsqJQHeG64zEjjv6U3JEYSmao6",
"token": null,
"uri": "https://api.ngrok.com/credentials/cr_2gsqJTuvpdCmEhRT4PDpiE1B4D2"
}

Fields

NameTypeDescription
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.
owner_idstringIf supplied at credential creation, ownership will be assigned to the specified User or Bot. Only admins may specify an owner other than themselves. Defaults to the authenticated User or Bot.