Create entity class

POST/projects/{projectId}/entityClasses

Base URL: https://api.tinkermode.com

Create a new entity class in the project

Authentication

Send an Authorization header of the form ModeCloud <AUTH_CODE>.

Must contain the API key of a user or service account who has the permission to create all Entity Classes of a project, or a Project API Key with admin permission.

Path parameters

NameTypeRequiredConstraintsDescription
projectIdintegerYesThe unique ID for a specified project.

Request body

Content type: application/json

PropertyTypeRequiredConstraintsDescription
attributeSchemaarrayNoA schema used for validating the attributes of an entity instance.
createdAtstringNoread-only (server-generated); format: date-timeTimestamp of entity class creation.
displaySettingsobjectNoVarious user interface settings used for display of the entity class.
Properties of displaySettings
PropertyTypeRequiredConstraintsDescription
descriptionstringNoAn intuitive description for the entity class for display.
iconDataobjectNoMetadata used for the uploaded icon of the entity class.
Properties of iconData
PropertyTypeRequiredConstraintsDescription
fileNamestringNoFileName represents the name of the file uploaded.
urlstringNoA temporary signed URL for file download.
imageDataobjectNoMetadata used for the uploaded image of the entity class.
Properties of imageData
PropertyTypeRequiredConstraintsDescription
fileNamestringNoFileName represents the name of the file uploaded.
urlstringNoA temporary signed URL for file download.
namestringNoThe display name for the entity class.
uiSettingsobjectNoAn opaque object used by UI applications to store any additional settings.
entityClassstringYesread-only (server-generated)ID of the entity class. Must be unique within a project.
metricsDefinitionsarrayNoAn array of metrics definitions that are applicable to this class of entities.
projectIdintegerYesread-only (server-generated)Project that this entity class belongs to.
updatedAtstringNoread-only (server-generated); format: date-timeTimestamp of the last update on the entity class.

Request example

{
  "attributeSchema": [
    {
      "defaultValue": "medium_size_robot",
      "description": "The group that the robot entity instance belongs to.",
      "key": "robot_group",
      "label": "Robot Group",
      "options": [
        {
          "label": "Small Size Robot",
          "value": "small_size_robot"
        },
        {
          "label": "Medium Size Robot",
          "value": "medium_size_robot"
        },
        {
          "label": "Large Size Robot",
          "value": "large_size_robot"
        }
      ],
      "required": true,
      "type": "string"
    },
    {
      "defaultValue": 15.5,
      "description": "The maximum speed that the robot can be set to.",
      "key": "maxRobotSpeedMph",
      "label": "Maximum Robot Speed (mph)",
      "max": 25,
      "min": 5,
      "required": false,
      "type": "number"
    }
  ],
  "createdAt": "2021-08-12T20:11:11Z",
  "displaySettings": {
    "description": "Freezer with a temperature sensor and a door sensor",
    "name": "Freezer",
    "uiSettings": {
      "componentPlacement": "placement1",
      "layout": "twoColumnsLayout"
    }
  },
  "entityClass": "freezer",
  "metricsDefinitions": [
    {
      "dataStoreConfiguration": {
        "bulkDataLabel": "tsdb",
        "moduleInstanceId": "tsdb",
        "moduleType": "tsdb"
      },
      "metricsDefinitionId": "ambient_sensor_module",
      "metricsType": "raw",
      "numericMetrics": [
        {
          "displayName": "Temperature",
          "name": "temperature",
          "range": {
            "max": 100,
            "min": 0
          },
          "unit": "°C"
        }
      ],
      "tagMetrics": [
        {
          "displayName": "Status",
          "enumDefinitions": [
            {
              "Name": "Normal",
              "Value": "000"
            },
            {
              "Name": "Error",
              "Value": "900"
            }
          ],
          "name": "statusCode"
        }
      ]
    },
    {
      "dataStoreConfiguration": {
        "bulkDataLabel": "tsdb",
        "moduleInstanceId": "tsdb",
        "moduleType": "tsdb"
      },
      "metricsDefinitionId": "door_sensor_module",
      "metricsType": "raw",
      "numericMetrics": [
        {
          "displayName": "Count",
          "name": "count"
        }
      ]
    }
  ],
  "projectId": 1,
  "updatedAt": "2021-09-02T22:19:39Z"
}

Responses

201 Successful creation of entity class.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
attributeSchemaarrayNoA schema used for validating the attributes of an entity instance.
createdAtstringNoread-only (server-generated); format: date-timeTimestamp of entity class creation.
displaySettingsobjectNoVarious user interface settings used for display of the entity class.
Properties of displaySettings
PropertyTypeRequiredConstraintsDescription
descriptionstringNoAn intuitive description for the entity class for display.
iconDataobjectNoMetadata used for the uploaded icon of the entity class.
Properties of iconData
PropertyTypeRequiredConstraintsDescription
fileNamestringNoFileName represents the name of the file uploaded.
urlstringNoA temporary signed URL for file download.
imageDataobjectNoMetadata used for the uploaded image of the entity class.
Properties of imageData
PropertyTypeRequiredConstraintsDescription
fileNamestringNoFileName represents the name of the file uploaded.
urlstringNoA temporary signed URL for file download.
namestringNoThe display name for the entity class.
uiSettingsobjectNoAn opaque object used by UI applications to store any additional settings.
entityClassstringYesread-only (server-generated)ID of the entity class. Must be unique within a project.
metricsDefinitionsarrayNoAn array of metrics definitions that are applicable to this class of entities.
projectIdintegerYesread-only (server-generated)Project that this entity class belongs to.
updatedAtstringNoread-only (server-generated); format: date-timeTimestamp of the last update on the entity class.

Response example

{
  "attributeSchema": [
    {
      "defaultValue": "medium_size_robot",
      "description": "The group that the robot entity instance belongs to.",
      "key": "robot_group",
      "label": "Robot Group",
      "options": [
        {
          "label": "Small Size Robot",
          "value": "small_size_robot"
        },
        {
          "label": "Medium Size Robot",
          "value": "medium_size_robot"
        },
        {
          "label": "Large Size Robot",
          "value": "large_size_robot"
        }
      ],
      "required": true,
      "type": "string"
    },
    {
      "defaultValue": 15.5,
      "description": "The maximum speed that the robot can be set to.",
      "key": "maxRobotSpeedMph",
      "label": "Maximum Robot Speed (mph)",
      "max": 25,
      "min": 5,
      "required": false,
      "type": "number"
    }
  ],
  "createdAt": "2021-08-12T20:11:11Z",
  "displaySettings": {
    "description": "Freezer with a temperature sensor and a door sensor",
    "name": "Freezer",
    "uiSettings": {
      "componentPlacement": "placement1",
      "layout": "twoColumnsLayout"
    }
  },
  "entityClass": "freezer",
  "metricsDefinitions": [
    {
      "dataStoreConfiguration": {
        "bulkDataLabel": "tsdb",
        "moduleInstanceId": "tsdb",
        "moduleType": "tsdb"
      },
      "metricsDefinitionId": "ambient_sensor_module",
      "metricsType": "raw",
      "numericMetrics": [
        {
          "displayName": "Temperature",
          "name": "temperature",
          "range": {
            "max": 100,
            "min": 0
          },
          "unit": "°C"
        }
      ],
      "tagMetrics": [
        {
          "displayName": "Status",
          "enumDefinitions": [
            {
              "Name": "Normal",
              "Value": "000"
            },
            {
              "Name": "Error",
              "Value": "900"
            }
          ],
          "name": "statusCode"
        }
      ]
    },
    {
      "dataStoreConfiguration": {
        "bulkDataLabel": "tsdb",
        "moduleInstanceId": "tsdb",
        "moduleType": "tsdb"
      },
      "metricsDefinitionId": "door_sensor_module",
      "metricsType": "raw",
      "numericMetrics": [
        {
          "displayName": "Count",
          "name": "count"
        }
      ]
    }
  ],
  "projectId": 1,
  "updatedAt": "2021-09-02T22:19:39Z"
}

401 Authorization is required to access this resource.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

403 Request failed because of invalid data or denied permission. The reason is TSDBV2_NOT_ENABLED when a metrics definition stores its metrics in TSDBv2 and the project has not enabled TSDBv2.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

409 The reason is TSDBV2_SCHEMA_IN_USE when a TSDBv2 schema of a metrics definition is used by another entity class, and ENTITY_CLASS_BEING_CREATED when another create is still writing an entity class with the same ID, or another request deleted the entity class during this create.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

429 Request failed because of rate limit.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

500 An unexpected error has occurred. The reason is PROJECT_MISCONFIGURED when the project has enabled TSDBv2 but has no TSDBv2 namespace.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.

503 The service is temporarily unavailable. The reason is TEMPORARILY_UNAVAILABLE when the time series database cannot be reached for a short time. Retry after the number of seconds in Retry-After when the response has it.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.