API Docs

Introduction

Welcome to the Blockbax API Reference. Use the Blockbax API to easily get data in and out of Blockbax.

The Blockbax API uses REST which means the URLs are resource-oriented and HTTP status codes are used to indicate success or failure. Data returned from our API will be in JSON format for all requests. In code examples cURL is used to interact with our API, however for almost any language there are libraries available to integrate with a REST API.

Authentication

Blockbax uses API keys to allow access to the API. API keys can be created in the web app. Every request to the API needs to send an authorization header along that looks like the following:

Authorization: ApiKey <API_key>

Make sure to replace <API_key> with your API key, for instance in the cURL examples throughout the API reference.

Rate limits

Blockbax uses rate limits to avoid resource starvation. All endpoints are rate limited except the endpoint for sending measurements. Once a rate limit is hit a 429 response code is returned for all subsequent requests until the limit is reset.

Rate limits can be inspected by looking at the content of the related response headers:

Header Description
X-RateLimit-Limit Number of requests allowed in a specific time period
X-RateLimit-Remaining Number of requests remaining in the current time period
X-RateLimit-Reset Number of seconds remaining in the current time period until rate limit is reset

If you are rate limited you can throttle your requests by waiting the time returned in the X-RateLimit-Reset header before retrying and making other requests again.

You can request a rate limit increase by contacting our support team. Please let us know what use case you are trying to support and how much of an increase is required.

Projects

This endpoint allows you to programmatically query projects.

Get a project

Fetch an existing project.

Parameters

This endpoint takes no arguments.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "id": "715b6935-e3d8-48b1-86a3-a6e2a268e1f",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "name": "My Project",
  "description": "This is my project",
  "timezoneId": "Europe/Amsterdam",
  "organizationId": "86d9e586-70b7-4f6b-a5af-9cb5c48de661"
}

Property Types

This endpoint allows you to programmatically create, update, delete and query property types.

Search property types

Search and filter property types. Results are paginated with a maximum of 200 results at a time.

Parameters

  • name [optional, default=None]: Filter property types by name.
  • externalId [optional, default=None]: Filter property types by external ID.
  • page [optional, default=0]: The page to fetch.
  • size [optional, default=20]: The page size. Max 200.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/propertyTypes

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}/propertyTypes"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "count": 2,
  "result": [
    {
      "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "createdDate": "2021-01-24T15:00:01.946+0000",
      "updatedDate": "2021-01-24T15:05:02.124+0000",
      "name": "City",
      "externalId": "city",
      "dataType": "TEXT",
      "predefinedValues": true,
      "values": [
        {
          "id": "4204fbd0-d09b-4803-adc5-09dbbc448d30",
          "text": "Amsterdam"
        },
        {
          "id": "6121933f-6f90-448e-86d2-ced335ac9172",
          "text": "Rotterdam"
        }
      ]
    },
    {
      "id": "4126798f-398a-4b90-92e0-4a03fc286bcf",
      "createdDate": "2021-01-24T15:00:01.946+0000",
      "updatedDate": "2021-01-24T15:05:02.124+0000",
      "name": "Capacity (persons)",
      "externalId": "capacity",
      "dataType": "NUMBER",
      "predefinedValues": true,
      "values": [
        {
          "id": "2dcaa9cb-6d39-4997-a710-0f6ccabdb3e3",
          "caption": "ElevatorType1",
          "number": 5
        },
        {
          "id": "a0f72e76-53a0-4d88-b1f6-dc7d9b1e927a",
          "number": 8
        }
      ]
    },
    {
      "id": "ade083a4-fb3a-490a-8025-312112066b79",
      "createdDate": "2021-01-25T15:00:01.946+0000",
      "updatedDate": "2021-01-25T15:05:02.124+0000",
      "name": "Geographic coordinate",
      "externalId": "geographic-coordinate",
      "dataType": "LOCATION",
      "predefinedValues": false,
      "values": [
        {
          "id": "f8c52571-b882-4bf0-b013-f38f9621e7b8",
          "location": {
            "lat": 52.37403,
            "lon": 4.88969,
            "alt": -3.2
          }
        },
        {
          "id": "dfff4f32-f2be-480e-8bb1-87d71d74aeb6",
          "location": {
            "lat": 51.9225,
            "lon": 4.47917,
            "alt": -5.2
          }
        }
      ]
    },
    {
      "id": "d237162d-6da6-455e-8921-ba0c4bae4fc5",
      "createdDate": "2021-01-25T15:00:01.946+0000",
      "updatedDate": "2021-01-25T15:05:02.124+0000",
      "name": "Factory layout",
      "externalId": "factory-layout",
      "dataType": "MAP_LAYER",
      "predefinedValues": false,
      "values": [
        {
          "id": "8a75002b-0c63-4fe8-afc0-2c05e428a76a",
          "mapLayer": {
            "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/d237162d-6da6-455e-8921-ba0c4bae4fc5/values/8a75002b-0c63-4fe8-afc0-2c05e428a76a/files/efa6753f-4981-417f-aabd-be0f43c6e4f6.png",
            "leftBottom": {
              "lat": 52.37403,
              "lon": 4.88969
            },
            "leftTop": {
              "lat": 52.37404,
              "lon": 4.88969
            },
            "rightBottom": {
              "lat": 52.37403,
              "lon": 4.8897
            },
            "rightTop": {
              "lat": 52.37404,
              "lon": 4.8897
            }
          }
        }
      ]
    },
    {
      "id": "bae083a4-fb3a-490a-8025-312112066b66",
      "createdDate": "2021-01-25T15:00:01.946+0000",
      "updatedDate": "2021-01-25T15:05:02.124+0000",
      "name": "Equipment photos",
      "externalId": "equipment-photos",
      "dataType": "IMAGE",
      "predefinedValues": false,
      "values": [
        {
          "id": "a8c52571-b882-4bf0-b013-f38f9621e7b6",
          "image": {
            "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/bae083a4-fb3a-490a-8025-312112066b66/values/a8c52571-b882-4bf0-b013-f38f9621e7b6/files/ada6753f-4981-417f-aabd-be0f43c6e4c9.png"
          }
        }
      ]
    },
    {
      "id": "dee083a4-fb3a-490a-8025-312112066b11",
      "createdDate": "2021-01-25T15:00:01.946+0000",
      "updatedDate": "2021-01-25T15:05:02.124+0000",
      "name": "Area",
      "externalId": "area",
      "dataType": "AREA",
      "predefinedValues": false,
      "values": [
        {
          "id": "c4c52571-b882-4bf0-b013-f38f9621e7d8",
          "area": {
            "polygon": {
              "outerRing": [
                {
                  "lat": 52.37404,
                  "lon": 4.88969
                },
                {
                  "lat": 51.37404,
                  "lon": 3.88969
                },
                {
                  "lat": 52.37404,
                  "lon": 2.88969
                },
                {
                  "lat": 52.37404,
                  "lon": 4.88969
                }
              ]
            }
          }
        }
      ]
    }
  ]
}

Get a property type

Fetch an existing property type.

Parameters

This endpoint takes no arguments.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/propertyTypes/<PROPERTY_TYPE_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
property_type_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl "https://api.blockbax.com/v1/projects/${project_id}/propertyTypes/${property_type_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "name": "City",
  "externalId": "city",
  "dataType": "TEXT",
  "predefinedValues": true,
  "values": [
    {
      "id": "4204fbd0-d09b-4803-adc5-09dbbc448d30",
      "caption": "The city in the Netherlands",
      "text": "Amsterdam"
    },
    {
      "id": "6121933f-6f90-448e-86d2-ced335ac9172",
      "text": "Rotterdam"
    }
  ]
}

Create or update a property type

Create a new property type or update an existing one.

Body

  • name [required]: The name of the property type.
  • externalId [required]: The external ID of the property type. This ID can be used when integrating with external systems (e.g. when subscribing to property updates via MQTT) in order to avoid having to know which IDs are internally used in the Blockbax Platform.
  • dataType [required]: The type of the property type. Can be “TEXT”, “NUMBER”, “LOCATION”, “MAP_LAYER” or “IMAGE”.
  • predefinedValues [required]: Defines whether it is possible to create values for this property type on this endpoint (for value true) or they are automatically created when adding a value to a subject (for value false).
  • values : List of values.
    • id : When updating a value with a PUT request, pass the value ID that should be updated. When creating a new value (with predefinedValues = true), leave empty.
    • caption : An optional caption, but required for locations, map layers and images. Can only be used for predefined values.
    • text: The value in case of a text data type.
    • number: The value in case of a number data type.
    • location: The value in case of a location data type.
      • lat: Latitude in decimal degrees (-90 to 90 for the integer part and 8 digits behind the decimal point).
      • lon: Longitude in decimal degrees (-180 to 180 for the integer part and 8 digits behind the decimal point).
      • alt: Altitude above the earth surface in meters (up to 20 digits before and 8 digits behind the decimal point).
    • mapLayer: The value in case of a map layer data type.
      • imageData: Base64 encoded image file that can be a gif, png or jpeg with a max size of 5 MB. In the returned JSON this is turned into an imagePath in the format /projects/{projectId}/propertyTypes/{propertyTypeId}/values/{valueId}/files/{imageFile} which can then be retrieved from there.
      • leftBottom: left bottom coordinates
        • lat: Latitude in decimal degrees (-90 to 90 for the integer part and 8 digits behind the decimal point).
        • lon: Longitude in decimal degrees (-180 to 180 for the integer part and 8 digits behind the decimal point).
      • leftTop: left top coordinates
        • lat: Latitude in decimal degrees (-90 to 90 for the integer part and 8 digits behind the decimal point).
        • lon: Longitude in decimal degrees (-180 to 180 for the integer part and 8 digits behind the decimal point).
      • rightBottom: right bottom coordinates
        • lat: Latitude in decimal degrees (-90 to 90 for the integer part and 8 digits behind the decimal point).
        • lon: Longitude in decimal degrees (-180 to 180 for the integer part and 8 digits behind the decimal point).
      • rightTop: right top coordinates
        • lat: Latitude in decimal degrees (-90 to 90 for the integer part and 8 digits behind the decimal point).
        • lon: Longitude in decimal degrees (-180 to 180 for the integer part and 8 digits behind the decimal point).
    • image: The value in case of an image data type.
      • imageData: Base64 encoded image file that can be a gif, png or jpeg with a max size of 5 MB. In the returned JSON this is turned into an imagePath in the format /projects/{projectId}/propertyTypes/{propertyTypeId}/values/{valueId}/files/{imageFile} which can then be retrieved from there.
    • area: The value in case of an area data type.
      • polygon: The polygon value.
        • outerRing: The outer ring of the polygon. This is an array of coordinates with a lat and lon value that must express a valid polygon that is drawn counter-clockwise. The last coordinate should be the same as the first.
          • lat: Latitude in decimal degrees (-90 to 90 for the integer part and 8 digits behind the decimal point).
          • lon: Longitude in decimal degrees (-180 to 180 for the integer part and 8 digits behind the decimal point).

HTTP Request

Create
POST https://api.blockbax.com/v1/projects/<PROJECT_ID>/propertyTypes

Update
PUT https://api.blockbax.com/v1/projects/<PROJECT_ID>/propertyTypes/<PROPERTY_TYPE_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
property_type_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl -X POST "https://api.blockbax.com/v1/projects/${project_id}/propertyTypes"
or
curl -X PUT "https://api.blockbax.com/v1/projects/${project_id}/propertyTypes/${property_type_id}"
  -H "Authorization: ApiKey ${api_key}"
  -H "Content-Type: application/json"
  -d '{
        "name": "City",
        "externalId": "city",
        "dataType": "TEXT",
        "predefinedValues": true,
        "values": [
          {
            "id": "4204fbd0-d09b-4803-adc5-09dbbc448d30",
            "caption": "The city in the Netherlands",
            "text": "Amsterdam"
          },
          {
            "text": "Den Haag"
          }
        ]
      }'

Example response

{
  "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "name": "City",
  "externalId": "city",
  "dataType": "TEXT",
  "predefinedValues": true,
  "values": [
    {
      "id": "4204fbd0-d09b-4803-adc5-09dbbc448d30",
      "caption": "The city in the Netherlands",
      "text": "Amsterdam"
    },
    {
      "id": "6121933f-6f90-448e-86d2-ced335ac9172",
      "text": "Den Haag"
    }
  ]
}

Delete a property type

Delete an existing property type.

Parameters

This endpoint takes no arguments.

HTTP Request

DELETE https://api.blockbax.com/v1/projects/<PROJECT_ID>/propertyTypes/<PROPERTY_TYPE_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
property_type_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl -X DELETE "https://api.blockbax.com/v1/projects/${project_id}/propertyTypes/${property_type_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{}

Subject Types

This endpoint allows you to programmatically create, update, delete and query subject types.

Search subject types

Search and filter subject types. Results are paginated with a maximum of 200 results at a time.

Parameters

  • name [optional, default=None]: Filter subject types by name.
  • propertyTypeIds [optional, default=None]: A list of strings that contain property type IDs to filter on.
  • page [optional, default=0]: The page to fetch.
  • size [optional, default=20]: The page size. Max 200.

Note

At the moment the deprecated field parentSubjectTypeId is included in the response for backward compatibility, if and only if there is only one parent subject type. Please do not use this field, it will be removed in the near future.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjectTypes

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}/subjectTypes"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "count": 1,
  "result": [
    {
      "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "createdDate": "2021-01-24T15:00:01.946+0000",
      "updatedDate": "2021-01-24T15:05:02.124+0000",
      "parentSubjectTypeIds": ["5674b063-7be9-465e-a8d8-451170960acb"],
      "name": "Transformer substation",
      "primaryLocation": {
        "type": "PROPERTY_TYPE",
        "id": "50f381bf-eb46-4d73-9bfd-5bfb57db43d6"
      },
      "propertyTypes": [
        {
          "id": "bfdc883b-524f-43e2-bef6-0e8f63a1b7ce",
          "required": true,
          "visible": true
        },
        {
          "id": "50f381bf-eb46-4d73-9bfd-5bfb57db43d6",
          "required": false,
          "visible": true
        }
      ]
    }
  ]
}

Get a subject type

Fetch an existing subject type.

Parameters

This endpoint takes no arguments.

Note

At the moment the deprecated field parentSubjectTypeId is included in the response for backward compatibility, if and only if there is only one parent subject type. Please do not use this field, it will be removed in the near future.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjectTypes/<SUBJECT_TYPE_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
subject_type_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl "https://api.blockbax.com/v1/projects/${project_id}/subjectTypes/${subject_type_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "parentSubjectTypeIds": ["5674b063-7be9-465e-a8d8-451170960acb"],
  "name": "Transformer substation",
  "primaryLocation": {
    "type": "PROPERTY_TYPE",
    "id": "50f381bf-eb46-4d73-9bfd-5bfb57db43d6"
  },
  "propertyTypes": [
    {
      "id": "bfdc883b-524f-43e2-bef6-0e8f63a1b7ce",
      "required": true,
      "visible": true
    },
    {
      "id": "50f381bf-eb46-4d73-9bfd-5bfb57db43d6",
      "required": false,
      "visible": false
    }
  ]
}

Create or update a subject type

Create a new subject type or update an existing one.

Body

  • name [required]: The name of the subject type.
  • parentSubjectTypeIds: The IDs of the parent subject types of this subject type.
  • primaryLocation : The primary location metric or property type of this subject type, for displaying the location of subjects on the map.
    • type : Choose from: METRIC or PROPERTY_TYPE.
    • id : the metric or property type ID to use as primary location.
  • propertyTypes : List of property types associated with this subject type.
    • id : Id of the property type.
    • required [required]: Whether the property type is required to have a value for subjects belong to this subject type.
    • visible : Whether the property type is visible in the web app in this subject type.

HTTP Request

Create
POST https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjectTypes

Update
PUT https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjectTypes/<SUBJECT_TYPE_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
subject_type_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl -X POST "https://api.blockbax.com/v1/projects/${project_id}/subjectTypes"
or
curl -X PUT "https://api.blockbax.com/v1/projects/${project_id}/subjectTypes/${subject_type_id}"
  -H "Authorization: ApiKey ${api_key}"
  -H "Content-Type: application/json"
  -d '{
        "parentSubjectTypeIds": ["5674b063-7be9-465e-a8d8-451170960acb"],
        "name": "Transformer substation",
        "primaryLocation" : {
          "type" : "PROPERTY_TYPE",
          "id" : "50f381bf-eb46-4d73-9bfd-5bfb57db43d6"
        },
        "propertyTypes": [
          {
            "id": "bfdc883b-524f-43e2-bef6-0e8f63a1b7ce",
            "required": true,
            "visible": true
          },
          {
            "id": "50f381bf-eb46-4d73-9bfd-5bfb57db43d6",
            "required": false,
            "visible": false
          }
        ]
      }'

Example response

{
  "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "parentSubjectTypeIds": ["5674b063-7be9-465e-a8d8-451170960acb"],
  "name": "Transformer substation",
  "primaryLocation": {
    "type": "PROPERTY_TYPE",
    "id": "50f381bf-eb46-4d73-9bfd-5bfb57db43d6"
  },
  "propertyTypes": [
    {
      "id": "bfdc883b-524f-43e2-bef6-0e8f63a1b7ce",
      "required": true,
      "visible": true
    },
    {
      "id": "50f381bf-eb46-4d73-9bfd-5bfb57db43d6",
      "required": false,
      "visible": false
    }
  ]
}

Delete a subject type

Delete an existing subject type.

Parameters

This endpoint takes no arguments.

HTTP Request

DELETE https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjectTypes/<SUBJECT_TYPE_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
subject_type_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl -X DELETE "https://api.blockbax.com/v1/projects/${project_id}/subjectTypes/${subject_type_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{}

Subjects

This endpoint allows you to programmatically create, update, delete and query subjects.

Search subjects

Search and filter subjects. Results are paginated with a maximum of 200 results at a time.

Parameters

  • name [optional, default=None]: Filter subjects by name.
  • externalId [optional, default=None]: Filter subjects by external ID.
  • subjectIds [optional, default=None]: Comma-separated list of subject IDs.
  • subjectIdsMode [optional, default=SELF]: Determines how the subjectIds parameter is applied. Choose from: SELF (only those ids), CHILDREN (only the direct children) or ALL (the subjects themselves and all subjects that have them in their composition anywhere in the tree).
  • subjectTypeIds [optional, default=None]: Comma-separated list of subject type IDs.
  • propertyValueIds [optional, default=None]: Filter on a list of property value IDs, use a , separator for OR and ; for AND, e.g. <A>,<B>;<C> translates to (A OR B) AND C.
  • page [optional, default=0]: The page to fetch.
  • size [optional, default=20]: The page size. Max 200.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjects

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}/subjects"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "count": 2,
  "result": [
    {
      "id": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
      "createdDate": "2021-01-24T15:00:01.946+0000",
      "updatedDate": "2021-01-24T15:05:02.124+0000",
      "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "parentSubjectId": "e2bbf958-9f60-4e67-97df-3f6e2c1c08a0",
      "name": "My house",
      "externalId": "MyHouse",
      "ingestionIds": [
        {
          "metricId": "7c40cc50-aa51-4eb2-8937-71ce62798f17",
          "deriveIngestionId": false,
          "ingestionId": "MyIngestionId"
        },
        {
          "metricId": "7f43ba7b-2c80-4e4f-b2b6-4f7fecd0311",
          "deriveIngestionId": true,
          "ingestionId": "MyHouse$MyTemperature"
        }
      ],
      "properties": [
        {
          "typeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
          "valueId": "4204fbd0-d09b-4803-adc5-09dbbc448d30",
          "text": "Rotterdam"
        },
        {
          "typeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
          "valueId": "2dcaa9cb-6d39-4997-a710-0f6ccabdb3e3",
          "caption": "Enum value five",
          "number": 5
        },
        {
          "typeId": "ade083a4-fb3a-490a-8025-312112066b79",
          "valueId": "f8c52571-b882-4bf0-b013-f38f9621e7b8",
          "location": {
            "lat": 52.37403,
            "lon": 4.88969,
            "alt": -3.2
          }
        },
        {
          "typeId": "d237162d-6da6-455e-8921-ba0c4bae4fc5",
          "valueId": "8a75002b-0c63-4fe8-afc0-2c05e428a76a",
          "mapLayer": {
            "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/d237162d-6da6-455e-8921-ba0c4bae4fc5/values/8a75002b-0c63-4fe8-afc0-2c05e428a76a/files/efa6753f-4981-417f-aabd-be0f43c6e4f6.png",
            "leftBottom": {
              "lat": 52.37403,
              "lon": 4.88969
            },
            "leftTop": {
              "lat": 52.37404,
              "lon": 4.88969
            },
            "rightBottom": {
              "lat": 52.37403,
              "lon": 4.8897
            },
            "rightTop": {
              "lat": 52.37404,
              "lon": 4.8897
            }
          }
        },
        {
          "typeId": "bae083a4-fb3a-490a-8025-312112066b66",
          "valueId": "a8c52571-b882-4bf0-b013-f38f9621e7b6",
          "image": {
            "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/bae083a4-fb3a-490a-8025-312112066b66/values/a8c52571-b882-4bf0-b013-f38f9621e7b6/files/ada6753f-4981-417f-aabd-be0f43c6e4c9.png"
          }
        },
        {
          "typeId": "dee083a4-fb3a-490a-8025-312112066b11",
          "valueId": "c4c52571-b882-4bf0-b013-f38f9621e7d8",
          "area": {
            "polygon": {
              "outerRing": [
                {
                  "lat": 52.37404,
                  "lon": 4.88969
                },
                {
                  "lat": 51.37404,
                  "lon": 3.88969
                },
                {
                  "lat": 52.37404,
                  "lon": 2.88969
                },
                {
                  "lat": 52.37404,
                  "lon": 4.88969
                }
              ]
            }
          }
        },
        {
          "typeId": "fc13e380-aee1-46c3-a125-2a7831b6d492",
          "valueId": "dc93a95c-7bc4-4e91-a36c-97f17ba0c9ef",
          "inherit": true,
          "text": "I inherited this value from my parent subject"
        }
      ]
    },
    {
      "id": "e889593b-d07d-4c53-a83f-3458e8e04a98",
      "createdDate": "2021-01-24T15:00:01.946+0000",
      "updatedDate": "2021-01-24T15:05:02.124+0000",
      "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "parentSubjectId": "e2bbf958-9f60-4e67-97df-3f6e2c1c08a0",
      "name": "My office",
      "externalId": "MyOffice",
      "ingestionIds": [
        {
          "metricId": "7c40cc50-aa51-4eb2-8937-71ce62798f17",
          "deriveIngestionId": false,
          "ingestionId": "MyIngestionId"
        },
        {
          "metricId": "7f43ba7b-2c80-4e4f-b2b6-4f7fecd0311",
          "deriveIngestionId": true,
          "ingestionId": "MyOffice$MetricId"
        }
      ],
      "properties": [
        {
          "typeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
          "valueId": "4204fbd0-d09b-4803-adc5-09dbbc448d30",
          "text": "Amsterdam"
        },
        {
          "typeId": "ade083a4-fb3a-490a-8025-312112066b79",
          "valueId": "dfff4f32-f2be-480e-8bb1-87d71d74aeb6",
          "location": {
            "lat": 51.9225,
            "lon": 4.47917,
            "alt": -5.2
          }
        }
      ]
    }
  ]
}

Get a subject

Fetch an existing subject.

Parameters

This endpoint takes no arguments.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjects/<SUBJECT_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
subject_id="f59ee376-ccec-40e1-8ebe-38bef7a30ac9"

curl "https://api.blockbax.com/v1/projects/${project_id}/subjects/${subject_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "id": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "parentSubjectId": "e2bbf958-9f60-4e67-97df-3f6e2c1c08a0",
  "name": "My house",
  "externalId": "MyHouse",
  "ingestionIds": [
    {
      "metricId": "7c40cc50-aa51-4eb2-8937-71ce62798f17",
      "deriveIngestionId": false,
      "ingestionId": "MyIngestionId"
    },
    {
      "metricId": "7f43ba7b-2c80-4e4f-b2b6-4f7fecd0311",
      "deriveIngestionId": true,
      "ingestionId": "MyHouse$MyTemperature"
    }
  ],
  "properties": [
    {
      "typeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "valueId": "4204fbd0-d09b-4803-adc5-09dbbc448d30",
      "text": "Rotterdam"
    },
    {
      "typeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "valueId": "2dcaa9cb-6d39-4997-a710-0f6ccabdb3e3",
      "caption": "Enum value five",
      "number": 5
    },
    {
      "typeId": "ade083a4-fb3a-490a-8025-312112066b79",
      "valueId": "f8c52571-b882-4bf0-b013-f38f9621e7b8",
      "location": {
        "lat": 52.37403,
        "lon": 4.88969,
        "alt": -3.2
      }
    },
    {
      "typeId": "d237162d-6da6-455e-8921-ba0c4bae4fc5",
      "valueId": "8a75002b-0c63-4fe8-afc0-2c05e428a76a",
      "mapLayer": {
        "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/d237162d-6da6-455e-8921-ba0c4bae4fc5/values/8a75002b-0c63-4fe8-afc0-2c05e428a76a/files/efa6753f-4981-417f-aabd-be0f43c6e4f6.png",
        "leftBottom": {
          "lat": 52.37403,
          "lon": 4.88969
        },
        "leftTop": {
          "lat": 52.37404,
          "lon": 4.88969
        },
        "rightBottom": {
          "lat": 52.37403,
          "lon": 4.8897
        },
        "rightTop": {
          "lat": 52.37404,
          "lon": 4.8897
        }
      }
    },
    {
      "typeId": "bae083a4-fb3a-490a-8025-312112066b66",
      "valueId": "a8c52571-b882-4bf0-b013-f38f9621e7b6",
      "image": {
        "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/bae083a4-fb3a-490a-8025-312112066b66/values/a8c52571-b882-4bf0-b013-f38f9621e7b6/files/ada6753f-4981-417f-aabd-be0f43c6e4c9.png"
      }
    },
    {
      "typeId": "dee083a4-fb3a-490a-8025-312112066b11",
      "valueId": "c4c52571-b882-4bf0-b013-f38f9621e7d8",
      "area": {
        "polygon": {
          "outerRing": [
            {
              "lat": 52.37404,
              "lon": 4.88969
            },
            {
              "lat": 51.37404,
              "lon": 3.88969
            },
            {
              "lat": 52.37404,
              "lon": 2.88969
            },
            {
              "lat": 52.37404,
              "lon": 4.88969
            }
          ]
        }
      }
    },
    {
      "typeId": "fc13e380-aee1-46c3-a125-2a7831b6d492",
      "valueId": "dc93a95c-7bc4-4e91-a36c-97f17ba0c9ef",
      "inherit": true,
      "text": "I inherited this value from my parent subject"
    }
  ]
}

Create or update a subject

Create a new subject or update an existing one.

Body

  • subjectTypeId[required]: Subject type that this subjects belongs to. Determines which subjects, property types and metrics are connected.
  • parentSubjectId: The ID of the parent subject of this subject. Required if the subject type has a parent subject type. Not allowed otherwise.
  • name[required]: The name of the subject.
  • ingestionIds[required]: For all connected ingested metrics, a list of ingestion IDs that are either custom or automatically derived from the subject and metric external id.
  • properties : The properties of this subject. When adding values, either the value ID must be filled (for an existing value) or a text, number, location, map layer, image or area must be given (to create one). Creating values directly from a subject is only possible if predefinedValues = false for that property type. See propertyTypes for a more detailed description of the various data types.
    • inherit : Inherit the property value from its parent subject. This can only be specified for property types that are present in the parent’s subject type. When creating subjects not specified property values are inherited by default if possible.
  • externalId[required]: The external ID of the subject. This can be used when sending measurements to avoid the source systems (e.g. sensors) need to know which IDs are internally used in the Blockbax Platform.

HTTP Request

Create
POST https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjects

Update
PUT https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjects/<SUBJECT_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
subject_id="f59ee376-ccec-40e1-8ebe-38bef7a30ac9"

curl -X POST "https://api.blockbax.com/v1/projects/${project_id}/subjects"
or
curl -X PUT "https://api.blockbax.com/v1/projects/${project_id}/subjects/${subject_id}"
  -H "Authorization: ApiKey ${api_key}"
  -H "Content-Type: application/json"
  -d '{
        "name": "My house",
        "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
        "parentSubjectId": "e2bbf958-9f60-4e67-97df-3f6e2c1c08a0",
        "externalId": "MyHouse",
        "ingestionIds": [
          {
            "metricId": "7c40cc50-aa51-4eb2-8937-71ce62798f17",
            "deriveIngestionId": false,
            "ingestionId": "MyIngestionId"
          },
          {
            "metricId": "7f43ba7b-2c80-4e4f-b2b6-4f7fecd0311",
            "deriveIngestionId": true
          }
        ],
        "properties": [
          {
            "typeId": "b04fe3ba-02d2-45cd-8359-d3211d77685f",
            "text": "MyValue"
          },
          {
            "typeId": "34a50cb8-517c-43fb-9397-b0159e5c692e",
            "valueId" : "861d2845-e90a-473b-954f-19965277fce4"
          },
          {
            "typeId": "34a50cb8-517c-43fb-9397-b0159e5c692e",
            "location": {
              "lat": 30.2, "lon": 20.25, "alt": 0.25
            }
          },
          {
            "typeId": "d237162d-6da6-455e-8921-ba0c4bae4fc5",
            "mapLayer": {
              "imagePath" : "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/d237162d-6da6-455e-8921-ba0c4bae4fc5/values/8a75002b-0c63-4fe8-afc0-2c05e428a76a/files/efa6753f-4981-417f-aabd-be0f43c6e4f6.png",
              "leftBottom" : {
                "lat": 52.37403, "lon": 4.88969
              },
              "leftTop" : {
                "lat": 52.37404, "lon": 4.88969
              },
              "rightBottom" : {
                "lat": 52.37403, "lon": 4.88970
              },
              "rightTop" : {
                "lat": 52.37404, "lon": 4.88970
              }
            }
          },
          {
            "typeId": "bae083a4-fb3a-490a-8025-312112066b66",
            "image": {
              "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/bae083a4-fb3a-490a-8025-312112066b66/values/a8c52571-b882-4bf0-b013-f38f9621e7b6/files/ada6753f-4981-417f-aabd-be0f43c6e4c9.png"
            }
          },
          {
            "typeId": "fc13e380-aee1-46c3-a125-2a7831b6d492",
            "inherit": true
          }
        ]
      }'

Example response

{
  "id": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "parentSubjectId": "e2bbf958-9f60-4e67-97df-3f6e2c1c08a0",
  "name": "My house",
  "externalId": "MyHouse",
  "ingestionIds": [
    {
      "metricId": "7c40cc50-aa51-4eb2-8937-71ce62798f17",
      "deriveIngestionId": false,
      "ingestionId": "MyIngestionId"
    },
    {
      "metricId": "7f43ba7b-2c80-4e4f-b2b6-4f7fecd0311",
      "deriveIngestionId": true,
      "ingestionId": "MyHouse$MetricId"
    }
  ],
  "properties": [
    {
      "typeId": "b04fe3ba-02d2-45cd-8359-d3211d77685f",
      "valueId": "ad80f927-2f40-405d-aed6-9a8f9b91f82a",
      "text": "MyValue"
    },
    {
      "typeId": "34a50cb8-517c-43fb-9397-b0159e5c692e",
      "valueId": "861d2845-e90a-473b-954f-19965277fce4",
      "location": {
        "lat": 30.2,
        "lon": 20.25,
        "alt": 0.25
      }
    },
    {
      "typeId": "d237162d-6da6-455e-8921-ba0c4bae4fc5",
      "valueId": "8a75002b-0c63-4fe8-afc0-2c05e428a76a",
      "mapLayer": {
        "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/d237162d-6da6-455e-8921-ba0c4bae4fc5/values/8a75002b-0c63-4fe8-afc0-2c05e428a76a/files/efa6753f-4981-417f-aabd-be0f43c6e4f6.png",
        "leftBottom": {
          "lat": 52.37403,
          "lon": 4.88969
        },
        "leftTop": {
          "lat": 52.37404,
          "lon": 4.88969
        },
        "rightBottom": {
          "lat": 52.37403,
          "lon": 4.8897
        },
        "rightTop": {
          "lat": 52.37404,
          "lon": 4.8897
        }
      }
    },
    {
      "typeId": "bae083a4-fb3a-490a-8025-312112066b66",
      "valueId": "a8c52571-b882-4bf0-b013-f38f9621e7b6",
      "image": {
        "imagePath": "/projects/715b6935-e3d8-48b1-86a3-a6e2a268e1f/propertyTypes/bae083a4-fb3a-490a-8025-312112066b66/values/a8c52571-b882-4bf0-b013-f38f9621e7b6/files/ada6753f-4981-417f-aabd-be0f43c6e4c9.png"
      }
    },
    {
      "typeId": "fc13e380-aee1-46c3-a125-2a7831b6d492",
      "valueId": "dc93a95c-7bc4-4e91-a36c-97f17ba0c9ef",
      "inherit": true,
      "text": "I inherited this value from my parent subject"
    }
  ]
}

Delete a subject

Delete an existing subject.

Parameters

This endpoint takes no arguments.

HTTP Request

DELETE https://api.blockbax.com/v1/projects/<PROJECT_ID>/subjects/<SUBJECT_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
subject_id="f59ee376-ccec-40e1-8ebe-38bef7a30ac9"

curl -X DELETE "https://api.blockbax.com/v1/projects/${project_id}/subjects/${subject_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{}

Metrics

This endpoint allows you to programmatically create, update, delete and query metrics.

Search metrics

Search and filter metrics. Results are paginated with a maximum of 200 results at a time.

Parameters

  • name [optional, default=None]: Filter metrics by name.
  • metricIds [optional, default=None]: Comma-separated list of metric IDs.
  • subjectTypeIds [optional, default=None]: Comma-separated list of subject type IDs.
  • externalId [optional, default=None]: Filter metrics by external ID.
  • page [optional, default=0]: The page to fetch.
  • size [optional, default=20]: The page size. Max 200.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/metrics

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}/metrics"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "count": 2,
  "result": [
    {
      "id": "7c40cc50-aa51-4eb2-8937-71ce62798f17",
      "createdDate": "2021-01-24T15:00:01.946+0000",
      "updatedDate": "2021-01-24T15:05:02.124+0000",
      "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "name": "Temperature living room",
      "dataType": "NUMBER",
      "unit": "°C",
      "precision": 2,
      "visible": true,
      "type": "INGESTED",
      "discrete": false,
      "preferredColor": "#2fc177",
      "externalId": "LivingRoomTemperature",
      "mappingLevel": "OWN"
    },
    {
      "id": "7f43ba7b-2c80-4e4f-b2b6-4f7fecd03116",
      "createdDate": "2021-01-24T15:00:01.946+0000",
      "updatedDate": "2021-01-24T15:05:02.124+0000",
      "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "name": "Humidity living room",
      "dataType": "NUMBER",
      "unit": "%",
      "precision": 2,
      "visible": true,
      "type": "INGESTED",
      "discrete": false,
      "preferredColor": "#2fc177",
      "externalId": "LivingRoomHumidity",
      "mappingLevel": "CHILD"
    }
  ]
}

Get a metric

Fetch an existing metric.

Parameters

This endpoint takes no arguments.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/metrics/<METRIC_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
metric_id="7c40cc50-aa51-4eb2-8937-71ce62798f17"

curl "https://api.blockbax.com/v1/projects/${project_id}/metrics/${metric_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "id": "7c40cc50-aa51-4eb2-8937-71ce62798f17",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "name": "Temperature living room",
  "dataType": "NUMBER",
  "unit": "°C",
  "precision": 2,
  "visible": true,
  "type": "INGESTED",
  "discrete": false,
  "preferredColor": "#2fc177",
  "externalId": "LivingRoomTemperature",
  "mappingLevel": "OWN"
}

Create or update a metric

Create a new metric or update an existing one.

Body

  • subjectTypeId[required]: Subject type that this metric belongs to. Determines which subjects, property types and metrics are connected.
  • name[required]: The name of the metric.
  • dataType [required]: The data type of the metric. Choose from: NUMBER, LOCATION or TEXT.
  • unit : The unit of the metric.
  • precision : The precision to show in the web app for the metric, from 0 to 8.
  • visible : Whether this metric is visible in the web app.
  • type [required]: The type of the metric. Currently, only the INGESTED type is supported.
  • discrete: Whether this metric has discrete values. This is used by the web app to optimize visualization.
  • preferredColor: The preferred color that the metric should be displayed as. This is used by the web app to optimize visualization. Has to be in hex format (with a #).
  • externalId[required]: The external ID of the metric. This can be used when sending measurements to avoid that the source systems (e.g. sensors) need to know which IDs are internally used in the Blockbax Platform.
  • mappingLevel[required]: The level on which the ingestion ID mappings are set. Choose from: OWN or CHILD. In most cases the ingestion ID for a metric is configured on the type’s own level, meaning at the subjects containing the metric. However, in some cases it might be useful to do this at child level. If ingestion IDs are derived from the external IDs of a subject and a metric, this makes it possible to move a subject to another parent without having to update the ingestion ID.

HTTP Request

Create
POST https://api.blockbax.com/v1/projects/<PROJECT_ID>/metrics

Update
PUT https://api.blockbax.com/v1/projects/<PROJECT_ID>/metrics/<METRIC_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
metric_id="7c40cc50-aa51-4eb2-8937-71ce62798f17"

curl -X POST "https://api.blockbax.com/v1/projects/${project_id}/metrics"
or
curl -X PUT "https://api.blockbax.com/v1/projects/${project_id}/metrics/${metric_id}"
  -H "Authorization: ApiKey ${api_key}"
  -H "Content-Type: application/json"
  -d '{
        "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
        "name": "Temperature living room",
        "dataType": "NUMBER",
        "unit": "°C",
        "precision": 2,
        "visible": true,
        "type": "INGESTED",
        "discrete": false,
        "preferredColor": "#2FC177",
        "externalId": "LivingRoomTemperature",
        "mappingLevel": "OWN"
      }'

Example response

{
  "id": "e2e5a8e4-ac23-4821-8ab7-18f994ec674d",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "name": "Temperature living room",
  "dataType": "NUMBER",
  "unit": "°C",
  "precision": 2,
  "visible": true,
  "subjectTypeId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "type": "INGESTED",
  "discrete": false,
  "preferredColor": "#2fc177",
  "externalId": "LivingRoomTemperature",
  "mappingLevel": "OWN"
}

Delete a metric

Delete an existing metric.

Parameters

This endpoint takes no arguments.

HTTP Request

DELETE https://api.blockbax.com/v1/projects/<PROJECT_ID>/metrics/<METRIC_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
metric_id="7c40cc50-aa51-4eb2-8937-71ce62798f17"

curl -X DELETE "https://api.blockbax.com/v1/projects/${project_id}/metrics/${metric_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{}

Event Triggers

This endpoint allows you to programmatically create, update, delete and query event triggers.

Search event triggers

Search and filter event triggers. Results are paginated with a maximum of 200 results at a time.

Parameters

  • name [optional, default=None]: Filter event triggers by name.
  • page [optional, default=0]: The page to fetch.
  • size [optional, default=20]: The page size. Max 200.

Note

At the moment the deprecated fields latestVersion and archived are included in the response for backward compatibility. Please do not use these fields, they will be removed in the near future.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/eventTriggers

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}/eventTriggers"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "count": 1,
  "result": [
    {
      "id": "68d64e04-a44d-4ab8-80da-68ad87f976f2",
      "createdDate": "2021-01-12T10:51:19.114+00:00",
      "subjectTypeId": "50ebe3b6-c2e9-45d0-9540-f7a920571148",
      "name": "Event trigger with various condition examples",
      "version": 1,
      "active": true,
      "evaluationTrigger": "SUBJECT_METRICS",
      "evaluationConstraint": "ALL_TIMESTAMPS_MATCH",
      "eventRules": [
        {
          "eventLevel": "PROBLEM",
          "conditionSets": [
            {
              "description": "threshold with times",
              "id": "7c2d3848-58fa-4f5d-989c-557d03469cda",
              "inputConditions": [
                {
                  "type": "THRESHOLD",
                  "leftOperand": {
                    "type": "METRIC",
                    "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc",
                    "aggregation": {
                      "function": "AVG",
                      "period": {
                        "unit": "SECOND",
                        "amount": 2
                      }
                    }
                  },
                  "comparisonOperator": "GREATER_THAN",
                  "rightOperand": {
                    "type": "STATIC_VALUE",
                    "number": 10.5
                  }
                }
              ],
              "durationCondition": {
                "period": {
                  "unit": "MILLISECOND",
                  "amount": 1500
                }
              },
              "occurrenceCondition": {
                "occurrences": 42,
                "period": {
                  "unit": "MINUTE",
                  "amount": 2
                }
              },
              "dayTimeCondition": {
                "TUESDAY": [
                  {
                    "fromTime": "06:00",
                    "toTime": "23:00"
                  }
                ],
                "MONDAY": [
                  {
                    "fromTime": "10:00",
                    "toTime": "12:00"
                  },
                  {
                    "fromTime": "13:30",
                    "toTime": "16:45"
                  }
                ]
              }
            },
            {
              "description": "metric 2 less than",
              "id": "8fab9ba3-82c2-4f0d-8f96-9f84896e77dd",
              "inputConditions": [
                {
                  "type": "THRESHOLD",
                  "leftOperand": {
                    "type": "METRIC",
                    "id": "d2f3fb22-75e1-4506-9c6b-80c6f4357f39"
                  },
                  "comparisonOperator": "LESS_THAN",
                  "rightOperand": {
                    "type": "STATIC_VALUE",
                    "number": 15
                  }
                }
              ]
            },
            {
              "description": "metric 3 contains",
              "id": "1fab9ba3-82c2-4f0d-8f96-9f84896e77de",
              "inputConditions": [
                {
                  "type": "TEXT_MATCH",
                  "leftOperand": {
                    "type": "METRIC",
                    "id": "a2f3fb22-75e1-4506-9c6b-80c6f4357f33"
                  },
                  "comparisonOperator": "CONTAINS",
                  "rightOperand": {
                    "type": "STATIC_VALUE",
                    "text": "alarmStatus10"
                  }
                }
              ]
            },
            {
              "description": "metric 4 distance to property type less than static value",
              "id": "a79012a7-d691-49ad-9a2b-178b6113db94",
              "inputConditions": [
                {
                  "type": "THRESHOLD",
                  "leftOperand": {
                    "type": "CALCULATION",
                    "leftOperand": {
                      "leftOperand": {
                        "type": "METRIC",
                        "id": "e96b26f1-11a1-4dc2-b9f1-b513a17b27bc"
                      },
                      "arithmeticOperator": "DISTANCE",
                      "rightOperand": {
                        "type": "PROPERTY_TYPE",
                        "id": "19fb1502-d46a-4681-8930-376c51c9e4c5"
                      }
                    }
                  },
                  "comparisonOperator": "LESS_THAN",
                  "rightOperand": {
                    "type": "STATIC_VALUE",
                    "number": 100
                  }
                }
              ]
            },
            {
              "description": "metric 5 location in property type area",
              "id": "a79012a7-d691-49ad-9a2b-178b6113db94",
              "inputConditions": [
                {
                  "type": "GEOFENCE",
                  "leftOperand": {
                    "type": "PROPERTY_TYPE",
                    "id": "4b4e9376-c534-4846-bac2-f4b4ea6aa82f"
                  },
                  "arithmeticOperator": "CONTAINS",
                  "rightOperand": {
                    "type": "METRIC",
                    "id": "3816ff23-70f8-479c-a5e7-4bb77a2a5320"
                  }
                }
              ]
            }
          ]
        },
        {
          "eventLevel": "WARNING",
          "conditionSets": [
            {
              "description": "change condition and mixed condition",
              "id": "b7c667de-3fb6-47d3-88ee-0bfbb7d7756a",
              "inputConditions": [
                {
                  "type": "THRESHOLD",
                  "leftOperand": {
                    "type": "STATIC_VALUE",
                    "number": 10.6
                  },
                  "comparisonOperator": "EQUALS",
                  "rightOperand": {
                    "type": "PROPERTY_TYPE",
                    "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
                  }
                },
                {
                  "leftOperand": {
                    "type": "VALUE_CHANGE",
                    "arithmeticOperator": "DIFFERENCE",
                    "leftOperand": {
                      "type": "METRIC",
                      "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc"
                    },
                    "rightOperand": {
                      "type": "METRIC",
                      "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc",
                      "offset": {
                        "type" : "PREVIOUS_VALUE"
                      }
                    }
                  },
                  "comparisonOperator": "EQUALS",
                  "rightOperand": {
                    "type": "PROPERTY_TYPE",
                    "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
                  }
                }
              ]
            }
          ]
        },
        {
          "eventLevel": "INFORMATION",
          "conditionSets": [
            {
              "description": "calculation",
              "id": "c7042dd3-7396-4626-9ada-2f39a5e173d7",
              "inputConditions": [
                {
                  "type": "THRESHOLD",
                  "leftOperand": {
                    "type": "CALCULATION",
                    "arithmeticOperator": "DIVISION",
                    "leftOperand": {
                      "type": "METRIC",
                      "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc"
                    },
                    "rightOperand": {
                      "type": "STATIC_VALUE",
                      "number": 99.5
                    }
                  },
                  "comparisonOperator": "LESS_THAN_OR_EQUALS",
                  "rightOperand": {
                    "type": "PROPERTY_TYPE",
                    "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
                  }
                }
              ]
            }
          ]
        }
      ],
      "subjectFilter": {
        "include": {
          "subjectIds": [
            "9eb8319b-f474-4eda-9de3-4169ddf9c607",
            "125b8167-eb00-4402-8fea-7406d4b5b295"
          ],
          "propertyValues": null
        },
        "exclude": null
      }
    }
  ]
}

Get an event trigger

Fetch an existing event trigger.

Parameters

This endpoint takes no arguments.

Note

At the moment the deprecated fields latestVersion and archived are included in the response for backward compatibility. Please do not use these fields, they will be removed in the near future.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/eventTriggers/<EVENT_TRIGGER_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
event_trigger_id="68d64e04-a44d-4ab8-80da-68ad87f976f2"

curl "https://api.blockbax.com/v1/projects/${project_id}/eventTriggers/${event_trigger_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "id": "68d64e04-a44d-4ab8-80da-68ad87f976f2",
  "createdDate": "2021-01-12T10:51:19.114+00:00",
  "subjectTypeId": "50ebe3b6-c2e9-45d0-9540-f7a920571148",
  "name": "Event trigger with various condition examples",
  "version": 1,
  "active": true,
  "evaluationTrigger": "SUBJECT_METRICS",
  "evaluationConstraint": "ALL_TIMESTAMPS_MATCH",
  "eventRules": [
    {
      "eventLevel": "PROBLEM",
      "conditionSets": [
        {
          "description": "threshold with times",
          "id": "7c2d3848-58fa-4f5d-989c-557d03469cda",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "METRIC",
                "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc",
                "aggregation": {
                  "function": "AVG",
                  "period": {
                    "unit": "SECOND",
                    "amount": 2
                  }
                }
              },
              "comparisonOperator": "GREATER_THAN",
              "rightOperand": {
                "type": "STATIC_VALUE",
                "number": 10.5
              }
            }
          ],
          "durationCondition": {
            "period": {
              "unit": "MILLISECOND",
              "amount": 1500
            }
          },
          "occurrenceCondition": {
            "occurrences": 42,
            "period": {
              "unit": "MINUTE",
              "amount": 2
            }
          },
          "dayTimeCondition": {
            "TUESDAY": [
              {
                "fromTime": "06:00",
                "toTime": "23:00"
              }
            ],
            "MONDAY": [
              {
                "fromTime": "10:00",
                "toTime": "12:00"
              },
              {
                "fromTime": "13:30",
                "toTime": "16:45"
              }
            ]
          }
        },
        {
          "description": "metric 2 less than",
          "id": "8fab9ba3-82c2-4f0d-8f96-9f84896e77dd",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "METRIC",
                "id": "d2f3fb22-75e1-4506-9c6b-80c6f4357f39",
                "aggregation": {
                  "function": "AVG",
                  "period": {
                    "unit": "SECOND",
                    "amount": 2
                  }
                }
              },
              "comparisonOperator": "LESS_THAN",
              "rightOperand": {
                "type": "STATIC_VALUE",
                "number": 15
              }
            }
          ]
        },
        {
          "description": "metric 3 contains",
          "id": "1fab9ba3-82c2-4f0d-8f96-9f84896e77de",
          "inputConditions": [
            {
              "type": "TEXT_MATCH",
              "leftOperand": {
                "type": "METRIC",
                "id": "a2f3fb22-75e1-4506-9c6b-80c6f4357f33"
              },
              "comparisonOperator": "CONTAINS",
              "rightOperand": {
                "type": "STATIC_VALUE",
                "text": "alarmStatus10"
              }
            }
          ]
        },
        {
          "description": "metric 4 distance to property type less than static value",
          "id": "a79012a7-d691-49ad-9a2b-178b6113db94",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "CALCULATION",
                "leftOperand": {
                  "leftOperand": {
                    "type": "METRIC",
                    "id": "e96b26f1-11a1-4dc2-b9f1-b513a17b27bc"
                  },
                  "arithmeticOperator": "DISTANCE",
                  "rightOperand": {
                    "type": "PROPERTY_TYPE",
                    "id": "19fb1502-d46a-4681-8930-376c51c9e4c5"
                  }
                }
              },
              "comparisonOperator": "LESS_THAN",
              "rightOperand": {
                "type": "STATIC_VALUE",
                "number": 100
              }
            }
          ]
        },
        {
          "description": "metric 5 location in property type area",
          "id": "a79012a7-d691-49ad-9a2b-178b6113db94",
          "inputConditions": [
            {
              "type": "GEOFENCE",
              "leftOperand": {
                "type": "PROPERTY_TYPE",
                "id": "4b4e9376-c534-4846-bac2-f4b4ea6aa82f"
              },
              "arithmeticOperator": "CONTAINS",
              "rightOperand": {
                "type": "METRIC",
                "id": "3816ff23-70f8-479c-a5e7-4bb77a2a5320"
              }
            }
          ]
        }
      ]
    },
    {
      "eventLevel": "WARNING",
      "conditionSets": [
        {
          "description": "change condition and mixed condition",
          "id": "b7c667de-3fb6-47d3-88ee-0bfbb7d7756a",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "STATIC_VALUE",
                "number": 10.6
              },
              "comparisonOperator": "EQUALS",
              "rightOperand": {
                "type": "PROPERTY_TYPE",
                "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
              }
            },
            {
              "leftOperand": {
                "type": "VALUE_CHANGE",
                "arithmeticOperator": "DIFFERENCE",
                "leftOperand": {
                  "type": "METRIC",
                  "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc"
                },
                "rightOperand": {
                  "type": "METRIC",
                  "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc",
                  "offset": {
                    "type" : "PREVIOUS_VALUE"
                  }
                }
              },
              "comparisonOperator": "EQUALS",
              "rightOperand": {
                "type": "PROPERTY_TYPE",
                "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
              }
            }
          ]
        }
      ]
    },
    {
      "eventLevel": "INFORMATION",
      "conditionSets": [
        {
          "description": "calculation",
          "id": "c7042dd3-7396-4626-9ada-2f39a5e173d7",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "CALCULATION",
                "arithmeticOperator": "DIVISION",
                "leftOperand": {
                  "type": "METRIC",
                  "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc"
                },
                "rightOperand": {
                  "type": "STATIC_VALUE",
                  "number": 99.5
                }
              },
              "comparisonOperator": "LESS_THAN_OR_EQUALS",
              "rightOperand": {
                "type": "PROPERTY_TYPE",
                "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
              }
            }
          ]
        }
      ]
    }
  ],
  "subjectFilter": {
    "include": {
      "subjectIds": [
        "9eb8319b-f474-4eda-9de3-4169ddf9c607",
        "125b8167-eb00-4402-8fea-7406d4b5b295"
      ],
      "propertyValues": null
    },
    "exclude": null
  }
}

Create or update an event trigger

Create a new event trigger or update an existing one.

Body

  • name [required]: The name of the event trigger.
  • subjectTypeId [required]: The ID of the subject type this event trigger is for.
  • active [required]: Whether this event trigger is active.
  • evaluationTrigger [required]: Determines when the event trigger is evaluated. Choose from: INPUT_METRICS (when a measurement for a metric used by the trigger is received) or SUBJECT_METRICS (when any measurement for the subject is received).
  • evaluationConstraint [required]: Further constraints when the event trigger is evaluated. Choose from: NONE (always evaluate using latest measurements, please be aware late arrivals are ignored) or ALL_TIMESTAMPS_MATCH (evaluate only when all non-aggregated inputs have measurements for the respective timestamp).
  • subjectFilter: Filter of subjects for which this event trigger will generate events.
    • include : Included subjects and/or properties.
      • subjectIds : Included subject IDs.
      • propertyValues : Included property values. When multiple types are specified a subject must contain a value of each type in order to qualify (AND logic).
        • typeId : The property type ID.
        • valueIds : All the property value IDs for this property type.
    • exclude : Excluded subjects and/or properties.
      • subjectIds : Excluded subject IDs.
      • propertyValues : Excluded property values. When multiple types are specified a subject must contain a value of any type in order to qualify (OR logic).
        • typeId : The property type ID.
        • valueIds : All the property value IDs for this property type.
  • eventRules [required]: List of event rules that will be applied.
    • eventLevel [required]: Event level of the rule. Choose from: OK,INFORMATION,WARNING or PROBLEM.
    • conditionSets [required]: The condition sets for this rule.
      • id : Only when updating a condition set, the ID of the condition set that must be updated. If left empty this will be considered a new condition set, meaning new events won’t share the same condition set ID even if the condition set is similar.
      • description [required]: The description of this condition set.
      • inputConditions: The input conditions.
        • type [required]: The type of this condition. Choose from: THRESHOLD, TEXT_MATCH or GEOFENCE. THRESHOLD includes change conditions as seen in the client.
        • leftOperand [required]: Left operand of this condition.
          • type [required]: Type of this operand. Choose from: METRIC, PROPERTY_TYPE, STATIC_VALUE, VALUE_CHANGE or CALCULATION.
          • id : The ID of the metric or property type for their respective operand types. These metrics or property types should be of data type NUMBER for THRESHOLD conditions, of data type TEXT for TEXT_MATCH conditions and of data type LOCATION or AREA for GEOFENCE conditions. For a COUNT aggregation in a THRESHOLD condition you can use any metric data type.
          • number : The number for a static value operand, for THRESHOLD conditions.
          • text : The text for a static value operand, for TEXT_MATCH conditions.
          • location : The location for a static value operand, for right operands in GEOFENCE conditions, and calculation operands with a DISTANCE arithmetic operator within THRESHOLD conditions.
          • area : The area for a static value operand, for left operands in GEOFENCE conditions, and calculation operands with a DISTANCE arithmetic operator within THRESHOLD conditions.
          • aggregation : Only allowed for the METRIC operand, and only for metric data type NUMBER unless the aggregation is COUNT.
            • function : Choose from: MIN, MAX, SUM, COUNT or AVG.
            • period [required]: Period.
              • unit [required]: Period unit. Choose from: MILLISECOND, SECOND, MINUTE, HOUR, DAY or WEEK.
              • amount [required]: Period amount. Total should be a max of 1 week in whichever period unit.
          • leftOperand : Nested left operand for a calculation or value change operand. Nested calculations are currently not allowed.
          • arithmeticOperator : Arithmetic operator for calculation operand. Choose from: ADDITION, MULTIPLICATION, DIVISION, DISTANCE DIFFERENCE, ABSOLUTE_DIFFERENCE, PERCENTAGE_DIFFERENCE or ABSOLUTE_PERCENTAGE_DIFFERENCE. When using the VALUE_CHANGE operand, only the latter 4 may be used.
          • rightOperand : Nested right operand for a calculation or value change operand. Nested calculations are currently not allowed.
            • offset : When using the VALUE_CHANGE operand, this offset must be added.
              • type : Choose from: PREVIOUS_VALUE or PERIOD.
              • period : Period. Required when type is PERIOD.
                • unit [required]: Period unit. Choose from: MILLISECOND, SECOND, MINUTE, HOUR, DAY or WEEK.
                • amount [required]: Period amount. Total should be a max of 1 week in whichever period unit.
        • comparisonOperator [required]: Comparison operator of the condition. For THRESHOLD input conditions choose from: LESS_THAN, LESS_THAN_OR_EQUALS,EQUALS, NOT_EQUALS, GREATER_THAN_OR_EQUALS or GREATER_THAN. For TEXT_MATCH input conditions choose from: EQUALS, NOT_EQUALS, CONTAINS, NOT_CONTAINS, STARTS_WITH, NOT_STARTS_WITH, ENDS_WITH, NOT_ENDS_WITH, MATCHES_REGEX or NOT_MATCHES_REGEX. For GEOFENCE input conditions choose from: CONTAINS or NOT_CONTAINS.
        • rightOperand [required]: Right operand of this condition. Available properties are the same as for left operand.
      • durationCondition: Optional constraint for the minimum period that the comparison should be true.
        • period [required]: Period.
          • unit [required]: Period unit. Choose from: MILLISECOND, SECOND, MINUTE, HOUR, DAY or WEEK.
          • amount [required]: Period amount. Total should be a max of 1 week in whichever period unit.
      • occurrenceCondition: Optional constraint for the minimum amount of times that the comparison should be true within a specified period.
        • period [required]: Period.
          • unit [required]: Period unit. Choose from: MILLISECOND, SECOND, MINUTE, HOUR, DAY or WEEK.
          • amount [required]: Period amount. Total should be a max of 1 week in whichever period unit.
        • occurrences [required]: Minimum number of occurrences.
      • dayTimeCondition: Optional constraint at which day and time ranges the comparison should be true.
        • MONDAY: Day of the week. Choose from: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY or SUNDAY.
          • fromTime [required]: From time (e.g. 9:00).
          • toTime [required]: To time (e.g. 18:00).

HTTP Request

Create
POST https://api.blockbax.com/v1/projects/<PROJECT_ID>/eventTriggers

Update
PUT https://api.blockbax.com/v1/projects/<PROJECT_ID>/eventTriggers/<EVENT_TRIGGER_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
event_trigger_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl -X POST "https://api.blockbax.com/v1/projects/${project_id}/eventTriggers"
or
curl -X PUT "https://api.blockbax.com/v1/projects/${project_id}/eventTriggers/${event_trigger_id}"
  -H "Authorization: ApiKey ${api_key}"
  -H "Content-Type: application/json"
  -d '{
        "subjectTypeId": "50ebe3b6-c2e9-45d0-9540-f7a920571148",
        "name": "Event trigger with various condition examples",
        "active": true,
        "evaluationTrigger": "SUBJECT_METRICS",
        "evaluationConstraint": "ALL_TIMESTAMPS_MATCH",
        "eventRules": [
          {
            "eventLevel": "PROBLEM",
            "conditionSets": [
              {
                "description": "threshold with times",
                "inputConditions": [
                  {
                    "type": "THRESHOLD",
                    "leftOperand": {
                      "type": "METRIC",
                      "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc",
                      "aggregation": {
                        "function": "AVG",
                        "period": {
                          "unit": "SECOND",
                          "amount": 2
                        }
                      }
                    },
                    "comparisonOperator": "GREATER_THAN",
                    "rightOperand": {
                      "type": "STATIC_VALUE",
                      "number": 10.5
                    }
                  }
                ],
                "durationCondition": {
                  "period": {
                    "unit": "MILLISECOND",
                    "amount": 1500
                  }
                },
                "occurrenceCondition": {
                  "occurrences": 42,
                  "period": {
                    "unit": "MINUTE",
                    "amount": 2
                  }
                },
                "dayTimeCondition": {
                  "TUESDAY": [
                    {
                      "fromTime": "06:00",
                      "toTime": "23:00"
                    }
                  ],
                  "MONDAY": [
                    {
                      "fromTime": "10:00",
                      "toTime": "12:00"
                    },
                    {
                      "fromTime": "13:30",
                      "toTime": "16:45"
                    }
                  ]
                }
              },
              {
                "description": "metric 2 less than",
                "inputConditions": [
                  {
                    "type": "THRESHOLD",
                    "leftOperand": {
                      "type": "METRIC",
                      "id": "d2f3fb22-75e1-4506-9c6b-80c6f4357f39"
                    },
                    "comparisonOperator": "LESS_THAN",
                    "rightOperand": {
                      "type": "STATIC_VALUE",
                      "number": 15
                    }
                  }
                ]
              },
              {
                "description": "metric 3 contains",
                "inputConditions": [
                  {
                    "type": "TEXT_MATCH",
                    "leftOperand": {
                      "type": "METRIC",
                      "id": "a2f3fb22-75e1-4506-9c6b-80c6f4357f33"
                    },
                    "comparisonOperator": "CONTAINS",
                    "rightOperand": {
                      "type": "STATIC_VALUE",
                      "text": "alarmStatus10"
                    }
                  }
                ]
              },
              {
                "description": "metric 4 distance to property type less than static value",
                "inputConditions": [
                  {
                    "type": "THRESHOLD",
                    "comparisonOperator": "LESS_THAN",
                    "leftOperand": {
                      "type": "CALCULATION",
                      "arithmeticOperator": "DISTANCE",
                      "leftOperand": {
                        "type": "METRIC",
                        "id": "e96b26f1-11a1-4dc2-b9f1-b513a17b27bc"
                      },
                      "rightOperand": {
                        "type": "PROPERTY_TYPE",
                        "id": "19fb1502-d46a-4681-8930-376c51c9e4c5"
                      }
                    },
                    "rightOperand": {
                      "type": "STATIC_VALUE",
                      "number": 100
                    }
                  }
                ]
              },
              {
                "description": "metric 5 location in property type area",
                "inputConditions": [
                  {
                    "type": "GEOFENCE",
                    "leftOperand": {
                      "type": "PROPERTY_TYPE",
                      "id": "4b4e9376-c534-4846-bac2-f4b4ea6aa82f"
                    },
                    "comparisonOperator": "CONTAINS",
                    "rightOperand": {
                      "type": "METRIC",
                      "id": "3816ff23-70f8-479c-a5e7-4bb77a2a5320"
                    }
                  }
                ]
              }
            ]
          },
          {
            "eventLevel": "WARNING",
            "conditionSets": [
              {
                "description": "change condition and mixed condition",
                "inputConditions": [
                  {
                    "type": "THRESHOLD",
                    "leftOperand": {
                      "type": "STATIC_VALUE",
                      "number": 10.6
                    },
                    "comparisonOperator": "EQUALS",
                    "rightOperand": {
                      "type": "PROPERTY_TYPE",
                      "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
                    }
                  },
                  {
                    "type": "THRESHOLD",
                    "leftOperand": {
                      "type": "VALUE_CHANGE",
                      "arithmeticOperator": "DIFFERENCE",
                      "leftOperand": {
                        "type": "METRIC",
                        "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc"
                      },
                      "rightOperand": {
                        "type": "METRIC",
                        "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc",
                        "offset": {
                          "type": "PREVIOUS_VALUE"
                        }
                      }
                    },
                    "comparisonOperator": "EQUALS",
                    "rightOperand": {
                      "type": "PROPERTY_TYPE",
                      "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
                    }
                  }
                ]
              }
            ]
          },
          {
            "eventLevel": "INFORMATION",
            "conditionSets": [
              {
                "description": "calculation",
                "inputConditions": [
                  {
                    "type": "THRESHOLD",
                    "leftOperand": {
                      "type": "CALCULATION",
                      "arithmeticOperator": "DIVISION",
                      "leftOperand": {
                        "type": "METRIC",
                        "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc"
                      },
                      "rightOperand": {
                        "type": "STATIC_VALUE",
                        "number": 99.5
                      }
                    },
                    "comparisonOperator": "LESS_THAN_OR_EQUALS",
                    "rightOperand": {
                      "type": "PROPERTY_TYPE",
                      "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
                    }
                  }
                ]
              }
            ]
          }
        ],
        "subjectFilter": {
          "include": {
            "subjectIds": [
              "9eb8319b-f474-4eda-9de3-4169ddf9c607",
              "125b8167-eb00-4402-8fea-7406d4b5b295"
            ],
            "propertyValues": null
          },
          "exclude": null
        }
      }'

Example response

{
  "id": "68d64e04-a44d-4ab8-80da-68ad87f976f2",
  "createdDate": "2021-01-12T10:51:19.114+00:00",
  "subjectTypeId": "50ebe3b6-c2e9-45d0-9540-f7a920571148",
  "name": "Event trigger with various condition examples",
  "version": 1,
  "active": true,
  "evaluationTrigger": "SUBJECT_METRICS",
  "evaluationConstraint": "ALL_TIMESTAMPS_MATCH",
  "eventRules": [
    {
      "eventLevel": "PROBLEM",
      "conditionSets": [
        {
          "description": "threshold with times",
          "id": "7c2d3848-58fa-4f5d-989c-557d03469cda",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "METRIC",
                "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc",
                "aggregation": {
                  "function": "AVG",
                  "period": {
                    "unit": "SECOND",
                    "amount": 2
                  }
                }
              },
              "comparisonOperator": "GREATER_THAN",
              "rightOperand": {
                "type": "STATIC_VALUE",
                "number": 10.5
              }
            }
          ],
          "durationCondition": {
            "period": {
              "unit": "MILLISECOND",
              "amount": 1500
            }
          },
          "occurrenceCondition": {
            "occurrences": 42,
            "period": {
              "unit": "MINUTE",
              "amount": 2
            }
          },
          "dayTimeCondition": {
            "TUESDAY": [
              {
                "fromTime": "06:00",
                "toTime": "23:00"
              }
            ],
            "MONDAY": [
              {
                "fromTime": "10:00",
                "toTime": "12:00"
              },
              {
                "fromTime": "13:30",
                "toTime": "16:45"
              }
            ]
          }
        },
        {
          "description": "metric 2 less than",
          "id": "8fab9ba3-82c2-4f0d-8f96-9f84896e77dd",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "METRIC",
                "id": "d2f3fb22-75e1-4506-9c6b-80c6f4357f39"
              },
              "comparisonOperator": "LESS_THAN",
              "rightOperand": {
                "type": "STATIC_VALUE",
                "number": 15
              }
            }
          ]
        },
        {
          "description": "metric 3 contains",
          "id": "1fab9ba3-82c2-4f0d-8f96-9f84896e77de",
          "inputConditions": [
            {
              "type": "TEXT_MATCH",
              "leftOperand": {
                "type": "METRIC",
                "id": "a2f3fb22-75e1-4506-9c6b-80c6f4357f33"
              },
              "comparisonOperator": "CONTAINS",
              "rightOperand": {
                "type": "STATIC_VALUE",
                "text": "alarmStatus10"
              }
            }
          ]
        },
        {
          "description": "metric 4 distance to property type less than static value",
          "id": "a79012a7-d691-49ad-9a2b-178b6113db94",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "CALCULATION",
                "leftOperand": {
                  "leftOperand": {
                    "type": "METRIC",
                    "id": "e96b26f1-11a1-4dc2-b9f1-b513a17b27bc"
                  },
                  "arithmeticOperator": "DISTANCE",
                  "rightOperand": {
                    "type": "PROPERTY_TYPE",
                    "id": "19fb1502-d46a-4681-8930-376c51c9e4c5"
                  }
                }
              },
              "comparisonOperator": "LESS_THAN",
              "rightOperand": {
                "type": "STATIC_VALUE",
                "number": 100
              }
            }
          ]
        },
        {
          "description": "metric 5 location in property type area",
          "id": "a79012a7-d691-49ad-9a2b-178b6113db94",
          "inputConditions": [
            {
              "type": "GEOFENCE",
              "leftOperand": {
                "type": "PROPERTY_TYPE",
                "id": "4b4e9376-c534-4846-bac2-f4b4ea6aa82f"
              },
              "arithmeticOperator": "CONTAINS",
              "rightOperand": {
                "type": "METRIC",
                "id": "3816ff23-70f8-479c-a5e7-4bb77a2a5320"
              }
            }
          ]
        }
      ]
    },
    {
      "eventLevel": "WARNING",
      "conditionSets": [
        {
          "description": "change condition and mixed condition",
          "id": "b7c667de-3fb6-47d3-88ee-0bfbb7d7756a",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "STATIC_VALUE",
                "number": 10.6
              },
              "comparisonOperator": "EQUALS",
              "rightOperand": {
                "type": "PROPERTY_TYPE",
                "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
              }
            },
            {
              "leftOperand": {
                "type": "VALUE_CHANGE",
                "arithmeticOperator": "DIFFERENCE",
                "leftOperand": {
                  "type": "METRIC",
                  "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc"
                },
                "rightOperand": {
                  "type": "METRIC",
                  "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc",
                  "offset": {
                    "type" : "PREVIOUS_VALUE"
                  }
                }
              },
              "comparisonOperator": "EQUALS",
              "rightOperand": {
                "type": "PROPERTY_TYPE",
                "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
              }
            }
          ]
        }
      ]
    },
    {
      "eventLevel": "INFORMATION",
      "conditionSets": [
        {
          "description": "calculation",
          "id": "c7042dd3-7396-4626-9ada-2f39a5e173d7",
          "inputConditions": [
            {
              "type": "THRESHOLD",
              "leftOperand": {
                "type": "CALCULATION",
                "arithmeticOperator": "DIVISION",
                "leftOperand": {
                  "type": "METRIC",
                  "id": "574fe135-ab2f-4df5-b640-a40b41d2e3dc"
                },
                "rightOperand": {
                  "type": "STATIC_VALUE",
                  "number": 99.5
                }
              },
              "comparisonOperator": "LESS_THAN_OR_EQUALS",
              "rightOperand": {
                "type": "PROPERTY_TYPE",
                "id": "1f68f53f-0505-4560-8e45-80f67abfeae3"
              }
            }
          ]
        }
      ]
    }
  ],
  "subjectFilter": {
    "include": {
      "subjectIds": [
        "9eb8319b-f474-4eda-9de3-4169ddf9c607",
        "125b8167-eb00-4402-8fea-7406d4b5b295"
      ],
      "propertyValues": null
    },
    "exclude": null
  }
}

Delete an event trigger

Delete an existing event trigger.

Parameters

This endpoint takes no arguments.

HTTP Request

DELETE https://api.blockbax.com/v1/projects/<PROJECT_ID>/eventTriggers/<EVENT_TRIGGER_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
event_trigger_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl -X DELETE "https://api.blockbax.com/v1/projects/${project_id}/eventTriggers/${event_trigger_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{}

Webhooks

These endpoints allows you to programmatically create, update, delete and query webhook settings as well as query the webhook responses.

Search webhook settings

Search and filter webhook settings. Results are paginated with a maximum of 200 results at a time.

Parameters

  • name [optional, default=None]: Filter webhook settings by name.
  • page [optional, default=0]: The page to fetch.
  • size [optional, default=20]: The page size. Max 200.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/webhookSettings

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}/webhookSettings"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "count": 1,
  "result": [
    {
      "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "createdDate": "2021-01-24T15:00:01.946+0000",
      "updatedDate": "2021-01-24T15:05:02.124+0000",
      "name": "Euro endpoint",
      "active": true,
      "endpoint": "https://euro.endpoint.com",
      "authorizationHeader": "Bearer SecretToken",
      "subjectFilter": {
        "include": {
          "subjectIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"],
          "propertyValues": [
            {
              "typeId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
              "valueIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"]
            }
          ]
        },
        "exclude": {
          "subjectIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"],
          "propertyValues": [
            {
              "typeId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
              "valueIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"]
            }
          ]
        }
      },
      "eventTriggerFilter": {
        "type": "EXCLUDE",
        "ids": ["1ba262d2-2627-4cf8-adc8-d2d36f693132"]
      },
      "eventLevelFilter": ["WARNING", "PROBLEM"]
    }
  ]
}

Get a webhook setting

Fetch an existing webhook setting.

Parameters

This endpoint takes no arguments.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/webhookSettings/<WEBHOOK_SETTING_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
webhook_setting_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl "https://api.blockbax.com/v1/projects/${project_id}/webhookSettings/${webhook_setting_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "name": "Euro endpoint",
  "active": true,
  "endpoint": "https://euro.endpoint.com",
  "authorizationHeader": "Bearer SecretToken",
  "subjectFilter": {
    "include": {
      "subjectIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"],
      "propertyValues": [
        {
          "typeId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
          "valueIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"]
        }
      ]
    },
    "exclude": {
      "subjectIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"],
      "propertyValues": [
        {
          "typeId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
          "valueIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"]
        }
      ]
    }
  },
  "eventTriggerFilter": {
    "type": "EXCLUDE",
    "ids": ["1ba262d2-2627-4cf8-adc8-d2d36f693132"]
  },
  "eventLevelFilter": ["WARNING", "PROBLEM"]
}

Create or update a webhook setting

Create a new webhook setting or update an existing one.

Body

  • name [required]: The name of the webhook setting.
  • active [required]: Whether the webhook setting is active.
  • endpoint [required]: The endpoint which is called.
  • authorizationHeader: The authorization header that will be passed along with the webhook calls.
  • subjectFilter: Filter of subjects for which this webhook will receive events.
    • include : Included subjects and/or properties.
      • subjectIds : Included subject IDs.
      • propertyValues : Included property values. When multiple types are specified a subject must contain a value of each type in order to qualify (AND logic).
        • typeId : The property type ID.
        • valueIds : All the property value IDs for this property type.
    • exclude : Excluded subjects and/or properties.
      • subjectIds : Excluded subject IDs.
      • propertyValues : Excluded property values. When multiple types are specified a subject must contain a value of any type in order to qualify (OR logic).
        • typeId : The property type ID.
        • valueIds : All the property value IDs for this property type.
  • eventTriggerFilter: Filter of event triggers for which this webhook will receive events.
    • type [required]: Type of the filter. Choose from: INCLUDE or EXCLUDE.
    • ids [required]: The IDs for which this filter applies.
  • eventLevelFilter [required]: Filter of event levels for which this webhook will receive events. Choose from: OK,INFORMATION,WARNING and PROBLEM.

HTTP Request

Create
POST https://api.blockbax.com/v1/projects/<PROJECT_ID>/webhookSettings

Update
PUT https://api.blockbax.com/v1/projects/<PROJECT_ID>/webhookSettings/<WEBHOOK_SETTING_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
webhook_setting_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl -X POST "https://api.blockbax.com/v1/projects/${project_id}/webhookSettings"
or
curl -X PUT "https://api.blockbax.com/v1/projects/${project_id}/webhookSettings/${webhook_setting_id}"
  -H "Authorization: ApiKey ${api_key}"
  -H "Content-Type: application/json"
  -d '{
        "name": "Euro endpoint",
        "active": true,
        "endpoint": "https://euro.endpoint.com",
        "authorizationHeader": "Bearer SecretToken",
        "subjectFilter": {
          "include": {
            "subjectIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"],
            "propertyValues": [
              {
                "typeId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
                "valueIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"]
              }
            ]
          },
          "exclude": {
            "subjectIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"],
            "propertyValues": [
              {
                "typeId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
                "valueIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"]
              }
            ]
          }
        },
        "eventTriggerFilter": {
          "type": "EXCLUDE",
          "ids": ["1ba262d2-2627-4cf8-adc8-d2d36f693132"]
        },
        "eventLevelFilter": [
          "WARNING", "PROBLEM"
        ]
      }'

Example response

{
  "id": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "createdDate": "2021-01-24T15:00:01.946+0000",
  "updatedDate": "2021-01-24T15:05:02.124+0000",
  "name": "Euro endpoint",
  "active": true,
  "endpoint": "https://euro.endpoint.com",
  "authorizationHeader": "Bearer SecretToken",
  "subjectFilter": {
    "include": {
      "subjectIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"],
      "propertyValues": [
        {
          "typeId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
          "valueIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"]
        }
      ]
    },
    "exclude": {
      "subjectIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"],
      "propertyValues": [
        {
          "typeId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
          "valueIds": ["f59ee376-ccec-40e1-8ebe-38bef7a30ac9"]
        }
      ]
    }
  },
  "eventTriggerFilter": {
    "type": "EXCLUDE",
    "ids": ["1ba262d2-2627-4cf8-adc8-d2d36f693132"]
  },
  "eventLevelFilter": ["WARNING", "PROBLEM"]
}

Delete a webhook setting

Delete an existing webhook setting.

Parameters

This endpoint takes no arguments.

HTTP Request

DELETE https://api.blockbax.com/v1/projects/<PROJECT_ID>/webhookSettings/<WEBHOOK_SETTING_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
webhook_setting_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl -X DELETE "https://api.blockbax.com/v1/projects/${project_id}/webhookSettings/${webhook_setting_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{}

Search webhook responses

Search and filter webhook responses. Webhook responses are stored for 7 days. Results can be paged through by setting size and cursor.

Parameters

  • cursor [optional, default=None]: The cursor from what sequence number to start retrieving.
  • error [optional, default=None]: Whether to retrieve only responses where error is true or false.
  • order [optional, default=DESC]: The order of the response, on sequence number. Choose from: ASC, or DESC.
  • size [optional, default=None]: The page size.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/webhookSettings/<WEBHOOK_SETTING_ID>/webhookResponses

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
webhook_setting_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"

curl "https://api.blockbax.com/v1/projects/${project_id}/webhookSettings/${webhook_setting_id}/webhookResponses"
  -H "Authorization: ApiKey ${api_key}"

Example response

[
  {
    "webhookSettingId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
    "sequenceNumber": 10,
    "deliveryAttempt": 1,
    "date": "2021-01-24T15:05:02.124+0000",
    "statusCode": 200,
    "responseType": "OK_RESPONSE",
    "error": false,
    "eventId": "fe61694a-7490-47a3-a92f-4576cd5a0835"
  },
  {
    "webhookSettingId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
    "sequenceNumber": 11,
    "deliveryAttempt": 5,
    "date": "2021-01-24T15:10:02.124+0000",
    "statusCode": 404,
    "responseType": "ERROR_RESPONSE",
    "error": true,
    "eventId": "ef61694a-7490-47a3-a92f-4576cd5a3677"
  },
  {
    "webhookSettingId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
    "sequenceNumber": 12,
    "deliveryAttempt": 5,
    "date": "2021-01-24T15:15:02.124+0000",
    "responseType": "CONNECTION_ERROR",
    "error": true,
    "eventId": "ef61694a-7490-47a3-a92f-4576cd5a3677"
  }
]

Get webhook response

Fetch an existing webhook response.

Parameters

This endpoint takes no arguments.

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/webhookSettings/<WEBHOOK_SETTING_ID>/webhookResponses/<SEQUENCE_NUMBER>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
webhook_setting_id="08efb2ce-18d2-4aa1-9f8c-f745386ad1ac"
sequence_number=10

curl "https://api.blockbax.com/v1/projects/${project_id}/webhookSettings/${webhook_setting_id}/webhookResponses/${sequence_number}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "webhookSettingId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "sequenceNumber": 10,
  "deliveryAttempt": 1,
  "date": "2021-01-24T15:05:02.124+0000",
  "statusCode": 200,
  "responseType": "OK_RESPONSE",
  "error": false,
  "eventId": "fe61694a-7490-47a3-a92f-4576cd5a0835"
}

Measurements

This endpoint allows you to programmatically send and query measurements.

Search measurements

Fetch existing measurements. If you pass a date range, you must pass exactly one subject and one metric ID. If you do not pass a date range, you can pass none or multiple IDs and you will get the latest measurements for those IDs, or no filter on subjects/metrics when not passing the argument.

Parameters

  • subjectIds [optional, default=None]: The ID of the subjects. When passing a fromDate or toDate, this must contain one subject ID.
  • metricIds [optional, default=None]: The ID of the metrics. When passing a fromDate or toDate, this must contain one metric ID.
  • fromDate [optional, default=None]: Inclusive from date as ISO 8601 string with millisecond precision.
  • toDate [optional, default=None]: Exclusive end date as ISO 8601 string with millisecond precision.
  • size [optional, default=None]: Maximum number of measurements to fetch.
  • order [optional, default=asc]: Ordering of measurements based on the date (asc or desc).

HTTP Request

GET https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements?subjectIds=<SUBJECT_IDS>&metricIds=<METRIC_IDS>&fromDate=<FROM_DATE>&toDate=<TO_DATE>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
subject_ids="f59ee376-ccec-40e1-8ebe-38bef7a30ac9"
metric_ids="7c40cc50-aa51-4eb2-8937-71ce62798f17, 5d9109db-d88f-4831-aa61-871a51498784"
from_date="2021-01-02T00:00:00.000+02:00"
to_date="2021-01-03T00:00:00.000+02:00"

curl -G --data-urlencode "fromDate=${from_date}" --data-urlencode "toDate=${to_date}" "https://api.blockbax.com/v1/projects/${project_id}/measurements?subjectIds=${subject_ids}&metricIds=${metric_ids}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "series": [
    {
      "subjectId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
      "metricId": "7c40cc50-aa51-4eb2-8937-71ce62798f17",
      "measurements": [
        {
          "date": "2021-01-02T15:00:01.946+0000",
          "number": 22.1
        },
        {
          "date": "2021-01-02T15:00:01.976+0000",
          "number": 22.2
        }
      ]
    },
    {
      "subjectId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
      "metricId": "5d9109db-d88f-4831-aa61-871a51498784",
      "measurements": [
        {
          "date": "2021-01-02T15:05:02.124+0000",
          "location": {
            "lat": 10.3,
            "lon": 20.2,
            "alt": 30.1
          }
        }
      ]
    },
    {
      "subjectId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
      "metricId": "8161ee9f-d84d-40bd-bbfe-f3bd20285e8c",
      "measurements": [
        {
          "date": "2021-01-02T15:05:02.124+0000",
          "text": "LowTirePressureAlarm"
        }
      ]
    }
  ]
}

Send measurements

Send new measurements. Must be either a measurement with number, location or text value. In case your request is syntactically correct, but not everything can be ingested you will receive a 207 (MULTI_STATUS) response with details in the response. It is possible to automatically create subjects by enabling this on a default inbound connector in your project settings.

If you are unable to work with the default payload format you can write your own custom JavaScript payload conversion function using inbound connectors.

Body

  • series [required]: A list of series, following this form:
    • ingestionId [required]: Ingestion ID, either the derived ingestion ID or a custom one that has been defined.
    • measurements: A list of measurement definitions. Measurement definitions follow this form:
      • date [optional]: ISO 8601 formatted date or epoch timestamp in milliseconds (limited to millisecond precision and maximum allowed date 9999-12-31 23:59:59.999 UTC). If no date is provided the time received on the server will be used.
      • number: Number value of the measurement (up to 20 digits before and 8 digits behind the decimal point).
      • location: Location of the measurement.
        • lat: Latitude in decimal degrees (-90 to 90 for the integer part and 8 digits behind the decimal point).
        • lon: Longitude in decimal degrees (-180 to 180 for the integer part and 8 digits behind the decimal point).
        • alt: Altitude above the earth surface in meters (up to 20 digits before and 8 digits behind the decimal point).
      • text: Text value of the measurement (up to 100 characters). When exceeding the character limit the text will be truncated.
The total number of measurements per batch is limited to 500.

HTTP Request

POST https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}/measurements"
  -H "Authorization: ApiKey ${api_key}"
  -H "Content-Type: application/json"
  -d '{
        "series":[
          {
            "ingestionId": "MyHouse$LivingRoomTemperature",
            "measurements": [
              {
                "date": "2021-01-09T12:00:00.000+00:00",
                "number": 10.3
              },
              {
                "date": "2021-01-09T12:01:00.000+00:00",
                "number": 11.5
              }
            ]
          },
          {
            "ingestionId": "MyCar$Location",
            "measurements": [
              {
                "date": "2021-01-09T12:00:00.000+00:00",
                "location": {
                  "lat": 10.3, "lon": 11.2, "alt": 12.1
                }
              }
            ]
          },
          {
            "ingestionId": "MyCar$Status",
            "measurements": [
              {
                "date": "2021-01-09T12:00:00.000+00:00",
                "text": "LowTirePressureAlarm"
              }
            ]
          }
        ]
      }'

Example response

{
  "numberOfIngestedMeasurements": 2,
  "message": "There were issues while processing the payload. The specific issues are listed in the 'detailedMessages' property.",
  "detailedMessages": [
    "Tried to save measurements for ingestion ids: MyHouse$LivingRoomTemperature, MyCar$Location. These ingestion ids could not be found or you have no access to the corresponding subject.",
    "Received invalid measurement values for ingestion ids: MyHouse$Humidity. Verify that the sent value is of the correct type for the metric data type, and that the value meets the requirements stated in the API docs at https://blockbax.com/docs/api/#send-measurements.",
    "Received measurement values for ingestion ids: Office$Temperature were truncated before ingestion. Number metrics, latitude, longitude and altitude are rounded to 8 fractional numbers. String metrics are truncated to 1000 characters."
  ]
}

Events

This endpoint allows you to programmatically query events.

Search events

Search and filter events. Results are paginated with a maximum of 200 results at a time.

Parameters

  • active [optional]: true to only fetch events that are currently active.
  • suppressed [optional]: true to only fetch events that are suppressed, false to only fetch events that are not suppressed.
  • fromDate [optional]: Inclusive from date as ISO 8601 string with millisecond precision.
  • toDate [optional]: Exclusive end date as ISO 8601 string with millisecond precision.
  • onlyNew [optional]: true to only fetch events that occurred in the given date range, as opposed to including events that may still be active but occurred earlier.
  • propertyValueIds [optional, default=None]: Filter on a list of property value IDs, use a , separator for OR and ; for AND, e.g. <A>,<B>;<C> translates to (A OR B) AND C.
  • subjectIds [optional]: Comma-separated list of subjects IDs.
  • eventTriggerIds [optional]: Comma-separated list of event trigger IDs.
  • eventLevels [optional]: Comma-separated list of event levels (problem, warning, information or ok).
  • sort [optional, default=startDate,desc]: The sort order, e.g. startDate,asc.
  • page [optional, default=0]: The page to fetch.
  • size [optional, default=20]: The page size. Max 200.

HTTP Request

GET "https://api.blockbax.com/v1/projects/<PROJECT_ID>/events

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"

curl "https://api.blockbax.com/v1/projects/${project_id}/events?fromDate=2021-01-03T13:00:00.000Z&toDate=2021-01-10T13:00:00.000Z&subjectIds=<SUBJECT_IDS>&eventTriggerIds=<EVENT_TRIGGER_IDS>&eventLevels=problem,warning&page=0&size=20&sort=startDate,desc"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "count": 2,
  "result": [
    {
      "id": "bdc74b43-8e94-40c7-bfcb-6b9b435f0af8",
      "eventTriggerId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "eventTriggerVersion": 8,
      "eventLevel": "WARNING",
      "subjectId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
      "conditionSetIds": ["7c40cc50-aa51-4eb2-8937-71ce62798f17"],
      "startDate": "2021-01-10T12:03:00.000+0000",
      "suppressed": false
    },
    {
      "id": "eeaa6dcc-eb63-4068-af68-4b651c5ef8dd",
      "eventTriggerId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
      "eventTriggerVersion": 8,
      "eventLevel": "OK",
      "subjectId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
      "conditionSetIds": [],
      "startDate": "2021-01-10T07:15:21.005+0000",
      "endDate": "2021-01-10T12:03:00.000+0000",
      "suppressed": true
    }
  ]
}

Get an event

Fetch an existing event.

Parameters

This endpoint takes no arguments.

HTTP Request

GET "https://api.blockbax.com/v1/projects/<PROJECT_ID>/events/<EVENT_ID>

Example request

api_key=<API_KEY>
project_id="715b6935-e3d8-48b1-86a3-a6e2a268e1f"
event_id="eeaa6dcc-eb63-4068-af68-4b651c5ef8dd"

curl "https://api.blockbax.com/v1/projects/${project_id}/events/${event_id}"
  -H "Authorization: ApiKey ${api_key}"

Example response

{
  "id": "eeaa6dcc-eb63-4068-af68-4b651c5ef8dd",
  "eventTriggerId": "08efb2ce-18d2-4aa1-9f8c-f745386ad1ac",
  "eventTriggerVersion": 8,
  "eventLevel": "PROBLEM",
  "subjectId": "f59ee376-ccec-40e1-8ebe-38bef7a30ac9",
  "conditionSetIds": ["7c40cc50-aa51-4eb2-8937-71ce62798f17"],
  "startDate": "2021-01-10T07:15:21.005+0000",
  "endDate": "2021-01-10T11:28:11.460+0000",
  "suppressed": false
}