Create an FTP Monitor

Last modified on August 24, 2020

With AlertSite Management API, you can create FTP and FTPS (FTP over SSL) monitors.

FTP

To create a new FTP monitor for an ftp:// server, send a POST request to /monitors/ftp with a JSON body containing the monitor configuration.

FTPS

To create a new FTPS monitor for an ftps:// server, send a POST request to /monitors/ftp-ssl with a JSON body containing the monitor configuration.

Request URL

FTP

POST https://api.alertsite.com/api/v3/monitors/ftp

FTPS

POST https://api.alertsite.com/api/v3/monitors/ftp-ssl

Authentication

The request must include the Authorization header containing a user’s access token:

Authorization: Bearer ACCESS_TOKEN

See Authentication for more information.

The authenticating user must have permissions to create monitors.

Request body

The request body is a JSON object containing the monitor configuration parameters. The required data fields for an FTP monitor are:

  • billing_plancode

  • name

  • hostname

  • enable_ftp_upload

For the full list and description of available fields, see FTP and FTPS monitor fields.

Parameters that are not specified in the request body will take the values specified in AlertSite defaults and your account defaults. For example, if you do not specify locations for the monitor, it will use your account's default monitoring locations.

FTP

Below is the minimal example of FTP monitor parameters:

{
    "billing_plancode": "UBM - A/A",
    "name": "FTP Sample",
    "hostname": "ftp://your_ftp_host",
    "enable_ftp_upload": false
}

FTPS

Below is the minimal example of FTPS monitor parameters:

{
    "billing_plancode": "UBM - A/A",
    "name": "FTPS Sample",
    "hostname": "ftps://your_ftps_host",
    "enable_ftp_upload": false
}

Response body

On success, the operation returns the ID of the created 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 creates a 15-minute FTP monitor.

cURL (Windows)

curl -X POST https://api.alertsite.com/api/v3/monitors/ftp
  -H "Authorization: Bearer ACCESS_TOKEN"
  -H "Content-Type: application/json"
  -d '{\"billing_plancode\":\"UBM - A/A\", \"name\":\"FTP Sample\", \"hostname\":\"ftp://your_ftp_host\", \"interval\":15, \"enable_ftp_upload\": true, \"ftp_username\":\"guest\", \"ftp_password\":\"demo@example.com\", \"enabled\":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/ftp \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-type: application/json" \
  -d '{"billing_plancode":"UBM - A/A", "name":"FTP Sample", "hostname":"ftp://your_ftp_host", "interval":15, "enable_ftp_upload": true, "ftp_username":"guest", "ftp_password":"demo@example.com", "enabled":true}'

Python

import requests # Requests library https://requests.kennethreitz.org/en/master/
import json

baseUrl = 'https://api.alertsite.com/api/v3'
username = 'demo@example.com'  # Replace with your AlertSite login email
password = 'pa55w0rd'          # Replace with your AlertSite password


monitor_params = {
  'billing_plancode': 'UBM - A/A',
  'name': 'FTP Sample',
  'hostname': 'ftp://your_ftp_host',
  'enable_ftp_upload': True,
  'ftp_username': 'guest',
  'ftp_password': 'demo@example.com',
  'interval': 15,
  'enabled': True
}

# 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']

# Create the monitor
headers = {
  'Authorization': 'Bearer ' + token,
  'Content-Type': 'application/json'
}
r = requests.post(baseUrl+'/monitors/ftp', data=json.dumps(monitor_params), headers=headers)
result = r.json()
if r.status_code == requests.codes.ok:
    monitor_id = result['id']
    print('Successfully created a monitor. ID:{}'.format(monitor_id))
else:
    print('Could not create a monitor. The following error(s) occurred:', *result['errors'], sep='\n')

FTPS

This code creates a 15-minute FTPS monitor.

cURL (Windows)

curl -X POST https://api.alertsite.com/api/v3/monitors/ftp-ssl
  -H "Authorization: Bearer ACCESS_TOKEN"
  -H "Content-Type: application/json"
  -d '{\"billing_plancode\":\"UBM - A/A\", \"name\":\"FTPS Sample\", \"hostname\":\"ftps://your_ftps_host\", \"interval\":15, \"enable_ftp_upload\": true, \"ftp_username\":\"guest\", \"ftp_password\":\"demo@example.com\", \"enabled\":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/ftp-ssl \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-type: application/json" \
  -d '{"billing_plancode":"UBM - A/A", "name":"FTP Sample", "hostname":"ftps://your_ftps_host", "interval":15, "enable_ftp_upload": true, "ftp_username":"guest", "ftp_password":"demo@example.com", "enabled":true}'

Python

import requests # Requests library https://requests.kennethreitz.org/en/master/
import json

baseUrl = 'https://api.alertsite.com/api/v3'
username = 'demo@example.com'  # Replace with your AlertSite login email
password = 'pa55w0rd'          # Replace with your AlertSite password


monitor_params = {
  'billing_plancode': 'UBM - A/A',
  'name': 'FTPS Sample',
  'hostname': 'ftps://your_ftps_host',
  'enable_ftp_upload': True,
  'ftp_username': 'guest',
  'ftp_password': 'demo@example.com',
  'interval': 15,
  'enabled': True
}

# 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']

# Create the monitor
headers = {
  'Authorization': 'Bearer ' + token,
  'Content-Type': 'application/json'
}
r = requests.post(baseUrl+'/monitors/ftp-ssl', data=json.dumps(monitor_params), headers=headers)
result = r.json()
if r.status_code == requests.codes.ok:
    monitor_id = result['id']
    print('Successfully created a monitor. ID:{}'.format(monitor_id))
else:
    print('Could not create a monitor. The following error(s) occurred:', *result['errors'], sep='\n')

See Also

Monitor Operations
Edit an FTP Monitor
Delete Monitor

Highlight search results