
Virtual Machine Sandbox
API Overview
Our own services
API Console
Log in to explore more features! Click to Log In
API Reference (9)
| API Description | API Endpoint | Request Method | Stability | Parameter Description |
|---|---|---|---|---|
One-click Code Execution | POST | Stable | View Details | |
Document Details Automatically create a sandbox, and destroy it immediately after execution. Optional feature to export sandbox files (if there are multiple files in the directory, they will be compressed into a zip file for export; a single file will be exported directly). This interface is recommended if continuous sandbox operations are not required. Price: Sandbox runtime (seconds) * 0.001 PTC + Exporting sandbox files to the 302 file system (0.001 PTC/call) Related MCP Server: https://github.com/302ai/302_sandbox_mcp/blob/main/README.md Request Parameters Header ParametersAuthorizationstringRequired Example Value: Bearer {{YOUR_API_KEY}}Request Body application/jsonlanguageenum<string>Optional If not specified or if the value is out of the selectable range, it will be treated as Python code. Enum Value: pythonrjavabashjscodestringRequired envsobjectOptional Supports passing environment variables. is_downloadbooleanOptional If the code’s function is to generate files, enabling this option is required to obtain the files. download_pathstringOptional For Linux file paths, if the code does not specify a save path, you may omit it, and the system will return files from the default save directory timeoutintegerOptional | ||||
Create Sandbox | POST | Stable | View Details | |
Document Details After successful creation, the sandbox will automatically pause. When you call other sandbox operation interfaces, the sandbox will automatically reconnect, and after execution, it will pause again to avoid unnecessary costs. (Note: Pausing and reconnecting will take some time, approximately 5 seconds in total.) Sandbox information is associated with the 302 API key, and you can only operate the sandbox of the current API key. Price: Sandbox runtime (seconds) * 0.001 PTC Request Parameters Header ParametersAuthorizationstringRequired Example Value: Bearer {{YOUR_API_KEY}}Request Body application/jsonmax_alive_timeintegerRequired sandbox_namestringOptional metadataobjectOptional envsobjectOptional | ||||
Query Your Sandbox List | GET | Stable | View Details | |
Document Details Sandbox information is bound to the API key, so you can only query the sandbox information associated with the current API key. Price:0 PTC/call Request Parameters Header ParametersAuthorizationstringRequired Example Value: Bearer {{YOUR_API_KEY}}Query Parameterssandbox_namestringOptional sandbox_idstringOptional | ||||
Destroy Sandbox | POST | Stable | View Details | |
Document Details Price:0 PTC/call Request Parameters Path Parameterssandbox_idstringRequired Header ParametersAuthorizationstringOptional Example Value: Bearer {{YOUR_API_KEY}} | ||||
Run-Code | POST | Stable | View Details | |
Document Details This interface only returns text-type outputs. If the code involves file generation or similar operations, please use the “View File” interface to check file information and the “Export File” interface to export files. Price: Sandbox runtime duration (seconds) * 0.001 PTC Request Parameters Header ParametersAuthorizationstringRequired Example Value: Bearer {{YOUR_API_KEY}}Request Body application/jsonlanguageenum<string>Optional If not provided or if the value is out of the selectable range, it will be treated as Python code Enum Value: pythonrjavabashjscodestringRequired envsobjectOptional Supports passing environment variables timeoutintegerOptional Sandbox execution timeout sandbox_idstringRequired | ||||
Run Command Line | POST | Stable | View Details | |
Document Details This interface only returns text-type outputs. If the command involves file generation or similar operations, please use the “View File” interface to check file information and the “File Download” interface to export files to the 302 file system. Price: Sandbox runtime duration (seconds) * 0.001 PTC Request Parameters Header ParametersAuthorizationstringRequired Example Value: Bearer {{YOUR_API_KEY}}Request Body application/jsonenvsobjectOptional Supports passing environment variables timeoutintegerOptional 沙盒执行的超时时间 cmdstringRequired sandbox_idstringRequired | ||||
Query File Information at Specified Path | POST | Stable | View Details | |
Document Details Supports batch queries; you can pass a list of paths. Price: 0 PTC/call Request Parameters Header ParametersAuthorizationstringOptional Example Value: Bearer {{YOUR_API_KEY}}Request Body application/jsonsandbox_idstringRequired pathanyOfRequired | ||||
Import File Data into Sandbox | POST | Stable | View Details | |
Document Details Supports batch import. If a file exists at the save path, it will be overwritten. If the folder at the save path does not exist, it will be automatically created. Price: Sandbox runtime duration (seconds) * 0.001 PTC Request Parameters Header ParametersAuthorizationstringRequired Example Value: Bearer {{YOUR_API_KEY}}Request Body application/jsonsandbox_idstringRequired file_listarray[object]Required filestringRequired save_pathstringRequired 需要Linux系统的路径 | ||||
Export Sandbox Files | POST | Stable | View Details | |
Document Details Supports Batch Export Price: Sandbox runtime duration (seconds) * 0.001 PTC + Uploading exported sandbox files to 302 file system (0.001 PTC/call) When exporting folders, system files are filtered out. Only the following common file formats are exported:
Request Parameters Header ParametersAuthorizationstringOptional Example Value: Bearer {{YOUR_API_KEY}}Request Body application/jsonsandbox_idstringRequired pathanyOfRequired 支持导出文件/文件夹 | ||||
API Pricing
| Model | Description | 302.AI Price |
|---|
One-click Code Execution | Run Code |
|
Create Sandbox | Create Sandbox |
|
Query Your Sandbox List | Query Your Sandbox List |
|
Destroy Sandbox | Destroy Sandbox |
|
Run-Code | Run-Code |
|
Run Command Line | Run Command Line |
|
Query File Information at Specified Path | Query File Information at Specified Path |
|
Import File Data into Sandbox | Import File Data into Sandbox |
|
Export Sandbox Files | Export Sandbox Files |
|