Enneo

Settings

Add a new User Defined Function

POST /settings/user-defined-function

POST /settings/user-defined-function

Request body

The new User Defined Function that should be created. The ID does not need to be included in the payload, as it will be generated automatically.

idintegerbody

No description.

typeenumbody

Options: tool, udf

dataobjectbody

No description.

namestringbody

No description.

Request Example

{
  "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"
}

Responses

200 — User Defined Function added successfully

Response Example

{
  "success": true,
  "id": 12345
}

403 — Unauthorized

500 — Internal error