Try it free

Execute a function

  • Latest Dynatrace
  • Reference
  • Published Oct 13, 2026

Execute custom JavaScript in Dynatrace with the Function Executor API, sending source code, payload, and SDK major versions to run a function.

POSTSaaShttps://{your-environment-id}.apps.dynatrace.com/v1/executions

Overview

You submit sourceCode, payload, and sdkMajorVersions in the request body to execute a given function in the Dynatrace JavaScript runtime. The operation returns 200 OK when the function runs successfully.

Authentication

To execute this request, you need a platform token or OAuth access token with app-engine:functions:run scope. To learn how to obtain and use it, see Tokens and authentication.

Parameters

ParameterTypeDescriptionInRequired
bodyFunctionExecutionRequest

One off code execution request.

bodyRequired

Request body objects

The FunctionExecutionRequest object

One off code execution request.

ElementTypeDescriptionRequired
sourceCodestring

source code that gets executed

Required
payloadstring

optional argument for the function defined in sourceCode

Optional
sdkMajorVersionsobject

Optional map of SDK package names to their major version numbers. Non-mentioned packages fall back to default versions. Max key length is 300 characters, max value length is 100 characters.

Optional

Request body JSON model

This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.

{
"sourceCode": "export default async function ({addThis}) { return 1 + addThis }",
"payload": "{\"addThis\":2}",
"sdkMajorVersions": {
"@dynatrace-sdk/adhoc-utils": "1",
"@dynatrace-sdk/client-classic-environment-v2": "5"
}
}

Response

Response codes

CodeTypeDescription
200AdhocSuccessResponse

OK

400ErrorEnvelope

Bad Request

540AdhocErrorResponse

JavaScript Error occurred

541AdhocErrorResponse

Runtime Error occurred

Response body objects

The AdhocSuccessResponse object

ElementTypeDescription
logsstring-
resultJsonNode-
packageVersionsobject

Map of SDK package names to their resolved versions used during execution

The JsonNode object

The ErrorEnvelope object

Error response for all 4xx and 5xx errors.

ElementTypeDescription
errorError

Contains information for 4xx and 5xx errors.

The Error object

Contains information for 4xx and 5xx errors.

ElementTypeDescription
codeinteger

The HTTP status code

messagestring

The error message

detailsErrorDetails

Contains details for 4xx and 5xx errors.

helpstring

Additional information related to the error

retryAfterSecondsinteger

Seconds to wait until the next retry

The ErrorDetails object

Contains details for 4xx and 5xx errors.

ElementTypeDescription
errorRefstring

Generated unique value for 5xx errors.

traceIdstring

OpenTelemetry trace id of the trace where error occurs.

errorCodestring

An optional error code that contains more detailed error information than the HTTP response code alone.

errorCodePropertiesobject

Additional properties related to the provided error code

constraintViolationsConstraintViolation[]

A list of constraint violations

The ConstraintViolation object

Contains information about a constraint violation caused by invalid input.

ElementTypeDescription
pathstring

The path of the property that caused the constraint violation

messagestring

The error message

errorCodestring

An optional error code that contains more detailed error information.

errorCodePropertiesobject

Additional properties related to the provided error code.

Response body JSON models

{
"logs": "string",
"result": {},
"packageVersions": {}
}
{
"error": {
"code": 1,
"message": "string",
"details": {
"errorRef": "string",
"traceId": "string",
"errorCode": "string",
"errorCodeProperties": {},
"constraintViolations": [
{
"path": "string",
"message": "string",
"errorCode": "string",
"errorCodeProperties": {}
}
]
},
"help": "string",
"retryAfterSeconds": 1
}
}
Related tags
Platform APIDynatrace Platform