> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage Custom Scripts

Custom scripts let you deploy reusable code in isolated containers and call them from workflow nodes using secure API endpoints.

Use the **Manage Custom Scripts** page in **Settings** to upload, configure, and deploy a complete script project without writing code directly in workflow nodes.

### Key Capabilities

| Capability | Description |
| - | - |
| **Task Automation** | Automate repetitive or complex tasks that require custom logic. |
| **Secure API Integration** | Integrate scripts into apps using API endpoints with secure authentication. |
| **Customization** | Implement logic or workflows tailored to unique business requirements. |
| **Data Processing** | Transform, filter, or validate data to meet specific operational requirements. |
| **Error Handling** | Create custom error-checking and fallback mechanisms beyond standard system behavior. |

Deployed scripts can be invoked from:

* The **API node** endpoint when building a workflow.
* The **Function node** in the workflow.

***

## Import and Deploy a Custom Script

1. Go to **Settings** → **Manage Custom Scripts**, then select **+ Import new**.
2. Configure the fields in each section: General Details, Runtime Settings, and Resource Allocation.
3. Review your configuration across all sections. Select any section to return and modify values.
4. Accept the **Terms and Conditions** and select **Deploy**, or select **Save as Draft** to save the configuration and deploy later.

After successful deployment, a confirmation email is sent to the admin with the credits remaining and total allocation for the account.

### General Details

| Field | Description |
| - | - |
| **Script Name** | Enter a unique name for the script. |
| **Description** | Briefly describe the purpose and capabilities of the script. |
| **Base Language** | Select the language: JavaScript (20.19.0) or Python (3.10.15). |
| **Language Version** | Select the version. Auto-selected based on the language chosen. |
| **Project File** | Upload a `.zip`, `.gz`, or `.tar` file up to 1 GB. |

Select **Validate** to check the file for errors before proceeding. Validation checks include:

* File matches the sample project structure and allowed format.
* Main file is not empty.
* Project file is within the 1 GB limit.

  ![validate file](https://mintcdn.com/koreai/FxeUffvny0kFoYXM/ai-for-process/settings/images/validate-file.png?fit=max\&auto=format\&n=FxeUffvny0kFoYXM\&q=85\&s=c3d7557a766b5944080a6e5550a8a98d)

Resolve all errors and warnings before continuing. Click **Download sample project** to get a `.zip` folder with sample script definitions as reference.

#### Custom Script Requirements and Guidelines

| Requirement | Description |
| - | - |
| **Main Entry Point** | Include a `main.py` (Python) or `main.js` (JavaScript) at the root directory. Only functions defined in this file are exposed via API endpoints or workflow integrations. |
| **Modular Code** | Organize code across multiple files for better structure. Use additional files for helper functions and import them into `main.py` or `main.js`. Only functions in the main file are exposed. |
| **Custom Dependencies** | Include a `requirements.txt` (Python) or `package.json` (JavaScript) at the root directory if your code has external package dependencies. |
| **Relative Imports** | Use relative imports when importing between files in your project. Refer to the sample files for examples. |
| **Environment Variables** | Access environment variables in your scripts as follows: Python: `import os` then `os.getenv('<key_name>')`. JavaScript: `process.env.<key_name>` |

### Runtime Settings

| Field | Description |
| - | - |
| **Environment Variables** | Enter key-value pairs accessible from your script at runtime. Select **+ Add** to add more pairs. Two default variables are available: **UPLOADS\_DIR** (read-only access to files uploaded via Public APIs) and **WORKSPACE\_DIR** (read-write directory for your function's file operations). |
| **Execution Timeout** | Set the timeout in seconds. Allowed range: 30–600 seconds. Prevents resource overuse from long-running or infinite-loop scripts. |

> [!NOTE]
>
> The following default environment variables are available:
>
> * **UPLOADS\_DIR**: Read-only access to all files uploaded via the Public APIs. Use this to access data submitted to your account.
> * **WORKSPACE\_DIR**: Read-write directory for your function's file operations. Data that your function stores or modifies is saved here.
>
> Both directories are accessible only while the container is deployed. Once undeployed, these storage locations are no longer available.

![runtime settings](https://mintcdn.com/koreai/FxeUffvny0kFoYXM/ai-for-process/settings/images/runtime-settings.png?fit=max\&auto=format\&n=FxeUffvny0kFoYXM\&q=85\&s=a96e45cace68767f77795d2cce3303e6)

### Resource Allocation

Define scaling parameters and hardware requirements to ensure the script performs optimally under varying loads.

| Field | Description |
| - | - |
| **Min Replicas** | Minimum number of pods per service. Allowed range: 1–10. Default: 1. |
| **Max Replicas** | Maximum number of pods per service. Must be ≥ Min Replicas. Allowed range: 1–10. Default: 1. |
| **Average Compute Utilization** | Threshold (%) to trigger auto-scaling per pod. Default: 75. Allowed range: 1–100. Disabled when Min and Max Replicas are equal. |
| **Hardware Profile** | Select the vCPU and memory configuration for deployment. |

Available hardware profiles:

| Profile | Actual CPU and Memory | Credits per Hour |
| - | - | - |
| 1 vCPU, 2 GB memory | 0.7 vCPUs, 1.1 GB memory | 0.07698 |
| 2 vCPUs, 4 GB memory | 1.5 vCPUs, 2.5 GB memory | 0.15396 |
| 2 vCPUs, 8 GB memory | 1.5 vCPUs, 6.5 GB memory | 0.144 |
| 4 vCPUs, 8 GB memory | 3.5 vCPUs, 6 GB memory | 0.30792 |
| 4 vCPUs, 16 GB memory | 3.5 vCPUs, 13.5 GB memory | 0.288 |

![resource allocation](https://mintcdn.com/koreai/FxeUffvny0kFoYXM/ai-for-process/settings/images/resource-allocation.png?fit=max\&auto=format\&n=FxeUffvny0kFoYXM\&q=85\&s=87dd875248aefe085b736b918277c779)

***

## Manage Deployed Scripts

Once a script is deployed or saved as a draft, the **Manage Custom Scripts** page lists all scripts and their statuses.

### Script Deployment Statuses

| Status | Description | Overview | Deployment History | Endpoint | API Keys | Redeploy |
| - | - | - | - | - | - | - |
| **Draft** | Draft copy of the script. Can be modified and deployed later. | Export, Delete, Deploy | Deploy Custom Script | Deploy Custom Script | Create a New API Key | No |
| **Deploying** | Script is being deployed. A success message appears on completion; a failure message appears if deployment fails. | Export, Delete | Rename deployment version | Endpoint not activated | Create API keys | No |
| **Ready to Deploy** | Script is configured and ready to deploy. | Export, Delete, Deploy | Rename deployment version | Endpoint not activated | Create API keys | Yes |
| **Deployed** | Script is successfully deployed. | Redeploy, Undeploy, Export | View configuration and deployment details; rename deployment version | Redeploy script; view endpoint code (cURL, JS, Python); copy script code | Create API keys; manage API keys | Yes |
| **Deployment Failed** | Script deployment failed. | Deploy, Delete, Export | View configuration and deployment details (except duration); rename deployment version | Endpoint not activated | Create API keys | Yes |

### Export a Script

Downloads the `.zip` folder of the script project to your local system.

1. On the **Manage Custom Scripts** page, select the **Ellipses** icon under **Actions** and select **Export**.
2. Alternatively, select the script entry and select **Export** on the **Overview** page.

   ![export script](https://mintcdn.com/koreai/PuupHPoTlgovf9wN/ai-for-process/settings/images/click-export-script.png?fit=max\&auto=format\&n=PuupHPoTlgovf9wN\&q=85\&s=ad54b5027f26f019c6a10504be4f3d84)

> [!NOTE]
>
> You can view the export status while it is in progress, on completion, or if it fails. You can cancel an export in progress.

### Undeploy a Script

Undeploys the script from all its deployed locations on the platform.

* An undeployed script can be redeployed. See [Redeploy a Script](#redeploy-a-script).
* After redeployment, the script's data and configurations are restored. You can edit the name and other parameters in the [deployment flow](#import-and-deploy-a-custom-script).
* If no scripts are deployed, the Function node displays "No custom scripts deployed yet." Undeployed scripts do not appear in the **Script** dropdown for the Function node.

To undeploy a script:

1. On the **Manage Custom Scripts** page, select the **Ellipses** icon under **Actions** and select **Undeploy**.
2. Alternatively, select the script entry and select **Proceed to Undeploy** on the **Overview** page.
3. Select **Undeploy** in the confirmation window.

The script status changes to **Ready to Deploy** and a success message is displayed.

After a successful undeploy, a confirmation email with the subject line *"Your custom script has been undeployed successfully"* is sent to the admin, including credits remaining and total allocation for the account.

### Delete a Script

Permanently deletes a script, including its configurations and definitions, from the system.

> [!WARNING]
>
> * You cannot delete a deployed script. Undeploy it first.
> * Deleted scripts and their configurations cannot be restored.

To delete a script:

1. On the **Manage Custom Scripts** page, click the **Ellipses** icon under **Actions**, then click **Delete**.

   Alternatively, click the script entry and select **Proceed to Delete** on the **Overview** page.

   ![proceed to delete](https://mintcdn.com/koreai/_Dn-kwIEkdH7YDGt/ai-for-process/settings/images/proceed-to-delete-script.png?fit=max\&auto=format\&n=_Dn-kwIEkdH7YDGt\&q=85\&s=c2b8f13e564d30a0b5cdbe90523bb516)

2. Click **Delete** in the confirmation window.

### Redeploy a Script

Redeployment lets you update a script's description, project file, runtime settings, and resource allocation. You cannot change the script name, base language, or version number during redeployment. Redeploy is only available for scripts with the **Deployed** status.

To redeploy a script:

1. Click the script with the **Deployed** status on the **Manage Custom Scripts** page.

2. Click **Re-deploy** on the **Overview** page.

   ![redeploy script](https://mintcdn.com/koreai/FxeUffvny0kFoYXM/ai-for-process/settings/images/re-deploy-script.png?fit=max\&auto=format\&n=FxeUffvny0kFoYXM\&q=85\&s=8efb89be1fecddb8fa12ab275c97e77c)

3. The import wizard opens with the existing configuration. Update the required fields.

After redeployment, the **Overview** page is updated with the latest deployment information.

***

## View Script Details

Select any script entry on the **Manage Custom Scripts** page to open its detail view. The following tabs are available for all script statuses.

### Script Overview

The **Overview** page shows the configuration details of the latest deployed version of a script. To open it, click any script entry on the **Manage Custom Scripts** page.

The page is available for all script statuses and displays:

* Script name and assigned status.
* [General Details](#general-details) configuration.
* [Runtime Settings](#runtime-settings) configuration.
* [Resource Allocation](#resource-allocation) configuration.

Available actions depend on the script's status. See the [Script Deployment Statuses](#script-deployment-statuses) table.

***

### Deployment History

The **Deployment History** page shows previous and current deployment and undeployment actions for a script. Use it to track version history, deployment statuses, and actions performed.

* Deployment history is available for the following statuses: **Deployed**, **Deployment Failed**, **Deploying**, and **Ready to Deploy**.
* For scripts in **Draft** status, the page shows a prompt to deploy the script. Click **Deploy custom script** and follow the steps in [Import and Deploy a Custom Script](#import-and-deploy-a-custom-script).
* Undeployment information is shown only when the status is **Ready to Deploy**.

***

### Endpoint

The **Endpoint** page shows the activated endpoint code for a deployed script in multiple formats. Copy the code in your preferred format to integrate it into your applications.

> [!NOTE]
>
> The endpoint code is view-only and cannot be edited.

Available formats:

* **cURL**: API endpoint information for the script.

  ![curl code](https://mintcdn.com/koreai/rlh-0_-9ZDbn4IuC/ai-for-process/settings/images/curl-endpoint.png?fit=max\&auto=format\&n=rlh-0_-9ZDbn4IuC\&q=85\&s=a97b18d85bce80454eef98011d2c8696)

* **JavaScript**: Payload JSON code in JavaScript format.

  ![java code](https://mintcdn.com/koreai/_Dn-kwIEkdH7YDGt/ai-for-process/settings/images/java-endpoint.png?fit=max\&auto=format\&n=_Dn-kwIEkdH7YDGt\&q=85\&s=ecda69445bdc3874ffe0e09cd651f3d6)

* **Python**: Payload JSON code in Python format.

  ![python code](https://mintcdn.com/koreai/FxeUffvny0kFoYXM/ai-for-process/settings/images/python-endpoint.png?fit=max\&auto=format\&n=FxeUffvny0kFoYXM\&q=85\&s=8e2f90c3e4f2b93abb10bebf626e0338)

For scripts with the *Deploying*, *Deployment Failed*, or *Ready to Deploy* status, the page shows a prompt to deploy the script and activate the endpoint.

***

### API Keys

API keys control access to a deployed script's endpoint. Create at least one API key before calling a script via an endpoint.

You can create API keys for a script regardless of its deployment status. Keys can only be used after the script is successfully deployed.

To create an API Key:

1. Navigate to the **API Keys** page.
2. Click **Create a New API Key** or **Create New Key**.
3. Enter a unique name for the key. The default name is "Secret Key."
4. Click **Generate Key** and then **Copy and Close**.

> [!WARNING]
>
> Your secret API key is shown only once. Save it in a secure location. Do not share it or expose it in client-side code. If you lose the key, you must generate a new one.

***

## Using Custom Scripts in the API Node

To call a deployed custom script from the API node in a workflow:

1. In the API node configuration, click **Request Definition**.

2. In the **Edit Request** dialog, configure the following:

   * Select the request type.

   * Copy the cURL from the [Endpoint](#endpoint) page of the custom script.

     ![copy endpoint](https://mintcdn.com/koreai/rlh-0_-9ZDbn4IuC/ai-for-process/settings/images/copy-endpoint.png?fit=max\&auto=format\&n=rlh-0_-9ZDbn4IuC\&q=85\&s=503b63c5485942bd43947240105bd493)

   * Paste it in the text field.

     ![curl link](https://mintcdn.com/koreai/rlh-0_-9ZDbn4IuC/ai-for-process/settings/images/curl-edit-request.png?fit=max\&auto=format\&n=rlh-0_-9ZDbn4IuC\&q=85\&s=9d28ef760fda0aae917d61a2513281d3)

   * In **Auth Profiles**, select an authentication profile or **None** (default) if authentication is not required. [Learn more](#authorization-profiles) about Auth Profiles.

   * In the **Headers** tab, add key-value pairs. For example, **Key**: `Content-Type`, **Value**: `application/json`.

   * In the **Body** tab (not available for GET requests), select the content type:
     * **application/x-www-form-urlencoded**: File uploads via HTTP POST. Key/value pairs are encoded by the platform.
     * **application/json**: JSON data exchange between servers and web applications.
     * **application/xml**: XML payload for SOAP services using POST, with the option to include node values.
     * **Custom**: Non-standard payload formats, such as for blogs or custom variables.

   * Click **Test** to send a test request. The API response appears in the **Response** tab.

   * Click **Save**.

For more information, see the [API node](https://koreai.mintlify.site/ai-for-process/nodes.md#api-node) documentation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.