# Add a new script to the script repository Adds a new script to the repository. Validates storage availability, secures filename, checks for duplicates (appends suffix if found), copies the file, generates SHA256 checksums, inserts DB records, and optionally shares the script. ## Endpoint `POST /dcapi/configuration/scriptRepository/script` ## Request URL `https://{server-hostname}:8383/dcapi/configuration/scriptRepository/script` ## Scope `Common.CREATE` ## Header `Authorization: d92d4xxxxxxxxxxxxx15f52` ## Request Parameters ### Request Headers - **Content-Type** — string, **Mandatory**: `application/scriptDetails.v1+json` - **Accept** — string, **Mandatory**: `application/addScriptStatus.v1+json` ### Request Body `application/scriptDetails.v1+json` - JSON object - **scriptFile** — JSON object, **Mandatory** - **arguments** — string, Optional - **platform** — string, Optional - **description** — string, Optional - **exitCodes** — string, Optional - **shareScript** — boolean, Optional - **scriptID** — string, Optional - **probeHandlerObject** — JSON object, Optional - **isZia** — boolean, Optional ## Sample Request ```curl curl --request POST \ --url https://appdomain/dcapi/configuration/scriptRepository/script \ --header 'Accept: application/addScriptStatus.v1+json' \ --header 'Authorization: d92d4xxxxxxxxxxxxx15f52' \ --header 'Content-Type: application/scriptDetails.v1+json' \ --data '{"description":"My custom script for deployment","exitCodes":"0","arguments":"--verbose","scriptFile":{"fileID":12345},"shareScript":false,"platform":"Windows"}' ``` ## Sample Request Body ### Add a new Windows script to the repository ```json { "description": "My custom script for deployment", "exitCodes": "0", "arguments": "--verbose", "scriptFile": { "fileID": 12345 }, "shareScript": false, "platform": "Windows" } ``` ### Add a new Linux shell script to the repository and share it ```json { "description": "Cleanup temporary files on Linux endpoints", "exitCodes": "0,1", "arguments": "", "scriptFile": { "fileID": 67890 }, "shareScript": true, "platform": "Linux" } ``` ## Response Parameters ### HTTP Code 200 Response body: `application/json` - JSON object - **status** — string: Operation result. Always 'success' on successful script creation. - **fileName** — string: Final filename of the script (may have suffix if duplicate was found). - **scriptId** — long: Unique ID assigned to the newly created script. ### HTTP Code 400 Response body: `application/json` - JSON object - **errorCode** — string: `CONFIG_FORM_INPUT_MISSING`: a required field is missing from the request. - **errorMessage** — string: Message indicating which input field is missing. ### HTTP Code 401 Response body: `application/json` - JSON object - **errorCode** — string: `UAC_UNAUTHORIZED`: user lacks the required role or access to all-customer scripts. - **errorMessage** — string: Authentication or authorization failure reason. ### HTTP Code 413 Response body: `application/json` - JSON object - **errorCode** — string: `SW_INTERNAL_ERROR`: insufficient storage to complete the operation. - **errorMessage** — string: Message indicating the server storage is full. ### HTTP Code 500 Response body: `application/json` - JSON object - **errorCode** — string: `INTERNAL_ERROR`: unexpected server error during processing. - **errorMessage** — string: Message describing the internal server error. ## Possible Response Codes - `200` — HTTP code - `400` — HTTP code - `401` — HTTP code - `413` — HTTP code - `500` — HTTP code ## Sample Responses ### HTTP 200 Script was added to the repository successfully. ```json { "fileName": "MyScript.bat", "scriptId": 67890, "status": "success" } ``` ### HTTP 400 File ID is missing from the request body. ```json { "errorMessage": "Some input field missing in configuration", "errorCode": "CONFIG_FORM_INPUT_MISSING" } ``` ### HTTP 401 Non-admin user attempted to create an all-customer script. ```json { "errorMessage": "Access denied", "errorCode": "UAC_UNAUTHORIZED" } ``` ### HTTP 413 Server does not have enough storage to add the script. ```json { "errorMessage": "Storage is full", "errorCode": "SW_INTERNAL_ERROR" } ``` ### HTTP 500 Unexpected server error while adding the script. ```json { "errorMessage": "Internal Server Error", "errorCode": "INTERNAL_ERROR" } ``` ## Rate Limits ![](https://www.zohowebstatic.com/sites/zweb/images/people/ico-help.png) **Duration:** 1 minute | **Threshold:** 30 | **Lock period:** 5 minutes Duration - Time window for the threshold. Threshold - Number of API calls allowed within the specified duration. Lock Period - Wait time before consecutive API requests.