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

# Start Process

> Start a new process through the sandbox proxy, for example on `https://<sandbox-id-or-name>.sandbox.tensorlake.ai`.

Start a new process inside a sandbox.

## Endpoint

```http theme={null}
POST /api/v1/processes
```

Use this endpoint on the sandbox proxy host:

```text theme={null}
https://<sandbox-id-or-name>.sandbox.tensorlake.ai/api/v1/processes
```

## Example Request

```bash theme={null}
curl -X POST https://<sandbox-id>.sandbox.tensorlake.ai/api/v1/processes \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "command": "python",
    "args": ["-m", "http.server", "8080"],
    "env": {"PORT": "8080"},
    "working_dir": "/workspace",
    "user": "tl-user",
    "stdin_mode": "pipe",
    "stdout_mode": "capture",
    "stderr_mode": "capture"
  }'
```

## Request Body

```json theme={null}
{
  "command": "python",
  "args": ["-m", "http.server", "8080"],
  "env": {"PORT": "8080"},
  "working_dir": "/workspace",
  "user": "tl-user",
  "stdin_mode": "pipe",
  "stdout_mode": "capture",
  "stderr_mode": "capture"
}
```

* `command` is required.
* `args` defaults to `[]`.
* `env` defaults to `{}` and is applied to the process environment.
* `working_dir` is optional.
* `user` is optional and accepts a username, UID string, `uid:gid` string, or an object such as `{"uid": 1000, "gid": 1000}`. The default is `tl-user`.
* `stdin_mode` accepts `closed` or `pipe`. The default is `closed`.
* `stdout_mode` and `stderr_mode` accept `capture` or `discard`. The default is `capture`.

## Response

Tensorlake returns `201 Created` with the started process metadata:

```json theme={null}
{
  "handle": 1,
  "pid": 42,
  "status": "running",
  "exit_code": null,
  "signal": null,
  "stdin_writable": true,
  "command": "python",
  "args": ["-m", "http.server", "8080"],
  "started_at": 1710000000000,
  "ended_at": null
}
```

`handle` is a daemon-local stable identifier. Route paths use the operating-system `pid`.


## OpenAPI

````yaml post /api/v1/processes
openapi: 3.1.0
info:
  title: Tensorlake API
  description: >-
    Tensorlake Cloud APIs for Sandboxes, Document Ingestion, and Serverless
    Workflows
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://api.tensorlake.ai/
security:
  - bearerAuth: []
tags:
  - name: Tensorlake Cloud API
    description: >-
      Tensorlake Cloud APIs for Sandboxes, Document Ingestion, and Serverless
      Workflows
paths:
  /api/v1/processes:
    servers:
      - url: https://{identifier}.sandbox.tensorlake.ai
        description: >-
          Example sandbox proxy host for a specific running sandbox. For
          programmatic access, use the sandbox's `ingress_endpoint`.
        variables:
          identifier:
            default: example-sandbox
            description: The sandbox ID or sandbox name.
    post:
      tags:
        - sandbox-processes
      summary: Start a process
      description: >-
        Start a new process through the sandbox proxy, for example on
        `https://<sandbox-id-or-name>.sandbox.tensorlake.ai`.
      operationId: sandbox_process_start
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SandboxProcessStartRequest'
      responses:
        '201':
          description: Process created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxProcessInfo'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SandboxProxyError'
components:
  schemas:
    SandboxProcessStartRequest:
      type: object
      required:
        - command
      properties:
        command:
          type: string
        args:
          type: array
          items:
            type: string
        env:
          type: object
          additionalProperties:
            type: string
        working_dir:
          type: string
        user:
          $ref: '#/components/schemas/SandboxProcessUser'
        stdin_mode:
          $ref: '#/components/schemas/SandboxProcessStdinMode'
        stdout_mode:
          $ref: '#/components/schemas/SandboxProcessOutputMode'
        stderr_mode:
          $ref: '#/components/schemas/SandboxProcessOutputMode'
    SandboxProcessInfo:
      type: object
      required:
        - handle
        - pid
        - status
        - stdin_writable
        - command
        - args
        - started_at
      properties:
        handle:
          type: integer
          format: int64
        pid:
          type: integer
          format: int32
        status:
          $ref: '#/components/schemas/SandboxProcessStatus'
        exit_code:
          type:
            - integer
            - 'null'
          format: int32
        signal:
          type:
            - integer
            - 'null'
          format: int32
        stdin_writable:
          type: boolean
        command:
          type: string
        args:
          type: array
          items:
            type: string
        started_at:
          type: integer
          format: int64
        ended_at:
          type:
            - integer
            - 'null'
          format: int64
    SandboxProxyError:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        code:
          type: string
    SandboxProcessUser:
      oneOf:
        - type: string
          description: Username, UID string, or uid:gid string.
        - type: object
          properties:
            name:
              type: string
            uid:
              type: integer
              format: int32
            gid:
              type: integer
              format: int32
    SandboxProcessStdinMode:
      type: string
      enum:
        - closed
        - pipe
    SandboxProcessOutputMode:
      type: string
      enum:
        - capture
        - discard
    SandboxProcessStatus:
      type: string
      enum:
        - running
        - exited
        - signaled
        - oom_killed
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````