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

# Drag

> Simulates a drag gesture, moving from a start point to an end point over a set duration. Supports simple start/end coordinates, multi-point drag paths, and natural-language targets.



## OpenAPI

````yaml post /boxes/{boxId}/actions/drag
openapi: 3.0.0
info:
  title: GBOX Open API
  description: GBOX Open API Documentation
  version: '1.0'
  contact: {}
servers:
  - url: https://gbox.ai/api/v1
    description: Production Server
security: []
tags: []
paths:
  /boxes/{boxId}/actions/drag:
    post:
      tags:
        - UI Action
      summary: Drag
      description: >-
        Simulates a drag gesture, moving from a start point to an end point over
        a set duration. Supports simple start/end coordinates, multi-point drag
        paths, and natural-language targets.
      operationId: UIActionController_drag
      parameters:
        - name: boxId
          required: true
          in: path
          description: Box ID
          schema:
            example: c9bdc193-b54b-4ddb-a035-5ac0c598d32d
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/DragSimple'
                - $ref: '#/components/schemas/DragAdvanced'
            examples:
              Basic:
                summary: Basic drag
                value:
                  start:
                    x: 100
                    'y': 100
                  end:
                    x: 200
                    'y': 200
              NaturalLanguage:
                summary: Drag using natural language
                value:
                  start: login button
                  end: submit button
              MultiPoint:
                summary: Multi-point drag
                value:
                  path:
                    - x: 100
                      'y': 100
                    - x: 200
                      'y': 200
                    - x: 300
                      'y': 300
                  duration: 500ms
      responses:
        '200':
          description: Drag action result with actual parameters used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DragActionResult'
      security:
        - bearer: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import GboxSDK from "gbox-sdk";

            const gboxSDK = new GboxSDK({
              apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
            });

            async function main() {
              const box = await gboxSDK.create({ type: "android" });

              await box.action.drag({
                start: { x: 100, y: 150 },
                end: { x: 200, y: 200 },
                duration: "50ms"
              });

              // Natural language start/end 
              await box.action.drag({
                start: "Chrome App",
                end: "Trash",
                duration: "800ms"
              });

              await box.action.drag({
                path: [
                  { x: 100, y: 150 },
                  { x: 200, y: 200 },
                  { x: 300, y: 250 }
                ],
                duration: "50ms"
              });
            }

            main();
        - lang: Python
          source: |-
            import os
            from gbox_sdk import GboxSDK


            def main():
                gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])

                # Create Android box
                box = gbox_sdk.create(type="android")

                # Drag action (advanced path)
                box.action.drag(
                    path=[
                        {"x": 100, "y": 150},
                        {"x": 200, "y": 200},
                        {"x": 300, "y": 250}
                    ],
                    duration="50ms"
                )

                # Drag action (simple coordinates)
                box.action.drag(
                    start={"x": 100, "y": 150},
                    end={"x": 200, "y": 200},
                    duration="50ms"
                )

                # Drag action (natural language, realistic Android example)
                # Drag the "Chrome" app icon to the launcher "Remove" target at the top bar
                box.action.drag(
                    start="Chrome",
                    end="Remove",
                    duration="800ms"
                )


            if __name__ == "__main__":
                main()
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/gbox/gbox-sdk-go\"\n)\n\nfunc main() {\n\tgboxSDK := gbox.NewGboxSDK(os.Getenv(\"GBOX_API_KEY\"))\n\n\tbox, err := gboxSDK.Create(context.Background(), gbox.CreateBoxRequest{\n\t\tType: \"android\",\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to create box: %v\", err)\n\t}\n\n\t// Drag action (advanced path)\n\terr = box.Action.Drag(context.Background(), gbox.DragRequest{\n\t\tPath: []gbox.DragPathPoint{\n\t\t\t{X: 100, Y: 150},\n\t\t\t{X: 200, Y: 200},\n\t\t\t{X: 300, Y: 250},\n\t\t},\n\t\tDuration: \"50ms\",\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to perform drag action: %v\", err)\n\t}\n\n\t// Drag action (simple coordinates)\n\terr = box.Action.Drag(context.Background(), gbox.DragRequest{\n\t\tStart: gbox.DragPathPoint{X: 100, Y: 150},\n\t\tEnd:   gbox.DragPathPoint{X: 200, Y: 200},\n\t\tDuration: \"50ms\",\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to perform drag action: %v\", err)\n\t}\n\n\t// Drag action (natural language, realistic Android example)\n\t// Drag the \"Chrome\" app icon to the launcher \"Remove\" target at the top bar\n\terr = box.Action.Drag(context.Background(), gbox.DragRequest{\n\t\tStart: \"Chrome\",\n\t\tEnd:   \"Remove\",\n\t\tDuration: \"800ms\",\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to perform drag action: %v\", err)\n\t}\n}"
components:
  schemas:
    DragSimple:
      type: object
      properties:
        start:
          description: Start point of the drag path (coordinates or natural language)
          oneOf:
            - $ref: '#/components/schemas/DragPathPoint'
              example:
                x: 100
                'y': 150
            - type: string
              example: Top-left corner of the screen
        end:
          description: End point of the drag path (coordinates or natural language)
          oneOf:
            - $ref: '#/components/schemas/DragPathPoint'
              example:
                x: 400
                'y': 300
            - type: string
              example: Bottom-right corner of the screen
        duration:
          type: string
          description: >-
            Duration to complete the movement from start to end coordinates


            Supported time units: ms (milliseconds), s (seconds), m (minutes), h
            (hours)

            Example formats: "500ms", "30s", "5m", "1h"

            Default: 500ms
          example: 500ms
          default: 500ms
          title: DragDuration
        options:
          description: >-
            Action options. When `options.screenshot` is provided, ALL
            deprecated screenshot fields (outputFormat, presignedExpiresIn,
            screenshotDelay, screenshotRange, includeScreenshot) will be
            completely ignored.
          example:
            screenshot:
              outputFormat: base64
              presignedExpiresIn: 30m
              delay: 500ms
              phases:
                - before
                - after
          allOf:
            - $ref: '#/components/schemas/ActionCommonOptions'
      title: Drag Simple
      description: |+
        Drag action configuration with start and end points.

        Operation flow:
        1. Touch finger at "start" coordinates
        2. Move to "end" coordinates within the "duration" time and lift finger

      required:
        - start
        - end
    DragAdvanced:
      type: object
      properties:
        path:
          description: Path of the drag action as a series of coordinates
          example:
            - x: 100
              'y': 150
            - x: 200
              'y': 200
            - x: 300
              'y': 250
          type: array
          items:
            $ref: '#/components/schemas/DragPathPoint'
        duration:
          type: string
          description: >-
            Time interval between points (e.g. "50ms")


            Supported time units: ms (milliseconds), s (seconds), m (minutes), h
            (hours)

            Example formats: "500ms", "30s", "5m", "1h"

            Default: 50ms
          example: 50ms
          default: 50ms
          title: DragDuration
        options:
          description: >-
            Action options. When `options.screenshot` is provided, ALL
            deprecated screenshot fields (outputFormat, presignedExpiresIn,
            screenshotDelay, screenshotRange, includeScreenshot) will be
            completely ignored.
          example:
            screenshot:
              outputFormat: base64
              presignedExpiresIn: 30m
              delay: 500ms
              phases:
                - before
                - after
          allOf:
            - $ref: '#/components/schemas/ActionCommonOptions'
      title: Drag Advanced
      description: Drag action configuration with path points
      required:
        - path
    DragActionResult:
      type: object
      properties:
        message:
          type: string
          description: message
          example: Action executed successfully
        actionId:
          type: string
          description: >-
            Unique identifier for each action. Use this ID to locate the action
            and report issues.
          example: c9bdc193-b54b-4ddb-a035-5ac0c598d32d
        screenshot:
          description: >-
            Optional screenshot data. Only present when screenshots are
            requested via options.screenshot.phases or deprecated fields
          example:
            trace:
              uri: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
            before:
              uri: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
            after:
              uri: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
          allOf:
            - $ref: '#/components/schemas/ActionResultScreenshot'
        actual:
          description: Actual parameters used when executing the drag action
          example:
            start:
              x: 100
              'y': 150
            end:
              x: 400
              'y': 300
            duration: 500ms
          allOf:
            - $ref: '#/components/schemas/DragActionActual'
      title: Drag Action Result
      description: Result of drag action execution with actual parameters used
      required:
        - message
        - actionId
        - actual
    DragPathPoint:
      type: object
      properties:
        x:
          type: number
          description: X coordinate of a point in the drag path
          example: 200
        'y':
          type: number
          description: Y coordinate of a point in the drag path
          example: 300
      title: Drag Path Point
      description: Single point in a drag path
      required:
        - x
        - 'y'
    ActionCommonOptions:
      type: object
      properties:
        screenshot:
          description: >-
            Screenshot options. Can be a boolean to enable/disable screenshots,
            or an object to configure screenshot options.
          oneOf:
            - $ref: '#/components/schemas/ActionScreenshotOptions'
              example:
                outputFormat: base64
                presignedExpiresIn: 30m
                delay: 500ms
                phases:
                  - before
                  - after
            - type: boolean
              example: true
        model:
          type: string
          description: >-
            Model to use for natural-language target resolution. Defaults to
            'uitars'.
          enum:
            - gpt-5
            - gpt-4o
            - gelato
            - ui-tars
            - openai-computer-use
          default: gelato
      title: Action Common Options
      description: Action common options
    ActionResultScreenshot:
      type: object
      properties:
        trace:
          description: URI of the screenshot before the action with operation trace
          example:
            uri: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
          allOf:
            - $ref: '#/components/schemas/ActionResultOperationTrace'
        before:
          description: URI of the screenshot before the action
          example:
            uri: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
          allOf:
            - $ref: '#/components/schemas/ActionResultScreenshotBefore'
        after:
          description: URI of the screenshot after the action
          example:
            uri: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
          allOf:
            - $ref: '#/components/schemas/ActionResultScreenshotAfter'
      title: Action Result Screenshot
      description: Complete screenshot result with operation trace, before and after images
    DragActionActual:
      type: object
      properties:
        start:
          description: Start point of the drag
          example:
            x: 100
            'y': 150
          allOf:
            - $ref: '#/components/schemas/DragPathPoint'
        end:
          description: End point of the drag
          example:
            x: 400
            'y': 300
          allOf:
            - $ref: '#/components/schemas/DragPathPoint'
        duration:
          type: string
          description: >-
            Duration of the drag


            Supported time units: ms (milliseconds), s (seconds), m (minutes), h
            (hours)

            Example formats: "500ms", "30s", "5m", "1h"

            Default: 500ms
          example: 500ms
          default: 500ms
          title: DragDuration
      title: Drag Action Actual Parameters
      description: Actual parameters used when executing the drag action
      required:
        - start
        - end
        - duration
    ActionScreenshotOptions:
      type: object
      properties:
        outputFormat:
          type: string
          enum:
            - base64
            - storageKey
          description: Type of the URI. default is base64.
          default: base64
          example: base64
        presignedExpiresIn:
          type: string
          description: >-
            Presigned url expires in. Only takes effect when outputFormat is
            storageKey.


            Supported time units: ms (milliseconds), s (seconds), m (minutes), h
            (hours)

            Example formats: "500ms", "30s", "5m", "1h"

            Default: 30m
          example: 30m
          default: 30m
          title: PresignedExpiresIn
        delay:
          type: string
          description: >-
            Delay after performing the action, before taking the final
            screenshot.


            Execution flow:

            1. Take screenshot before action

            2. Perform the action

            3. Wait for screenshotDelay (this parameter)

            4. Take screenshot after action


            Example: '500ms' means wait 500ms after the action before capturing
            the final screenshot.


            Supported time units: ms (milliseconds), s (seconds), m (minutes), h
            (hours)

            Example formats: "500ms", "30s", "5m", "1h"

            Default: 500ms

            Maximum allowed: 30s
          example: 500ms
          default: 500ms
          title: Delay
        phases:
          type: array
          description: >-
            Specify which screenshot phases to capture.


            Available options:

            - before: Screenshot before the action

            - after: Screenshot after the action

            - trace: Screenshot with operation trace


            Default captures all three phases. Can specify one or multiple in an
            array.

            If empty array is provided, no screenshots will be taken.
          default:
            - before
            - after
            - trace
          example:
            - before
            - after
          items:
            type: string
            enum:
              - before
              - after
              - trace
      title: Action Screenshot Options
      description: Action screenshot options
    ActionResultOperationTrace:
      type: object
      properties:
        uri:
          type: string
          description: URI of the screenshot with operation trace
          example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
      title: Action Result Screenshot Operation Trace
      description: Screenshot with action operation trace
      required:
        - uri
    ActionResultScreenshotBefore:
      type: object
      properties:
        uri:
          type: string
          description: URI of the screenshot before the action
          example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
        presignedUrl:
          type: string
          description: Presigned url of the screenshot before the action
          example: https://example.com/xxxxx/xxxxx/xxxxx
      title: Action Result Screenshot Before
      description: Screenshot taken before action execution
      required:
        - uri
    ActionResultScreenshotAfter:
      type: object
      properties:
        uri:
          type: string
          description: URI of the screenshot after the action
          example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...
        presignedUrl:
          type: string
          description: Presigned url of the screenshot before the action
          example: https://example.com/xxxxx/xxxxx/xxxxx
      title: Action Result Screenshot After
      description: Screenshot taken after action execution
      required:
        - uri
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: >-
        Enter your API Key in the format: Bearer <token>. Get it from
        https://gbox.ai

````