# 360 Monitoring

The 360 Monitoring module for WHM API 1.

## Register the server with 360 Monitoring

 - [GET /360Monitoring/register_server_with_360_monitoring](https://api.docs.cpanel.net/specifications/whm.openapi/360-monitoring/360monitoring-register_server_with_360_monitoring.md): This function registers the server with 360 Monitoring.

If the server is not already associated with a 360 Monitoring account,
the function creates a new account on the user's behalf and configures
the local agent. If the server is already registered, the function is
a no-op and returns the existing identifier.

The system persists the credentials required by the local agent server-side
and does not return them in the response. Inspect the metadata.result
field (1 for success, 0 for failure) and metadata.reason for
any failure details.

## Update 360 Monitoring agent polling settings

 - [GET /360Monitoring/set_360_agent_polling](https://api.docs.cpanel.net/specifications/whm.openapi/360-monitoring/360monitoring-set_360_agent_polling.md): This function updates agent360 polling settings.

Provide at least one of the following parameters: interval or max_data_span.

The interval parameter sets the individual polling interval for each plugin. If you
provide interval without any section filters, the function updates all core
(global, agent, data, and execution) and default plugin
(cpu, iostat, and network) sections.

The global_sections and plugin_sections parameters are only valid
if you provide the interval parameter.

The max_data_span parameter is global. The agent collects metrics from multiple
plugins and sends them together as a single batch.

If the requested values already match the current configuration, the function does not
make changes or restart the agent360 process.

## Complete the WebPros authentication flow

 - [POST /360Monitoring/webpros_auth_callback](https://api.docs.cpanel.net/specifications/whm.openapi/360-monitoring/360monitoring-webpros_auth_callback.md): This function completes the WebPros single sign-on flow for
360 Monitoring.

Call this function after the WebPros authorization server redirects the
user back to the server. The function exchanges the authorization code
for a token bundle and stores that bundle on the server. It does not
return the access token or the refresh token. Use the
360Monitoring/webpros_auth_token function to retrieve the access
token.

This function accepts its arguments as a single JSON-encoded json
parameter, and it requires that parameter in the request body. The
authorization code is a secret, and the server records the URL query
string in its access log. The function therefore rejects a request that
is not an HTTP POST, and also rejects a json parameter that appears
in the query string of a POST.

The function returns data.success with a value of 1 when it stores
a token. If the function fails, it returns data.success with a value
of 0, a human-readable data.error message, and, for the failures
that it detects before it contacts the authorization server, a
machine-readable data.reason value.

## Clear the WebPros authentication token

 - [GET /360Monitoring/webpros_auth_clear](https://api.docs.cpanel.net/specifications/whm.openapi/360-monitoring/360monitoring-webpros_auth_clear.md): This function removes the stored WebPros authentication token for
360 Monitoring.

This function does not accept any parameters. It deletes the token
bundle that the server stored during the WebPros single sign-on flow,
which signs the server out of 360 Monitoring.

The function is idempotent. If the server does not store a token, the
function reports success and makes no changes.

## Start the WebPros authentication flow

 - [GET /360Monitoring/webpros_auth_start](https://api.docs.cpanel.net/specifications/whm.openapi/360-monitoring/360monitoring-webpros_auth_start.md): This function starts the WebPros single sign-on flow for 360 Monitoring.

The system records the user agent and the remote IP address in the
server's log only. It builds the redirect URI from the WHM session
identifier, which it reads from the request when the session_id
parameter is absent. The function fails when it cannot determine a
session identifier, because a redirect URI without one produces an
authentication flow that cannot complete.

The function returns an authorization URL and the state token for this
flow. Redirect the user to the authorization URL and store the state
token for the duration of the flow. When the user returns to the
server, pass the authorization code and the state that the identity
provider returned to the 360Monitoring/webpros_auth_callback
function.

The system keeps the Proof Key for Code Exchange (PKCE) verifier on the
server, stored with the state for this flow. The verifier never reaches
the caller, and the 360Monitoring/webpros_auth_callback function does
not accept one.

The state token is a single-use secret. Do not log it, and do not use
it outside of the WHM session that started the flow. The system binds
the flow to that session and rejects a callback that arrives under any
other session.

## Check the WebPros authentication status

 - [GET /360Monitoring/webpros_auth_status](https://api.docs.cpanel.net/specifications/whm.openapi/360-monitoring/360monitoring-webpros_auth_status.md): This function reports whether the server holds a valid WebPros
authentication token for 360 Monitoring.

This function does not accept any parameters. It reads the token that
the server stored during the WebPros single sign-on flow, checks that
the token contains an identity token, and checks whether the token has
expired.

The function returns data.valid with a value of 1 when a usable
token exists. When the token is not usable, the function returns
data.valid with a value of 0 and a machine-readable
data.reason value.

The function does not return the access token or the refresh token.
Use the 360Monitoring/webpros_auth_token function to retrieve the
access token.

## Retrieve the WebPros access token

 - [GET /360Monitoring/webpros_auth_token](https://api.docs.cpanel.net/specifications/whm.openapi/360-monitoring/360monitoring-webpros_auth_token.md): This function returns the stored WebPros access token for
360 Monitoring.

This function does not accept any parameters. It returns the
access_token value from the token bundle that the server stored during
the WebPros single sign-on flow, and the number of seconds that remain
before that token expires. The function never returns the refresh token
or the rest of the token bundle.

The function fails with a data.reason value of no_valid_token when
the server does not store a token or when the stored token is no longer
valid. Use the 360Monitoring/webpros_auth_status function to find out
why the stored token is not valid, and the
360Monitoring/webpros_auth_start function to start a new
authentication flow.

The access token is a bearer credential. Transmit it only over HTTPS and
do not write it to logs.

