{
  "openapi": "3.0.1",
  "info": {
    "title": "AI Code Runner Sandbox",
    "description": "Execute short JavaScript or Python snippets in a fresh bounded container process. Get structured status, stdout, stderr, parsed JSON, timing, and generated-file references for AI agents and automations.",
    "version": "0.1",
    "x-build-id": "KTsmT0oNoIWhC2TDQ"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/automation-lab~ai-code-runner-sandbox/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-automation-lab-ai-code-runner-sandbox",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/automation-lab~ai-code-runner-sandbox/runs": {
      "post": {
        "operationId": "runs-sync-automation-lab-ai-code-runner-sandbox",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/automation-lab~ai-code-runner-sandbox/run-sync": {
      "post": {
        "operationId": "run-sync-automation-lab-ai-code-runner-sandbox",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "executions": {
            "title": "🧩 Batch executions",
            "minItems": 1,
            "maxItems": 20,
            "type": "array",
            "description": "Optional ordered batch of 1–20 independent snippets. Do not combine this field with top-level language or code. Each item gets a fresh directory and its own limits; item timeouts must total at most 40 seconds.",
            "items": {
              "type": "object",
              "required": [
                "language",
                "code"
              ],
              "additionalProperties": true,
              "properties": {
                "id": {
                  "title": "Execution ID",
                  "description": "Optional caller-defined ID returned as executionId.",
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100
                },
                "language": {
                  "title": "Runtime language",
                  "description": "Runtime used for this snippet.",
                  "type": "string",
                  "enum": [
                    "javascript",
                    "python"
                  ]
                },
                "code": {
                  "title": "Code",
                  "description": "JavaScript or Python source code, up to 100 KB.",
                  "type": "string"
                },
                "parseJsonOutput": {
                  "title": "Parse stdout as JSON",
                  "description": "Parse complete stdout and expose it in result.",
                  "type": "boolean",
                  "default": false
                },
                "timeoutSeconds": {
                  "title": "Timeout (seconds)",
                  "description": "Wall timeout for this snippet.",
                  "type": "integer",
                  "default": 5,
                  "minimum": 1,
                  "maximum": 30
                },
                "maxOutputBytes": {
                  "title": "Output limit (bytes)",
                  "description": "Combined stdout/stderr cap for this snippet.",
                  "type": "integer",
                  "default": 256000,
                  "minimum": 1000,
                  "maximum": 1000000
                },
                "saveFiles": {
                  "title": "Generated files",
                  "description": "Up to 10 generated relative paths to save.",
                  "type": "array",
                  "default": [],
                  "maxItems": 10,
                  "items": {
                    "type": "string"
                  }
                },
                "maxSavedFileBytes": {
                  "title": "Saved-file limit (bytes)",
                  "description": "Combined saved-file cap for this snippet.",
                  "type": "integer",
                  "default": 5000000,
                  "minimum": 1000,
                  "maximum": 10000000
                }
              }
            }
          },
          "language": {
            "title": "🧩 Runtime language",
            "enum": [
              "javascript",
              "python"
            ],
            "type": "string",
            "description": "Choose the runtime for a legacy single execution. Omit this and code when using executions.",
            "default": "javascript"
          },
          "code": {
            "title": "Code",
            "type": "string",
            "description": "JavaScript or Python source code for a legacy single execution, up to 100 KB."
          },
          "stdin": {
            "title": "Standard input",
            "description": "A string or JSON value sent to the single snippet through stdin."
          },
          "parseJsonOutput": {
            "title": "Parse stdout as JSON",
            "type": "boolean",
            "description": "For a single execution, parse complete stdout and expose it in result.",
            "default": true
          },
          "timeoutSeconds": {
            "title": "⏱️ Execution timeout (seconds)",
            "minimum": 1,
            "maximum": 30,
            "type": "integer",
            "description": "Stop the single subprocess group after this many seconds.",
            "default": 5
          },
          "maxOutputBytes": {
            "title": "Combined output limit (bytes)",
            "minimum": 1000,
            "maximum": 1000000,
            "type": "integer",
            "description": "Maximum combined stdout and stderr bytes captured for the single execution.",
            "default": 256000
          },
          "saveFiles": {
            "title": "📁 Generated files to save",
            "maxItems": 10,
            "type": "array",
            "description": "For a single execution, relative generated paths to copy to the run key-value store. Up to 10 files.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "maxSavedFileBytes": {
            "title": "Saved-file limit (bytes)",
            "minimum": 1000,
            "maximum": 10000000,
            "type": "integer",
            "description": "Maximum combined size of generated files copied for the single execution.",
            "default": 5000000
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}