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

# Execute a command

> Execute a command and return process information. If Accept header is text/event-stream, streams logs in SSE format and returns the process response as a final event.



## OpenAPI

````yaml https://raw.githubusercontent.com/blaxel-ai/sandbox/refs/heads/main/sandbox-api/docs/openapi.yml post /process
openapi: 3.0.0
info:
  contact: {}
  description: API for manipulating filesystem, processes and network.
  title: Sandbox API
  version: 0.0.1
servers:
  - url: https://sbx-{sandbox_id}-{workspace_id}.{region}.bl.run
    variables:
      sandbox_id:
        default: unknown
      workspace_id:
        default: unknown
      region:
        default: unknown
security:
  - BearerAuth: []
paths:
  /process:
    post:
      tags:
        - process
      summary: Execute a command
      description: >-
        Execute a command and return process information. If Accept header is
        text/event-stream, streams logs in SSE format and returns the process
        response as a final event.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcessRequest'
        description: Process execution request
        required: true
      responses:
        '200':
          description: Process information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProcessResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ProcessResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
            text/event-stream:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ProcessRequest:
      properties:
        command:
          example: ls -la
          type: string
        env:
          additionalProperties:
            type: string
          example:
            '{"PORT"': ' "3000"}'
          type: object
        keepAlive:
          description: >-
            Disable scale-to-zero while process runs. Default timeout is 600s
            (10 minutes). Set timeout to 0 for infinite.
          example: false
          type: boolean
        maxRestarts:
          example: 3
          type: integer
        name:
          example: my-process
          type: string
        restartOnFailure:
          example: true
          type: boolean
        timeout:
          description: >-
            Timeout in seconds. When keepAlive is true, defaults to 600s (10
            minutes). Set to 0 for infinite (no auto-kill).
          example: 30
          type: integer
        waitForCompletion:
          example: false
          type: boolean
        waitForPorts:
          example:
            - 3000
            - 8080
          items:
            type: integer
          type: array
        workingDir:
          example: /home/user
          type: string
      required:
        - command
      type: object
    ProcessResponse:
      properties:
        command:
          example: ls -la
          type: string
        completedAt:
          example: Wed, 01 Jan 2023 12:01:00 GMT
          type: string
        exitCode:
          example: 0
          type: integer
        keepAlive:
          description: Whether scale-to-zero is disabled for this process
          example: false
          type: boolean
        logs:
          example: logs output
          type: string
        maxRestarts:
          example: 3
          type: integer
        name:
          example: my-process
          type: string
        pid:
          example: '1234'
          type: string
        restartCount:
          example: 2
          type: integer
        restartOnFailure:
          example: true
          type: boolean
        startedAt:
          example: Wed, 01 Jan 2023 12:00:00 GMT
          type: string
        status:
          enum:
            - failed
            - killed
            - stopped
            - running
            - completed
          example: running
          type: string
        stderr:
          example: stderr output
          type: string
        stdout:
          example: stdout output
          type: string
        workingDir:
          example: /home/user
          type: string
      required:
        - command
        - completedAt
        - exitCode
        - logs
        - name
        - pid
        - startedAt
        - status
        - stderr
        - stdout
        - workingDir
      type: object
    ErrorResponse:
      properties:
        error:
          example: Error message
          type: string
      required:
        - error
      type: object
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````