With AlertSite Management API, you can edit FTP and FTPS (FTP over SSL) monitors.
FTP
To modify an FTP monitor for an ftp://
server, send a PATCH request to /monitors/ftp/{id}
, where {id}
is the monitor ID.
FTPS
To modify an FTPS monitor for an ftps://
server, send a PATCH request to /monitors/ftp-ssl/{id}
, where {id}
is the monitor ID.
Request URL
Authentication
The request must include the Authorization
header containing a user’s access token:
Authorization: Bearer ACCESS_TOKEN
See Authentication for more information.
Request body
The request body is a JSON object containing the monitor configuration fields you want to update.
FTP
For example, disable testing file uploading and downloading on an FTP server and change the port number:
{
"enable_ftp_upload":false
"port":80
}
FTPS
For example, change the SSL certificate version and disable testing file uploading and downloading on an FTPS server:
{
"use_ssl_version":2,
"enable_ftp_upload":false
}
Response body
On success, the operation returns the ID of the updated monitor.
{
"id": "123456"
}
Error responses have a non-200 status code and contain the errors
list, such as:
{
"errors": [
{
"code": 400,
"message": "invalid_request - User authentication failed."
}
]
}
Try it out
FTP
Click here to test this operation in AlertSite’s interactive API console.
FTPS
Click here to test this operation in AlertSite’s interactive API console.
Code examples
FTP
This code updates the monitor with ID 123456 and disables testing file uploading and downloading on an FTP server and changes the port number.
cURL (Windows)
curl -X PATCH https://api.alertsite.com/api/v3/monitors/ftp/123456
-H "Authorization: Bearer ACCESS_TOKEN"
-H "Content-Type: application/json"
-d '{\"enable_ftp_upload\":true, \"port\":80}'
Note: New lines are added for readability.
The actual command should be one continuous line.
cURL (bash)
curl -X PATCH https://api.alertsite.com/api/v3/monitors/ftp/123456 \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-type: application/json" \
-d '{"enable_ftp_upload":true, "port":80}'
Python
import requests # Requests library https://requests.kennethreitz.org/en/master/
import json
baseUrl = 'https://api.alertsite.com/api/v3'
username = '[email protected]' # Replace with your AlertSite login email
password = 'pa55w0rd' # Replace with your AlertSite password
monitor_params = {
'enable_ftp_upload': False,
'port': 80
}
# Login
payload = {'username': username, 'password': password}
r = requests.post(baseUrl+'/access-tokens', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
token = r.json()['access_token']
# Update the monitor
headers = {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
}
r = requests.patch(baseUrl+'/monitors/ftp/123456', data=json.dumps(monitor_params), headers=headers)
result = r.json()
if r.status_code == requests.codes.ok:
monitor_id = result['id']
print('Successfully updated the monitor. ID:{}'.format(monitor_id))
else:
print('Could not update the monitor. The following error(s) occurred:', *result['errors'], sep='\n')
FTPS
This code updates the monitor with ID 123456 and changes the SSL certificate version and disables testing file uploading and downloading on an FTPS server.
cURL (Windows)
curl -X PATCH https://api.alertsite.com/api/v3/monitors/ftp-ssl/123456
-H "Authorization: Bearer ACCESS_TOKEN"
-H "Content-Type: application/json"
-d '{\"use_ssl_version\":2, \"enable_ftp_upload\":true}'
Note: New lines are added for readability.
The actual command should be one continuous line.
cURL (bash)
curl -X POST https://api.alertsite.com/api/v3/monitors/website-ssl/123456 \
-H "Authorization: Bearer ACCESS_TOKEN" \
-H "Content-type: application/json" \
-d '{"use_ssl_version":2, "enable_ftp_upload":false}'
Python
import requests # Requests library https://requests.kennethreitz.org/en/master/
import json
baseUrl = 'https://api.alertsite.com/api/v3'
username = '[email protected]' # Replace with your AlertSite login email
password = 'pa55w0rd' # Replace with your AlertSite password
monitor_params = {
'use_ssl_version': 2,
'enable_ftp_upload': False
}
# Login
payload = {'username': username, 'password': password}
r = requests.post(baseUrl+'/access-tokens', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
token = r.json()['access_token']
# Update the monitor
headers = {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
}
r = requests.patch(baseUrl+'/monitors/ftp-ssl/123456', data=json.dumps(monitor_params), headers=headers)
result = r.json()
if r.status_code == requests.codes.ok:
monitor_id = result['id']
print('Successfully updated the monitor. ID:{}'.format(monitor_id))
else:
print('Could not update the monitor. The following error(s) occurred:', *result['errors'], sep='\n')