Skip to main content

Types management

Updated over a week ago

This section describes the API endpoints for creating, listing, modifying, and deleting types within a functional tree.

Note: If you are not familiar with the concept of "types", please see the article on configuring types in IndaMeta.


Retrieve the list of types in a tree

Description

This request returns the list of item types defined in a tree. It is essential as it allows you to retrieve the ID of each type, which will be necessary for other requests.

GET /v2/data-structures/{data_structure_id}/types

Scope

To execute this request, you must have the metadata:read scope.

Parameters

This parameter must be added to the URL to build the request string:

/v2/data-structures/{data_structure_id}/types

Example request

# Command to list the types of a tree
curl -X 'GET' \
'https://xxx.indaba.api.indasuite.io-base.com/v2/data-structures/67337415-6bcb-4c21-b0f5-8253d68b6e80/types' \

# ----- Headers -----
-H 'accept: application/json' \
-H 'Authorization: Bearer VOTRE_JETON_JWT'

Responses

Example of a valid response (200 OK) :

{ 
"data": [
{
"id": "4c51dc5f-2951-47c6-81cd-9691c86e2e64",
"name": "Folder",
"properties": [],
"metricTemplates": [],
"formulaTemplates": [],
"isTypeMetric": false
},
{
"id": "5776c7ff-7eae-4a53-bf3a-19939b0e1a0f",
"name": "Metric",
"properties": [],
"metricProperties": [
{
"name": "Name",
"format": "Text"
},
{
"name": "Datasource",
"format": "Text"
},
{
"name": "Description",
"format": "Text"
},
{
"name": "Unit",
"format": "Text"
}
],
"metricTemplates": [],
"formulaTemplates": [],
"isTypeMetric": true
}
],
"resultCode": 2010,
"message": "OK"
}

Common errors

Please refer to the list of common errors.


Create new types

Description

This request allows you to add new item types to a tree.

POST v2/data-structures/{data_structure_id}/types

Scope

To execute this request, you must have the metadata:admin scope.

Parameters

This parameter must be added to the URL to build the request string:

/v2/data-structures/{data_structure_id}/types

Request Body

The following parameters must be provided in the request body:

  • name (required): name of the type to create.

  • isTypeMetric (optional): indicates whether it is a metric type or not. This parameter can take two values:

    • true: metric type

    • false: folder type Note: If this field is not specified, the value false (folder type) is applied by default.

  • properties (optional): allows you to add properties associated with the type. For each property, you must specify:

    • name: name of the property

    • format: format of the property. Can take the values:

      • Text

      • Boolean

      • Number

Example request

# Command to create a new type in a tree
curl -X 'POST' \
'https://xxx.indaba.api.indasuite.io-base.com/v2/data-structures/67337415-6bcb-4c21-b0f5-8253d68b6e80/types' \

# ----- Headers -----
-H 'accept: application/json' \
-H 'Authorization: Bearer VOTRE_JETON_JWT' \
-H 'Content-Type: application/json' \

# ----- Request body -----
-d '
{
"name": "nouveau_type",
"isTypeMetric": false,
"properties": [
{
"name": "code_site",
"format": "Text"
},
{
"name": "HasDescription",
"format": "Boolean"
},
{
"name": "numero_site",
"format": "Number"
}
]
}
'

Responses

Example of a valid response (200 OK) :

{ 
"data": {
"id": "67bfd93e-7216-49eb-8acf-88ada6e76b55",
"name": "nouveau_type",
"properties": [
{
"name": "code_site",
"format": "Text"
},
{
"name": "HasDescription",
"format": "Boolean"
},
{
"name": "numero_site",
"format": "Number"
}
],
"metricTemplates": [],
"formulaTemplates": [],
"isTypeMetric": false
},
"resultCode": 2010,
"message": "OK"
}

Common errors

Please refer to the list of common errors.


Update a type

Description

This query allows you to edit a type of elements contained in a tree structure.


Put v2/data-structures/{data_structure_id}/types/{type_id}

Scope

To make this request, you must have the scope metadata:admin.

Parameters

  • data_structure_id (string, required): ID of the tree. This ID can be retrieved via the GET v2/data-structures request or from the response when creating a new tree with POST v2/data-structures.

  • type_id (string, mandatory): ID assigned to the element type.

    This ID can be retrieved via the GET request /v2/data-structures/{data_structure_id}/types or following the creation of a new type with Post v2/data-structures/{data_structure_id}/types.

These parameters must be added to the URL to construct the query string :

v2/data-structures/{data_structure_id}/types/{type_id}

Request body

The following parameters must be provided in the request body:

  • name: type name

  • properties (optional): properties associated with the type.

    For each property, you must indicate:

    • name: property name

    • format: format of the property. Can take values:

      • Text

      • Boolean

      • Number

Note : The "isTypeMetric" parameter, used to indicate whether it is a metric type or not, cannot be modified.

Request example

# Command to update a functional tree
curl -X 'PUT' \
'https://xxx.indaba.api.indasuite.io-base.com/v2/data-structures/54f87655-2ce5-4fa7-bd58-4185c289d1d0/types/5776c7ff-7eae-4a53-bf3a-19939b0e1a0f' \

# ----- Headers -----
-H 'accept: application/json' \
-H 'Authorization: Bearer VOTRE_JETON_JWT' \
-H 'Content-Type: application/json' \

# ----- Request body -----
-d '
{
"name": "modif",
"isTypeMetric": false,
"properties": [
{
"name": "Name",
"format": "Text"
},
{
"name": "Count",
"format": "Number"
}
]
}
'

Responses

Example of a valid response (200 OK) :

{ 
"data": {
"id": "5776c7ff-7eae-4a53-bf3a-19939b0e1a0f",
"name": "modif",
"properties": [
{
"name": "Name",
"format": "Text"
},
{
"name": "Count",
"format": "Number"
}
],
"metricProperties": [
{
"name": "Name",
"format": "Text"
},
{
"name": "Datasource",
"format": "Text"
},
{
"name": "Description",
"format": "Text"
},
{
"name": "Unit",
"format": "Text"
}
],
"metricTemplates": [],
"formulaTemplates": [],
"isTypeMetric": true
},
"resultCode": 2010,
"message": "OK"
}

Common errors

Please refer to the list of common errors.


Delete a type

Description

This query allows you to delete a type of elements.

Note: It is only possible to delete a type of elements if no element of this type is used in the tree.

Delete v2/data-structures/{data_structure_id}/types/{type_id}

Scope

To make this request, you must have the scope metadata:admin.

Parameters

  • data_structure_id (string, required): ID of the tree. This ID can be retrieved via the GET v2/data-structures request or from the response when creating a new tree with POST v2/data-structures.

  • type_id (string, mandatory): ID assigned to the element type.

    This ID can be retrieved via the GET request /v2/data-structures/{data_structure_id}/types or following the creation of a new type with Post v2/data-structures/{data_structure_id}/types.

These parameters must be added to the URL to construct the query string:

v2/data-structures/{data_structure_id}/types/{type_id}

Request example

# Command to delete a type from a functional tree
curl -X 'DELETE' \
'https://xxx.indaba.api.indasuite.io-base.com/v2/data-structures/f9f16627-460e-4369-b345-a4ee3e94221e/types/88dacd49-2f01-4ca7-944c-6716322cb67e' \

# ----- Headers -----
-H 'accept: application/json' \
-H 'Authorization: Bearer VOTRE_JETON_JWT'

Responses

Example of a valid response (200 OK) :

{ 
"resultCode": 2010,
"message": "OK"
}

Common errors

Please refer to the list of common errors.

Specific error 400:

It is impossible to delete a type, if an element belonging to this type is used in the tree. The following error appears then:

{ 
"errors": [],
"resultCode": 2122,
"message": "Type is used"
}


Common Errors

You will primarily encounter the following HTTP error codes:

  • 400 Bad Request: Your request is malformed. This may be due to a missing parameter, an incorrect data type, or invalid JSON. The response body will contain an errors array detailing the problem.

{ 
"errors": [
{
"error": "Type_De_L_Erreur",
"message": "Description détaillée de l'erreur spécifique."
}
],
"statusCode": 1050,
"message": "Invalid request"
}
  • 401 Unauthorized: Your authentication token (JWT) is missing, invalid, or expired. You must obtain a new valid token.

  • 403 Forbidden: Your authentication token is valid, but you do not have the necessary rights for this action. This can happen for two reasons:

    • Your token does not have the required scope (e.g., you are trying to write data without the metrics:write scope).

    • Your token has the correct scope, but your user (or service account) is not linked to an authorization that grants access to the requested metric.

  • 404 Not Found: The resource you are trying to reach does not exist. This typically occurs if you are using an incorrect ID or requesting a metric that does not exist.

Did this answer your question?