Get Custom Properties

Last modified on March 25, 2021

Get all custom properties defined in your AlertSite account. The returned data includes the property names, IDs, and possible values.

Request URL

GET https://api.alertsite.com/api/v3/properties[?select=field1,...]

Authentication

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

Authorization: Bearer ACCESS_TOKEN

See Authentication for more information.

Query parameters

select

Optional. A comma-separated list of property data fields to include in the response. The available field names are: id, name, values.

Response body

If successful, the operation returns HTTP status 200 and a JSON object containing metadata and results, where results is an array of property data. The following example shows the data of two custom properties, Application and Environment:

{
  "metadata": {
    "__permissions": {
      "acl": 7
    },
    "resultset": {
      "count": 2,
      "limit": null,
      "offset": null
    }
  },
  "results": [
    {
      "id": 28,
      "name": "Application",
      "values": [
        {
          "id": 74,
          "name": "App1"
        },
        {
          "id": 76,
          "name": "App2"
        },
        {
          "id": 78,
          "name": "App3"
        }
      ]
    },
    {
      "id": 26,
      "name": "Environment",
      "values": [
        {
          "id": 58,
          "name": "Development"
        },
        {
          "id": 60,
          "name": "Production"
        },
        {
          "id": 62,
          "name": "Staging"
        }
      ]
    }
  ]
}

If no custom properties are defined in your AlertSite account, an empty results array is returned:

{
  "metadata": {
    "__permissions": {
      "acl": 7
    },
    "resultset": {
      "count": 0,
      "limit": null,
      "offset": null
    }
  },
  "results": []
}

Error responses have HTTP status codes in the 4xx range.

Try it out

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

Code examples

cURL

Get all custom properties:

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

Get just the property IDs and names:

curl https://api.alertsite.com/api/v3/properties?select=id,name -H "Authorization: Bearer ACCESS_TOKEN"

Python

This example prints a list of all custom property names and possible values.

Python

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

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

# Get all custom properties
r = requests.get(baseUrl + '/properties', headers={'Authorization': 'Bearer ' + token})
result = r.json()

if r.ok:
    for prop in result['results']:
        values = [value['name'] for value in prop['values']]
        values_as_string = ', '.join(map(str, values))
        print('Name: {}\nValues: {}\n'.format(prop['name'], values_as_string))
else:
    print('Could not retrieve custom properties. The following error(s) occurred:', *result['errors'], sep='\n')

See Also

Custom Properties Operations

Highlight search results