---
title: "Create Luau Execution Session Task"
method: POST
path: "/cloud/v2/universes/{universe_id}/places/{place_id}/luau-execution-session-tasks"
tags: ["Luau Execution", "Places"]
---

# Create Luau Execution Session Task

`POST /cloud/v2/universes/{universe_id}/places/{place_id}/luau-execution-session-tasks`

## Request

- Base URL: `https://apis.roblox.com`
- URL: `https://apis.roblox.com/cloud/v2/universes/{universe_id}/places/{place_id}/luau-execution-session-tasks`
- Auth: API key in header `x-api-key`

Creates a task but does not wait for the task to complete.

To check whether a task has
completed, call the `GetLuauExecutionSessionTask` method and inspect the
`state` field of the returned resource.

## Path parameters

- `universe_id` string, required
- `place_id` string, required

## Request body

- LuauExecutionSessionTask: A `LuauExecutionSessionTask` ("task" for short) executes a given Luau script in the context of a specific version of a place. In a task, physics simulation does not run. Server and local scripts within the place also do not automatically run. The script may access and update the data model of the place, including invoking any module scripts. However, data model changes are local to the task and cannot be persisted. The script can also invoke engine APIs that read and/or modify data stored in the cloud, such as those for DataStores. Exercise caution when using these APIs. Scripts can be up to 4 MB in size and run for up to 5 minutes. Scripts that run for longer than the time limit terminate with an error. Scripts are executed as-is and do not need to be wrapped in a function. Scripts can return values (using the Luau `return` keyword). Return values are serialized to JSON and can be retrieved with the `Get LuauExecutionSessionTask` API after the task completes. The total size of the return values after JSON serialization must not exceed 4 MB. If the limit is exceeded, the task terminates with an error. If the script raises an unhandled error, the task terminates. The error information can be retrieved with the `GetLuauExecutionSessionTask` API. Standard output (generated by the Luau `print` function) can be retrieved with the `ListLuauExecutionSessionTaskLogs` method after the task completes. A maximum of 450 KB of logs are retained. If the amount of logs exceeds the limit, older logs are discarded. Information about a task is retained for 24 hours after task completion. At most ten incomplete tasks are allowed per place. Attempting to create more tasks while the first ten are incomplete results in a HTTP 429 response.
  - `path` string: The resource path of the luau execution session task. Formats: * `universes/{universe_id}/places/{place_id}/luau-execution-session-tasks/{luau_execution_session_task_id}` * `universes/{universe_id}/places/{place_id}/versions/{place_version_id}/luau-execution-session-tasks/{luau_execution_session_task_id}` * `universes/{universe_id}/places/{place_id}/luau-execution-sessions/{luau_execution_session_id}/tasks/{luau_execution_session_task_id}` * `universes/{universe_id}/places/{place_id}/versions/{place_version_id}/luau-execution-sessions/{luau_execution_session_id}/tasks/{luau_execution_session_task_id}`
  - `createTime` string, date-time: Time when this task was created.
  - `updateTime` string, date-time: Time when this task's state last changed.
  - `user` string: The user that created the API key that was used to create this task.
  - `state` 'STATE_UNSPECIFIED' | 'QUEUED' | 'PROCESSING' | 'CANCELLED' | 'COMPLETE' | 'FAILED', enum: The task's state. See the State enum for information about each possible value. Possible values: | Value | Description | | --- | --- | | STATE_UNSPECIFIED | UNSPECIFIED | | QUEUED | The Task is waiting to be processed. | | PROCESSING | The Task has been picked up for processing. | | CANCELLED | The Task has been stopped by the user. | | COMPLETE | The Task has finished processing. The output field contains the output. | | FAILED | The Task failed. The error field contains details about the error. |
  - `script` string: The script to be run as part of this task. For example: ```luau local x = 3 local y = 4 return x + y ```
  - `timeout` string, duration: Limit for how long the script can run. The task fails if the script does not complete within the specified duration. Defaults to 5 minutes.
  - `error` LuauExecutionSessionTaskError: Contains error details in case of failed execution.
    - `code` 'ERROR_CODE_UNSPECIFIED' | 'SCRIPT_ERROR' | 'DEADLINE_EXCEEDED' | 'OUTPUT_SIZE_LIMIT_EXCEEDED' | 'INTERNAL_ERROR', enum: An error code indicating the category of the error. Possible values: | Value | Description | | --- | --- | | ERROR_CODE_UNSPECIFIED | UNSPECIFIED | | SCRIPT_ERROR | The task's script raised an unhandled error. | | DEADLINE_EXCEEDED | The task exceeded the maximum allowed execution duration. | | OUTPUT_SIZE_LIMIT_EXCEEDED | The task's outputs were too large. | | INTERNAL_ERROR | The Task failed due to an internal system error. |
    - `message` string: An error message containing more details about the error.
  - `output` LuauExecutionSessionTaskOutput: Contains the output of a task's execution.
    - `results` GoogleProtobufValue[]: Return values from the script that was run. Return values that are not JSON serializable (such as Data Model Instances) will be returned as nulls.
      - unknown
  - `binaryInput` string: Resource path of the binary input to this task. See the documentation for the `LuauExecutionSessionTaskBinaryInput` resource for usage details.
  - `enableBinaryOutput` boolean: If set to true, allows the task to output a large binary object in addition to standard return values. If `enable_binary_output` is set to true, the task script must return a `LuauExecutionTaskOutput` (or equivalent table) and no other return values. Below is example code for doing so: ```luau local buf: buffer = buffer.create(10) local result: LuauExecutionTaskOutput = { BinaryOutput = buf, ReturnValues = { "hello world", 123 } } return result ``` The `BinaryOutput` buffer must be no larger than 256 MiB in size. The `ReturnValues` array, if given, will be serialized to JSON and made available in the `output` field of the `LuauExecutionSessionTask` resource, similar to regular return values when not using `enable_binary_output`. The binary output can be fetched from the URI in the `binaryOutputUri` field after the task completes. The `binaryOutputUri` is valid for 15 minutes after task completion.
  - `binaryOutputUri` string: URI for the binary output of this task. See the `enableBinaryOutput` field for usage details.

## Response `200`

OK

- LuauExecutionSessionTask: A `LuauExecutionSessionTask` ("task" for short) executes a given Luau script in the context of a specific version of a place. In a task, physics simulation does not run. Server and local scripts within the place also do not automatically run. The script may access and update the data model of the place, including invoking any module scripts. However, data model changes are local to the task and cannot be persisted. The script can also invoke engine APIs that read and/or modify data stored in the cloud, such as those for DataStores. Exercise caution when using these APIs. Scripts can be up to 4 MB in size and run for up to 5 minutes. Scripts that run for longer than the time limit terminate with an error. Scripts are executed as-is and do not need to be wrapped in a function. Scripts can return values (using the Luau `return` keyword). Return values are serialized to JSON and can be retrieved with the `Get LuauExecutionSessionTask` API after the task completes. The total size of the return values after JSON serialization must not exceed 4 MB. If the limit is exceeded, the task terminates with an error. If the script raises an unhandled error, the task terminates. The error information can be retrieved with the `GetLuauExecutionSessionTask` API. Standard output (generated by the Luau `print` function) can be retrieved with the `ListLuauExecutionSessionTaskLogs` method after the task completes. A maximum of 450 KB of logs are retained. If the amount of logs exceeds the limit, older logs are discarded. Information about a task is retained for 24 hours after task completion. At most ten incomplete tasks are allowed per place. Attempting to create more tasks while the first ten are incomplete results in a HTTP 429 response.
  - `path` string: The resource path of the luau execution session task. Formats: * `universes/{universe_id}/places/{place_id}/luau-execution-session-tasks/{luau_execution_session_task_id}` * `universes/{universe_id}/places/{place_id}/versions/{place_version_id}/luau-execution-session-tasks/{luau_execution_session_task_id}` * `universes/{universe_id}/places/{place_id}/luau-execution-sessions/{luau_execution_session_id}/tasks/{luau_execution_session_task_id}` * `universes/{universe_id}/places/{place_id}/versions/{place_version_id}/luau-execution-sessions/{luau_execution_session_id}/tasks/{luau_execution_session_task_id}`
  - `createTime` string, date-time: Time when this task was created.
  - `updateTime` string, date-time: Time when this task's state last changed.
  - `user` string: The user that created the API key that was used to create this task.
  - `state` 'STATE_UNSPECIFIED' | 'QUEUED' | 'PROCESSING' | 'CANCELLED' | 'COMPLETE' | 'FAILED', enum: The task's state. See the State enum for information about each possible value. Possible values: | Value | Description | | --- | --- | | STATE_UNSPECIFIED | UNSPECIFIED | | QUEUED | The Task is waiting to be processed. | | PROCESSING | The Task has been picked up for processing. | | CANCELLED | The Task has been stopped by the user. | | COMPLETE | The Task has finished processing. The output field contains the output. | | FAILED | The Task failed. The error field contains details about the error. |
  - `script` string: The script to be run as part of this task. For example: ```luau local x = 3 local y = 4 return x + y ```
  - `timeout` string, duration: Limit for how long the script can run. The task fails if the script does not complete within the specified duration. Defaults to 5 minutes.
  - `error` LuauExecutionSessionTaskError: Contains error details in case of failed execution.
    - `code` 'ERROR_CODE_UNSPECIFIED' | 'SCRIPT_ERROR' | 'DEADLINE_EXCEEDED' | 'OUTPUT_SIZE_LIMIT_EXCEEDED' | 'INTERNAL_ERROR', enum: An error code indicating the category of the error. Possible values: | Value | Description | | --- | --- | | ERROR_CODE_UNSPECIFIED | UNSPECIFIED | | SCRIPT_ERROR | The task's script raised an unhandled error. | | DEADLINE_EXCEEDED | The task exceeded the maximum allowed execution duration. | | OUTPUT_SIZE_LIMIT_EXCEEDED | The task's outputs were too large. | | INTERNAL_ERROR | The Task failed due to an internal system error. |
    - `message` string: An error message containing more details about the error.
  - `output` LuauExecutionSessionTaskOutput: Contains the output of a task's execution.
    - `results` GoogleProtobufValue[]: Return values from the script that was run. Return values that are not JSON serializable (such as Data Model Instances) will be returned as nulls.
      - unknown
  - `binaryInput` string: Resource path of the binary input to this task. See the documentation for the `LuauExecutionSessionTaskBinaryInput` resource for usage details.
  - `enableBinaryOutput` boolean: If set to true, allows the task to output a large binary object in addition to standard return values. If `enable_binary_output` is set to true, the task script must return a `LuauExecutionTaskOutput` (or equivalent table) and no other return values. Below is example code for doing so: ```luau local buf: buffer = buffer.create(10) local result: LuauExecutionTaskOutput = { BinaryOutput = buf, ReturnValues = { "hello world", 123 } } return result ``` The `BinaryOutput` buffer must be no larger than 256 MiB in size. The `ReturnValues` array, if given, will be serialized to JSON and made available in the `output` field of the `LuauExecutionSessionTask` resource, similar to regular return values when not using `enable_binary_output`. The binary output can be fetched from the URI in the `binaryOutputUri` field after the task completes. The `binaryOutputUri` is valid for 15 minutes after task completion.
  - `binaryOutputUri` string: URI for the binary output of this task. See the `enableBinaryOutput` field for usage details.

---

[API](https://skmtc.dev/roblox/apis/roblox-api.md) - [All operations](https://skmtc.dev/roblox/apis/roblox-api/llms.txt) - [OpenAPI document](https://skmtc.dev/roblox/apis/roblox-api/revisions/bcfdc20689cd?raw)
