---
title: "Perform an action on the desktop"
method: POST
path: "/v1/desktop/{id}/computer-action"
tags: ["Desktop"]
---

# Perform an action on the desktop

`POST /v1/desktop/{id}/computer-action`

Executes a computer action such as mouse clicks, keyboard input, or screenshots on the desktop

## Path parameters

- `id` string, required — Desktop instance ID to perform the action on

## Headers

- `x-api-key` string, required — API key for authentication

## Request body

- union
  - object
    - `type` 'click_mouse', required — Perform a mouse action: click, press (down), or release (up). Defaults to a single left click at the current position.
    - `x` integer — X coordinate for the action (optional, uses current position if omitted)
    - `y` integer — Y coordinate for the action (optional, uses current position if omitted)
    - `button` 'left' | 'right' | 'middle' — Mouse button to use (optional, defaults to 'left')
    - `num_of_clicks` integer — Number of clicks to perform (optional, defaults to 1, only applicable for 'click' type)
    - `click_type` 'click' | 'down' | 'up' — Type of mouse action (optional, defaults to 'click')
  - object
    - `type` 'scroll', required — Scroll the mouse wheel in the specified direction
    - `direction` 'up' | 'down' | 'left' | 'right', required — Direction to scroll
    - `amount` integer, required — Amount to scroll in pixels
  - object
    - `type` 'move_mouse', required — Move the mouse cursor to the specified coordinates
    - `x` integer, required — X coordinate to move to
    - `y` integer, required — Y coordinate to move to
  - object
    - `type` 'drag_mouse', required — Drag the mouse from start to end coordinates
    - `start` object, required — Starting coordinates for the drag operation
      - `x` integer, required — X coordinate on the screen
      - `y` integer, required — Y coordinate on the screen
    - `end` object, required — Ending coordinates for the drag operation
      - `x` integer, required — X coordinate on the screen
      - `y` integer, required — Y coordinate on the screen
  - object
    - `type` 'type', required — Type text at the current cursor position
    - `text` string, required — Text to type
  - object
    - `type` 'press_keys', required — Press, hold down, or release one or more keyboard keys. Defaults to a single press and release.
    - `keys` union, required
      - string — Single key to press
      - string[] — Multiple keys to press simultaneously
    - `key_action_type` 'press' | 'down' | 'up' — Type of key action (optional, defaults to 'press' which is a down and up action)
  - object
    - `type` 'wait', required — Wait for the specified number of milliseconds
    - `ms` integer, required — Time to wait in milliseconds
  - object
    - `type` 'screenshot', required — Take a screenshot of the desktop
  - object
    - `type` 'get_cursor_position', required — Get the current mouse cursor position

## Response `200`

Action executed successfully. Response may contain output or image data depending on the action.

- object
  - `output` string — Raw string output from the executed command (if any)
  - `error` string — Error message if the operation failed (also indicated by non-2xx HTTP status)
  - `base64_image` string — Base64 encoded JPEG image data (only returned for screenshot actions)

## Other responses

- `400` — The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
- `401` — Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.
- `403` — The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server.
- `404` — The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
- `409` — This response is sent when a request conflicts with the current state of the server.
- `429` — The user has sent too many requests in a given amount of time ("rate limiting")
- `500` — The server has encountered a situation it does not know how to handle.
- `502` — The server, while acting as a gateway or proxy, received an invalid response from the upstream server.

---

[API](https://skmtc.net/cyberdesk-hq/apis/api-reference.md) · [All operations](https://skmtc.net/cyberdesk-hq/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cyberdesk-hq/api-reference/versions/586b758d6514/schema)
