A user-defined function (UDF) is a function that you can define yourself and use in your queries. It is a way to extend the functionality of the database.
curl --request GET \
--url https://demo.enneo.ai/api/mind/settings/user-defined-function
{
"success": true,
"userDefinedFunctions": [
{
"id": 1,
"type": "tool",
"data": {
"udfExecutor": {
"id": 1,
"code": "<?php\n\n// Load enneo SDK. Input is made available through $in\nuse EnneoSDK\\Api;\nuse EnneoSDK\\ApiEnneo;\nrequire(getenv()['SDK']);\n\nfunction exampleApiCall(string $method, string $api, array|object|string|false $params = false, $attempt = 1): stdClass|array\n{\n // load token\n $token = ApiEnneo::executeUdf('fetchToken', [])->token;\n\n // make request\n $res = Api::call(\n method: $method,\n url: sprintf('urlExampleHere', $api),\n headers: [\n sprintf('Authorization: Bearer %s', $token),\n 'x-api-key: tokenExampleHere',\n 'Accept: application/json'\n ],\n params: $params\n );\n\n return $res;\n}\n\necho json_encode(exampleApiCall($in->method, $in->api, $in->params));",
"type": "sourceCode",
"language": "php82",
"packages": "",
"parameters": []
}
},
"name": "exampleApiCall"
}
]
}
Cookie-based authentication
Filter by type of user defined function. If 'tool', only tool functions are returned. If 'udf', only non-tool functions are returned.
tool
, udf
Successful operation
Data format of Enneo success messages
curl --request GET \
--url https://demo.enneo.ai/api/mind/settings/user-defined-function
{
"success": true,
"userDefinedFunctions": [
{
"id": 1,
"type": "tool",
"data": {
"udfExecutor": {
"id": 1,
"code": "<?php\n\n// Load enneo SDK. Input is made available through $in\nuse EnneoSDK\\Api;\nuse EnneoSDK\\ApiEnneo;\nrequire(getenv()['SDK']);\n\nfunction exampleApiCall(string $method, string $api, array|object|string|false $params = false, $attempt = 1): stdClass|array\n{\n // load token\n $token = ApiEnneo::executeUdf('fetchToken', [])->token;\n\n // make request\n $res = Api::call(\n method: $method,\n url: sprintf('urlExampleHere', $api),\n headers: [\n sprintf('Authorization: Bearer %s', $token),\n 'x-api-key: tokenExampleHere',\n 'Accept: application/json'\n ],\n params: $params\n );\n\n return $res;\n}\n\necho json_encode(exampleApiCall($in->method, $in->api, $in->params));",
"type": "sourceCode",
"language": "php82",
"packages": "",
"parameters": []
}
},
"name": "exampleApiCall"
}
]
}