{
  "_id": "@n8n/sandbox-client",
  "maintainers": [
    {
      "email": "cornelius@n8n.io",
      "name": "cornelius_n8n_io"
    },
    {
      "email": "matias.huhta@n8n.io",
      "name": "n8n-matsuuu"
    },
    {
      "email": "tomi+npm@n8n.io",
      "name": "tomin8n"
    },
    {
      "email": "jan@n8n.io",
      "name": "jan_n8n_io"
    },
    {
      "email": "charlie@n8n.io",
      "name": "n8n-charliekolb"
    }
  ],
  "dist-tags": {
    "latest": "0.0.4"
  },
  "_rev": "4-06ac4e5a321503acb87bc7abfad56927",
  "description": "Client for the n8n sandbox service API",
  "readme": "# @n8n/sandbox-client\n\nClient for the n8n sandbox service API.\n\n## Install\n\n```sh\npnpm add @n8n/sandbox-client\n```\n\n## Usage\n\n```ts\nimport { SandboxClient } from '@n8n/sandbox-client';\n\nconst client = new SandboxClient({\n  baseUrl: 'http://localhost:8080',\n  apiKey: 'your-api-key',\n});\n```\n\n### Retries (`retry` option)\n\nBy default the client retries transient failures: 3 extra attempts (four tries total), backoff with jitter, and HTTP statuses `429` and `503` (plus transport errors, represented as status `0`). `502` is not in the default retry set — the service uses it when repeating the same request is unlikely to help.\n\n- Turn off retries: `retry: { attempts: 0 }`.\n- Tune backoff: `retry: { attempts: 5, baseDelayMs: 100, maxDelayMs: 30_000, jitter: false }`.\n- Also retry other statuses (only if you accept the risk): `retry: { retryOnStatuses: [429, 502, 503] }`.\n- Idempotent methods (`GET`, `HEAD`, `OPTIONS`, `PUT`, `DELETE`) use this policy automatically.\n- `POST` is not retried unless you set `isSafeToRetry: true` on that specific request (for example when the server makes the operation idempotent, as with `exec_id` on exec).\n\n`exec` still has its own stream resume loop (`exec_id`, `POST` then `GET` follow). Constructor `retry` applies to each underlying HTTP call (so `GET` resume lines benefit from the default policy). It does not replace the exec event/state machine.\n\n### Sandbox lifecycle\n\n```ts\n// Create a sandbox\nconst sandbox = await client.createSandbox();\nconsole.log(sandbox.id); // UUID\n\n// Get sandbox info\nconst info = await client.getSandbox(sandbox.id);\n\n// Delete sandbox\nawait client.deleteSandbox(sandbox.id);\n```\n\n### Execute commands\n\n```ts\nconst result = await client.exec(sandbox.id, {\n  command: 'echo hello world',\n  env: { NODE_ENV: 'production' },\n  workdir: '/home/user',\n  timeoutMs: 30_000,\n});\n\nconsole.log(result.stdout);          // \"hello world\\n\"\nconsole.log(result.exitCode);        // 0\nconsole.log(result.success);         // true\nconsole.log(result.executionTimeMs); // 42\n```\n\nStream output as it arrives:\n\n```ts\nconst result = await client.exec(sandbox.id, {\n  command: 'npm install',\n  onStdout: (data) => process.stdout.write(data),\n  onStderr: (data) => process.stderr.write(data),\n});\n```\n\nCancel a running command:\n\n```ts\nconst controller = new AbortController();\nsetTimeout(() => controller.abort(), 5000);\n\nconst result = await client.exec(sandbox.id, {\n  command: 'sleep 60',\n  abortSignal: controller.signal,\n});\n```\n\n### File operations\n\n```ts\n// Write a file\nawait client.writeFile(sandbox.id, '/home/user/hello.txt', 'Hello, world!');\n\n// Write without overwriting\nawait client.writeFile(sandbox.id, '/home/user/hello.txt', 'new content', false);\n\n// Read a file\nconst buf = await client.readFile(sandbox.id, '/home/user/hello.txt');\nconsole.log(buf.toString());\n\n// Append to a file\nawait client.appendFile(sandbox.id, '/home/user/log.txt', 'new line\\n');\n\n// Delete a file\nawait client.deleteFile(sandbox.id, '/home/user/hello.txt');\n\n// Delete a directory recursively\nawait client.deleteFile(sandbox.id, '/home/user/node_modules', { recursive: true });\n\n// Create a directory\nawait client.mkdir(sandbox.id, '/home/user/src/components', true);\n\n// List files\nconst files = await client.listFiles(sandbox.id, {\n  path: '/home/user/src',\n  recursive: true,\n  extension: '.ts',\n});\n\n// Get file metadata\nconst stat = await client.stat(sandbox.id, '/home/user/hello.txt');\nconsole.log(stat.size, stat.type); // 13 \"file\"\n\n// Copy a file\nawait client.copyFile(sandbox.id, {\n  src: '/home/user/hello.txt',\n  dest: '/tmp/hello-copy.txt',\n});\n\n// Move / rename a file\nawait client.moveFile(sandbox.id, {\n  src: '/tmp/hello-copy.txt',\n  dest: '/tmp/renamed.txt',\n});\n```\n\n### Error handling\n\nAll API errors throw `SandboxServiceError`:\n\n```ts\nimport { SandboxServiceError } from '@n8n/sandbox-client';\n\ntry {\n  await client.getSandbox('nonexistent-id');\n} catch (err) {\n  if (err instanceof SandboxServiceError) {\n    console.log(err.status);  // 404\n    console.log(err.message); // \"sandbox not found\"\n  }\n}\n```\n\n## Development\n\n```sh\npnpm install\npnpm build       # Build CJS + ESM + types\npnpm typecheck   # Type-check without emitting\npnpm test        # Run tests once\npnpm test:dev    # Run tests in watch mode\n```\n",
  "repository": {
    "url": "git+https://github.com/n8n-io/n8n-sandbox-service.git",
    "type": "git",
    "directory": "sdk"
  },
  "bugs": {
    "url": "https://github.com/n8n-io/n8n-sandbox-service/issues"
  },
  "versions": {
    "0.0.1": {
      "name": "@n8n/sandbox-client",
      "version": "0.0.1",
      "_id": "@n8n/sandbox-client@0.0.1",
      "maintainers": [
        {
          "name": "n8n-matsuuu",
          "email": "matias.huhta@n8n.io"
        },
        {
          "name": "tomin8n",
          "email": "tomi+npm@n8n.io"
        },
        {
          "name": "jan_n8n_io",
          "email": "jan@n8n.io"
        },
        {
          "name": "cornelius.suermann",
          "email": "cornelius.suermann+npm@gmail.com"
        }
      ],
      "dist": {
        "shasum": "8a2caafa8877b281f765d8a560a08de2dda70cb5",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@n8n/sandbox-client/-/sandbox-client-0.0.1.tgz",
        "fileCount": 8,
        "integrity": "sha512-qvfc8/qv+rPz0nsM/r0pL/tWm5Rcry3X/d80/uxobBkWDtjZs9cFj10NBzU8+yrSs8F3dsk08FIWyVCzSt9jKA==",
        "signatures": [
          {
            "sig": "MEUCIBOXhE/1RVaobMqBByClHwIyvxPUvnCRzqrhgNuScAw6AiEA7PYMBgL/gP2grocEVwBulmDY5pRLfpCvDWAD5dZSXEg=",
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
          }
        ],
        "unpackedSize": 77545
      },
      "main": "./dist/index.js",
      "types": "./dist/index.d.ts",
      "module": "./dist/index.mjs",
      "engines": {
        "node": ">=22.16",
        "pnpm": ">=10.22.0"
      },
      "exports": {
        ".": {
          "types": "./dist/index.d.ts",
          "import": "./dist/index.mjs",
          "require": "./dist/index.js"
        }
      },
      "scripts": {
        "fmt": "oxfmt src/ test/",
        "lint": "oxlint src/ test/",
        "test": "vitest run",
        "build": "tsup",
        "lint:fix": "oxlint --fix src/ test/",
        "test:dev": "vitest",
        "fmt:check": "oxfmt --check src/ test/",
        "typecheck": "tsc --noEmit"
      },
      "_npmUser": {
        "name": "tomin8n",
        "email": "tomi+npm@n8n.io"
      },
      "_npmVersion": "10.9.4",
      "description": "Client for the n8n sandbox service API",
      "directories": {},
      "_nodeVersion": "22.21.1",
      "dependencies": {
        "axios": "^1.15.0"
      },
      "_hasShrinkwrap": false,
      "devDependencies": {
        "tsup": "^8.0.0",
        "oxfmt": "^0.47.0",
        "oxlint": "^1.62.0",
        "vitest": "^4.1.1",
        "typescript": "6.0.2",
        "@types/node": "^22.16.0"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/sandbox-client_0.0.1_1778066106911_0.14257870704412445",
        "host": "s3://npm-registry-packages-npm-production"
      }
    },
    "0.0.4": {
      "name": "@n8n/sandbox-client",
      "version": "0.0.4",
      "_id": "@n8n/sandbox-client@0.0.4",
      "maintainers": [
        {
          "name": "n8n-matsuuu",
          "email": "matias.huhta@n8n.io"
        },
        {
          "name": "tomin8n",
          "email": "tomi+npm@n8n.io"
        },
        {
          "name": "jan_n8n_io",
          "email": "jan@n8n.io"
        },
        {
          "name": "cornelius.suermann",
          "email": "cornelius.suermann+npm@gmail.com"
        }
      ],
      "homepage": "https://github.com/n8n-io/n8n-sandbox-service#readme",
      "bugs": {
        "url": "https://github.com/n8n-io/n8n-sandbox-service/issues"
      },
      "dist": {
        "shasum": "b2e23b073e0f8b1200bc936fd57e613db9b815c1",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/@n8n/sandbox-client/-/sandbox-client-0.0.4.tgz",
        "fileCount": 8,
        "integrity": "sha512-yaCVqz2MCHfmNkPQObiXiM9x3hzy/S+Ey2+WIe3TazFsXz1A02cZudt7eO1MW1J0O7IKU1mqe1xPmchHN3+6Vw==",
        "signatures": [
          {
            "sig": "MEUCIFAUcrD6MkzrpYQ9jwaFPDA8wE9uwssYkga2UwubjnhVAiEAsBDD0/O65HI1HDbI69uixLBQuYx5KjtR1INoV9ayEn8=",
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
          }
        ],
        "attestations": {
          "url": "https://registry.npmjs.org/-/npm/v1/attestations/@n8n%2fsandbox-client@0.0.4",
          "provenance": {
            "predicateType": "https://slsa.dev/provenance/v1"
          }
        },
        "unpackedSize": 117383
      },
      "main": "./dist/index.js",
      "_from": "file:n8n-sandbox-client-0.0.4.tgz",
      "types": "./dist/index.d.ts",
      "module": "./dist/index.mjs",
      "engines": {
        "node": ">=22.16",
        "pnpm": ">=10.22.0"
      },
      "exports": {
        ".": {
          "types": "./dist/index.d.ts",
          "import": "./dist/index.mjs",
          "require": "./dist/index.js"
        }
      },
      "scripts": {
        "fmt": "oxfmt src/ test/",
        "lint": "oxlint src/ test/",
        "test": "vitest run",
        "build": "tsup",
        "lint:fix": "oxlint --fix src/ test/",
        "test:dev": "vitest",
        "fmt:check": "oxfmt --check src/ test/",
        "typecheck": "tsc --noEmit"
      },
      "_npmUser": {
        "name": "GitHub Actions",
        "email": "npm-oidc-no-reply@github.com",
        "trustedPublisher": {
          "id": "github",
          "oidcConfigId": "oidc:ed8b5844-fd7b-46f8-9544-a5f9156fab41"
        }
      },
      "_resolved": "/tmp/22b7558da5768f1010b9b6d8659c2731/n8n-sandbox-client-0.0.4.tgz",
      "_integrity": "sha512-yaCVqz2MCHfmNkPQObiXiM9x3hzy/S+Ey2+WIe3TazFsXz1A02cZudt7eO1MW1J0O7IKU1mqe1xPmchHN3+6Vw==",
      "repository": {
        "url": "git+https://github.com/n8n-io/n8n-sandbox-service.git",
        "type": "git",
        "directory": "sdk"
      },
      "_npmVersion": "11.11.0",
      "description": "Client for the n8n sandbox service API",
      "directories": {},
      "_nodeVersion": "24.14.1",
      "dependencies": {
        "axios": "^1.15.0"
      },
      "publishConfig": {
        "access": "public",
        "provenance": true
      },
      "_hasShrinkwrap": false,
      "devDependencies": {
        "tsup": "^8.0.0",
        "oxfmt": "^0.47.0",
        "oxlint": "^1.62.0",
        "vitest": "^4.1.1",
        "typescript": "6.0.2",
        "@types/node": "^22.16.0"
      },
      "_npmOperationalInternal": {
        "tmp": "tmp/sandbox-client_0.0.4_1778663406092_0.5151419583719348",
        "host": "s3://npm-registry-packages-npm-production"
      }
    }
  },
  "name": "@n8n/sandbox-client",
  "time": {
    "created": "2026-05-06T11:15:06.786Z",
    "modified": "2026-07-15T20:06:01.604Z",
    "0.0.1": "2026-05-06T11:15:07.053Z",
    "0.0.4": "2026-05-13T09:10:06.328Z"
  },
  "readmeFilename": "README.md",
  "homepage": "https://github.com/n8n-io/n8n-sandbox-service#readme"
}