Delete Custom Property

Last modified on March 27, 2024

To delete a custom property, send a DELETE request to /properties/{id}, where {id} is the property ID. You can get property IDs by using GET /properties.

Deleting a property deletes it from all monitors.

Request URL

DELETE https://api.alertsite.com/api/v3/properties/{id}

Authentication

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

Authorization: Bearer ACCESS_TOKEN

See Authentication for more information.

Response body

If successful, the operation returns HTTP status 204 without a request body.

Error responses have a non-204 status code and include the errors list:

{
  "errors": [
    {
      "code": 404,
      "message": "Record not found"
    }
  ]
}

Try it out

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

Code examples

cURL

Delete the property with ID 123:

curl -X DELETE https://api.alertsite.com/api/v3/properties/123 -H "Authorization: Bearer ACCESS_TOKEN"

Python

Delete the property named Environment:

Python

# Python 3.5+
import requests  # Requests library http://docs.python-requests.org
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
property_name = 'Environment'

# Log in and get the bearer token
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']
headers = {'Authorization': 'Bearer ' + token}

# Get property ID by property name
r = requests.get(baseUrl + '/properties?select=id,name', headers=headers)
for prop in r.json()['results']:
  if prop['name'] == property_name:
    property_id = prop['id']
    break
else:
  print('Property named "{}" was not found.'.format(property_name))
  quit()

# Delete the property
r = requests.delete(baseUrl + '/properties/{}'.format(property_id), headers=headers)
if r.ok:
  print('Property # {} has been deleted.'.format(property_id))
else:
  print('Could not delete property # {}. The following error(s) occurred:'.format(property_id), *r.json()['errors'], sep='\n')

See Also

Custom Properties Operations

Highlight search results