---
title: "Execute a command asynchronously"
method: POST
path: "/browsers/{id_or_name}/process/spawn"
tags: ["Browser Processes"]
---

# Execute a command asynchronously

`POST /browsers/{id_or_name}/process/spawn`

## Request

- Base URL: `https://api.onkernel.com`
- URL: `https://api.onkernel.com/browsers/{id_or_name}/process/spawn`
- Auth: HTTP bearer

## Path parameters

- `id_or_name` string, required

## Request body

- ProcessSpawnRequest: Request to execute a command synchronously.
  - `args` string[]: Command arguments.
  - `as_root` boolean: Run the process with root privileges.
  - `as_user` string, nullable: Run the process as this user.
  - `command` string, required: Executable or shell command to run.
  - `cwd` string, nullable: Working directory (absolute path) to run the command in.
  - `env` object: Environment variables to set for the process.
  - `timeout_sec` integer, nullable: Maximum execution time in seconds.
  - `allocate_tty` boolean: Allocate a pseudo-terminal (PTY) for interactive shells.
  - `cols` integer: Initial terminal columns. Only used when allocate_tty is true.
  - `rows` integer: Initial terminal rows. Only used when allocate_tty is true.

## Response `200`

Spawned

- ProcessSpawnResult: Information about a spawned process.
  - `pid` integer: OS process ID.
  - `process_id` string, uuid: Server-assigned identifier for the process.
  - `started_at` string, date-time: Timestamp when the process started.

## Other responses

- `400`: Bad Request – invalid input
- `404`: Resource not found
- `500`: Internal Server Error
- `default`: Error returned by the browser or its proxy

---

[API](https://skmtc.dev/kernel/apis/kernel-api.md) - [All operations](https://skmtc.dev/kernel/apis/kernel-api/llms.txt) - [OpenAPI document](https://skmtc.dev/kernel/apis/kernel-api/revisions/0f6cf4f58fe6?raw)
