This article explains how to check the Anypoint VPN tunnel status in a CloudHub 2.0 Private Space using the Anypoint Platform API. You can use this to monitor the VPN and, by incorporating it with other tools, get alerted when a tunnel is down.
1. Create or identify a user in the Anypoint Platform in the organization or business group that owns the Private Space and its VPN. Grant that user permission to read the Private Space network configuration.
2. Retrieve a bearer token from the Anypoint Platform. See "How to generate your Authorization Bearer token for Anypoint Platform." The token expires per the "Default session timeout" setting in the root organization, usually 1 hour and a maximum of 3 hours, so refresh it regularly. For example:
curl -X POST \
https://anypoint.mulesoft.com/accounts/login \
-H 'Accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"username": "myusername",
"password": "mypassword"
}'
{
"access_token": "5c3c8c97-5afd-4c78-ab1a-xxxxxxxxxxxx",
"token_type": "bearer",
"redirectUrl": "/home/"
}
3. Get the Organization ID and the Private Space ID.
Unlike CloudHub 1.0, there is no VPC ID and no separate VPN ID to collect. One request returns every VPN connection in the private space.
4. Query the API for the VPN status.
curl -X GET \
https://anypoint.mulesoft.com/runtimefabric/api/organizations/<org id>/privatespaces/<private space id>/connections \
-H 'Authorization: Bearer 5c3c8c97-5afd-4c78-ab1a-xxxxxxxxxxxx'
The output is JSON. Each element in the array is a connection, each connection has a vpns list, and each VPN has a vpnTunnels list. The status fields to watch per tunnel are:
The connection also reports vpnConnectionStatus (for example, "available" or "modifying").
To parse only the tunnel statuses, pipe to jq:
curl -X GET -s \
https://anypoint.mulesoft.com/runtimefabric/api/organizations/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/privatespaces/11111111-2222-3333-4444-555555555555/connections \
-H 'Authorization: Bearer 5c3c8c97-5afd-4c78-ab1a-xxxxxxxxxxxx' | jq --raw-output '.[].vpns[].vpnTunnels[].status'
Tunnel name, status, and message together:
... | jq --raw-output '.[].vpns[] | .connectionName + ": " + (.vpnTunnels[] | .status + " " + .statusMessage)'
Only connections with a tunnel currently DOWN:
... | jq --raw-output '.[].vpns[] | select(.vpnTunnels[].status == "DOWN") | .connectionName'
Run the query on a schedule (a scheduled job or an external monitor) and raise a notification when any tunnel reports DOWN.
Please keep in mind:
The connections response includes tunnel configuration details, including the pre-shared keys (the psk field) for each tunnel. Treat the full response as sensitive: do not paste it into shared channels, tickets, or logs without redacting the pre-shared keys and any tunnel IP addresses.
005421205

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.