Create Custom Property

Last modified on August 16, 2021

To define a new custom property, send a POST request to /properties, with a JSON body containing the property name and possible values.

Once a property is created, you can use it in your monitors.

Request URL



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 property name and possible values, in the following format:

  "name": "Environment",
  "values": [
    { "name": "Production" },
    { "name": "Staging" },
    { "name": "Development" }

All values must be strings.

Response body

If successful, the operation returns HTTP status 200 with a response body containing the ID of the created property:

  "id": "123"

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

Click here to test this operation in AlertSite’s interactive API console.

Code examples

This code creates a property named Environment with the Production, Staging, and Development values.

cURL (Windows)

curl -X POST \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"name\": \"Environment\", \"values\": [{\"name\": \"Production\"}, {\"name\": \"Staging\"}, {\"name\": \"Development\"}]}"

Note: New lines are added for readability.
The actual command should be one continuous line.

cURL (bash)

curl -X POST \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name": "Environment", "values": [{"name": "Production"}, {"name": "Staging"}, {"name": "Development"}]}'


# Python 3.5+
import requests  # Requests library –
import json

baseUrl = ''
username = ''  # Replace with your AlertSite login email
password = 'pa55w0rd'          # Replace with your AlertSite password

property_name = 'Environment'
property_values = ['Production', 'Staging', 'Development']

# Log in
payload = {'username': username, 'password': password}
r = + '/access-tokens', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
token = r.json()['access_token']

# Create a custom property
headers = {
   'Authorization': 'Bearer ' + token,
   'Content-Type': 'application/json'
payload = {
   'name': property_name,
   'values': [{'name': value} for value in property_values]
r = + '/properties', data=json.dumps(payload), headers=headers)
result = r.json()
if r.ok:
   property_id = result['id']
   print('Successfully created a new custom property (ID: {})'.format(property_id))
   print('Could not create a property. The following error(s) occurred:', *result['errors'], sep='\n')

See Also

Custom Properties Operations

Highlight search results