> ## 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.

# Extract rewind recording

> Rewind and capture the device's background screen recording from a specified time period.



## OpenAPI

````yaml post /boxes/{boxId}/actions/recording/rewind/extract
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/recording/rewind/extract:
    post:
      tags:
        - UI Action
      summary: Extract rewind recording
      description: >-
        Rewind and capture the device's background screen recording from a
        specified time period.
      operationId: UIActionController_getReplayRecording
      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:
              $ref: '#/components/schemas/ExtractRecordingRewind'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExtractRecordingRewindResult'
      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",
                config: {
                  deviceType: "physical",
                },
              });

              await box.action.recording.rewind.enable();

              // Perform some operations...

              console.info("tapping chrome app...");

              await box.action.tap({ target: "chrome app" });

              // sleep 3 seconds
              console.info("sleeping 3 seconds...");

              await new Promise((resolve) => setTimeout(resolve, 3000));

              console.info("pressing home button...");

              await box.action.pressButton({ buttons: ["home"] });

              console.info("extracting recording...");

              // Extract the last 5 seconds of the recording
              const result = await box.action.recording.rewind.extract({
                duration: "5s",
              });

              console.log(`recording download url: ${result.presignedUrl}`);
            }

            main();
        - lang: Python
          source: >-
            import os

            import time

            from gbox_sdk import GboxSDK


            gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])  # This is
            the default and can be omitted


            def main():
                box = gbox_sdk.create(
                    type="android",
                    config={
                        "device_type": "physical"
                    }
                )

                box.action.recording.rewind.enable()

                # Perform some operations...

                print("tapping chrome app...")

                box.action.tap(target="chrome app")

                # sleep 3 seconds
                print("sleeping 3 seconds...")

                time.sleep(3)

                print("pressing home button...")

                box.action.press_button(buttons=["home"])

                print("extracting recording...")

                # Extract the last 5 seconds of the recording
                result = box.action.recording.rewind.extract(duration="5s")

                print(f"recording download url: {result.presigned_url}")

            if __name__ == "__main__":
                main()
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"time\"\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\tConfig: &gbox.BoxConfig{\n\t\t\tDeviceType: \"physical\",\n\t\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to create box: %v\", err)\n\t}\n\n\terr = box.Action.Recording.Rewind.Enable(context.Background())\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to enable rewind: %v\", err)\n\t}\n\n\t// Perform some operations...\n\n\tfmt.Println(\"tapping chrome app...\")\n\n\terr = box.Action.Tap(context.Background(), gbox.TapRequest{\n\t\tTarget: \"chrome app\",\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to tap: %v\", err)\n\t}\n\n\t// sleep 3 seconds\n\tfmt.Println(\"sleeping 3 seconds...\")\n\n\ttime.Sleep(3 * time.Second)\n\n\tfmt.Println(\"pressing home button...\")\n\n\terr = box.Action.PressButton(context.Background(), gbox.PressButtonRequest{\n\t\tButtons: []string{\"home\"},\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to press button: %v\", err)\n\t}\n\n\tfmt.Println(\"extracting recording...\")\n\n\t// Extract the last 5 seconds of the recording\n\tresult, err := box.Action.Recording.Rewind.Extract(context.Background(), gbox.ExtractRecordingRewindRequest{\n\t\tDuration: \"5s\",\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to extract rewind: %v\", err)\n\t}\n\n\tfmt.Printf(\"recording download url: %s\\n\", result.PresignedURL)\n}"
components:
  schemas:
    ExtractRecordingRewind:
      type: object
      properties:
        duration:
          type: string
          description: >-
            How far back in time to rewind for extracting recorded video. This
            specifies the duration to go back from the current moment (e.g.,
            '30s' rewinds 30 seconds to get recent recorded activity). Default
            is 30s, max is 5m.


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

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

            Maximum allowed: 5m
          example: 10s
          default: 30s
          title: RewindDuration
      title: Extract Recording Rewind
      description: >-
        Configuration for rewinding and extracting clips from continuous screen
        recording
    ExtractRecordingRewindResult:
      type: object
      properties:
        storageKey:
          type: string
          description: >-
            Storage key of the recording. Before the box is deleted, you can use
            this storageKey with the endpoint `box/:boxId/storage/presigned-url`
            to get a downloadable URL for the recording.
          example: storage://gbox/recording/1234567890
        presignedUrl:
          type: string
          description: >-
            Presigned URL of the recording. This is a temporary downloadable URL
            with an expiration time for accessing the recording file.
          example: https://gbox.ai/api/v1/boxes/1234567890/recording/1234567890
      title: Extract Recording Rewind Result
      description: Result of extracting the recording rewind
      required:
        - storageKey
        - presignedUrl
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: >-
        Enter your API Key in the format: Bearer <token>. Get it from
        https://gbox.ai

````