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

# Asynchronously execute a command via the Devbox shell

> Execute the given command in the Devbox shell asynchronously and returns the execution that can be used to track the command's progress.



## OpenAPI

````yaml /openapi-specs/stainless-processed-openapi.json post /v1/devboxes/{id}/execute_async
openapi: 3.1.0
info:
  title: RunLoop API
  version: '0.1'
  description: >-
    The RunLoop API spec that allows you to host lambda functions and Devboxes
    to enable scaled long running ai workflows.
  contact:
    name: Runloop AI Support
    url: https://runloop.ai
    email: support@runloop.ai
servers:
  - url: https://api.runloop.ai
    description: Runloop API
    variables: {}
security:
  - bearerAuth: []
tags:
  - name: Benchmark
  - name: Blueprint
  - name: Blueprint-Lifecycle
  - name: Blueprint-ObservabilityTools
  - name: Devbox
  - name: Devbox-FileTools
  - name: Devbox-Lifecycle
  - name: Devbox-NetworkTools
  - name: Devbox-ObservabilityTools
  - name: Devbox-PersistenceTools
  - name: Devbox-ShellTools
  - name: Scenario
  - name: ScenarioScorer
  - name: accounts
  - name: agents
  - name: apikeys
  - name: axons
  - name: executions
  - name: gateway-configs
  - name: mcp-configs
  - name: network-policies
  - name: objects
  - name: restricted_keys
  - name: secrets
  - name: streaming
paths:
  /v1/devboxes/{id}/execute_async:
    post:
      tags:
        - Devbox
        - Devbox-ShellTools
      summary: Asynchronously execute a command via the Devbox shell
      description: >-
        Execute the given command in the Devbox shell asynchronously and returns
        the execution that can be used to track the command's progress.
      operationId: execAsyncCommand
      parameters:
        - name: id
          in: path
          description: The Devbox ID.
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DevboxCreateExecutionParameters'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DevboxAsyncExecutionDetailView'
        '404':
          description: Devbox not found.
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Runloop from '@runloop/api-client';


            const client = new Runloop({
              bearerToken: process.env['RUNLOOP_API_KEY'], // This is the default and can be omitted
            });


            const devboxAsyncExecutionDetailView = await
            client.devboxes.executeAsync('id', {
              command: 'command',
            });


            console.log(devboxAsyncExecutionDetailView.devbox_id);
        - lang: Python
          source: |-
            import os
            from runloop_api_client import Runloop

            client = Runloop(
                bearer_token=os.environ.get("RUNLOOP_API_KEY"),  # This is the default and can be omitted
            )
            devbox_async_execution_detail_view = client.devboxes.execute_async(
                id="id",
                command="command",
            )
            print(devbox_async_execution_detail_view.devbox_id)
components:
  schemas:
    DevboxCreateExecutionParameters:
      type: object
      properties:
        command:
          type: string
          description: >-
            The command to execute via the Devbox shell. By default, commands
            are run from the user home directory unless shell_name is specified.
            If shell_name is specified the command is run from the directory
            based on the recent state of the persistent shell.
        shell_name:
          description: >-
            The name of the persistent shell to create or use if already
            created. When using a persistent shell, the command will run from
            the directory at the end of the previous command and environment
            variables will be preserved.
          type:
            - string
            - 'null'
        attach_stdin:
          description: >-
            Whether to attach stdin streaming for async commands. Not valid for
            execute_sync endpoint. Defaults to false if not specified.
          type:
            - boolean
            - 'null'
      required:
        - command
    DevboxAsyncExecutionDetailView:
      type: object
      properties:
        devbox_id:
          type: string
          description: Devbox id where command was executed.
        execution_id:
          type: string
          description: Ephemeral id of the execution in progress.
        status:
          $ref: '#/components/schemas/DevboxExecutionStatus'
          description: Current status of the execution.
        shell_name:
          description: Shell name.
          type:
            - string
            - 'null'
        stdout:
          description: >-
            Standard out generated by command. This field will remain unset
            until the execution has completed.
          type:
            - string
            - 'null'
        stderr:
          description: >-
            Standard error generated by command. This field will remain unset
            until the execution has completed.
          type:
            - string
            - 'null'
        exit_status:
          format: int32
          description: >-
            Exit code of command execution. This field will remain unset until
            the execution has completed.
          type:
            - integer
            - 'null'
        stdout_truncated:
          description: Indicates whether the stdout was truncated due to size limits.
          type:
            - boolean
            - 'null'
        stderr_truncated:
          description: Indicates whether the stderr was truncated due to size limits.
          type:
            - boolean
            - 'null'
      required:
        - devbox_id
        - execution_id
        - status
    DevboxExecutionStatus:
      type: string
      enum:
        - queued
        - running
        - completed
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````