This section details the API endpoints that allow you to generate generic formulas within your data structure.
As a reminder, this generation relies on formula templates that must have been previously defined on the types within your data structure. If you are not familiar with this functionality, please consult the documentation on formula templates.
Retrieve the list of metrics to generate
Description
This request allows you to list all the metrics that can be generated from a formula template.
Note : This is not about actually generating metrics, but rather about visualizing the metrics that a formula template can generate.
GET /v2/data-structures/{data_structure_id}/templates/generate/formulas/{formulas_template_id}
Scope
To perform this request, you must have the metadata:read scope.
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 withPOST v2/data-structures
.
formula_template_id (string, required): The ID assigned to the formula template you wish to edit.
You can retrieve this ID via the
GET v2/data-structures/{data_structure_id}/types/{type_id}/formulas
request or when the formula template was created.Note : This parameter can be left empty to retrieve all formulas originating from templates in the data structure.
These parameters need to be added to the URL to build the query string :
/v2/data-structures/{data_structure_id}/templates/generate/formulas/{formulas_template_id}
Request example
# Command to generate formulas from a template
curl -X 'GET' \
'https://xxx.indaba.api.indasuite.io-base.com/v2/data-structures/67337415-6bcb-4c21-b0f5-8253d68b6e80/templates/generate/formulas/9b034dcf-0e5b-4b45-908a-1c07ff7880c1' \
# ----- En-têtes -----
-H 'accept: application/json' \
-H 'Authorization: Bearer VOTRE_JETON_JWT'
Responses
example of a valid response (200 Ok) :
{
"data": [
{
"id": "5d2b5890-a3e4-482c-9ade-bff1662f5fc8",
"dataStructureId": "67337415-6bcb-4c21-b0f5-8253d68b6e80",
"typeId": "0b3f2349-9b17-45d9-b7c4-0b47d0f39960",
"parentId": "_siteb",
"label": "main@dopen_106",
"metric": {
"id": "main@dopen_106",
"name": "dopen_106",
"datasource": "main",
"description": "formule vérifiant si la diode du site 106 est ouverte ou non.",
"type": "Calculated"
},
"properties": {},
"parents": {
"e9910c2b-83e9-4954-a1dd-abca2d833999": [
{
"code_site": 106,
"id": "_siteb",
"label": "Site b",
"parentid": null
}
]
},
"options": {
"indabaId": "main@dopen_106",
"indabaLabel": "Name"
},
"isTypeMetric": true,
"hasError": false,
"formula": "if(main@cip_int_106>0 or main@cip_int_106>0, 1, 0)",
"formulaTemplateId": "9b034dcf-0e5b-4b45-908a-1c07ff7880c1",
"formulaTemplateVersion": 3,
"hasTemplateCreated": false,
"isLockedToTemplate": true
}
],
"resultCode": 2010,
"message": "OK"
}
Common errors
Please refer to the list of common errors.
Generate formulas from a template
Description
This request allows you to generate formulas from a template.
POST /v2/data-structures/{data_structure_id}/templates/generate/formulas/{formula_template_id}
Scope
To perform this request, you must have the metadata:admin scope.
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 withPOST v2/data-structures
.
formula_template_id (string, required): The ID assigned to the formula template you wish to edit.
You can retrieve this ID via the
GET v2/data-structures/{data_structure_id}/types/{type_id}/formulas
request or when the formula template was created.override_manuals (string, optional): This allows you to specify whether you want to overwrite manual metrics that have the same name as the new generic formulas. It can take two values:
true
: Manual metrics will be overwritten by the formulas.false
: Manual metrics will be kept.
Note : By default, this parameter is set to
false
.
These parameters need to be added to the URL to build the query string :
/v2/data-structures/{data_structure_id}/templates/generate/formulas/{formula_template_id}?override_manuals="boolean"
Request example
# Command to generate formulas from a template
curl -X 'POST' \
'https://xxx.indaba.api.indasuite.io-base.com/v2/data-structures/67337415-6bcb-4c21-b0f5-8253d68b6e80/templates/generate/formulas/9b034dcf-0e5b-4b45-908a-1c07ff7880c1?override_manuals=true' \
# ----- 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.
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.