Instabase Runs API

The Runs API from Instabase — 4 operation(s) for runs.

OpenAPI Specification

instabase-runs-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  title: AI Hub Audit Runs API
  version: '0.1'
  description: The AI Hub REST API. See https://docs.instabase.com/api-sdk/ for more details.
  termsOfService: https://www.instabase.com/terms-of-service/
  contact:
    name: Instabase Support
    url: https://help.instabase.com/
  license:
    name: MIT
    url: https://github.com/instabase/aihub-python/blob/master/LICENSE
servers:
- url: https://aihub.instabase.com/api
security:
- bearerAuth: []
tags:
- name: Runs
paths:
  /v2/apps/runs:
    post:
      operationId: runApp
      x-fern-audiences:
      - public
      tags:
      - Runs
      summary: Run app
      description: 'Run an automation app by its name or app ID. The input for the run can be a batch ID or an input file path.


        <Tip>


        <span class="badge">Commercial & Enterprise</span>


        Running an automation app via a deployment is generally preferred over running an app directly.


        Deployments offer additional features including upstream and downstream integrations, deployment metrics, human review workflows, and secret and configuration management.


        Learn more about [deployments](/automate/deployments) to decide if you''d rather use the [Run deployment](/api-sdk/api-reference/runs/run-deployment) API operation.


        </Tip>


        <Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note>

        '
      parameters:
      - $ref: '#/components/parameters/ib_context'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                app_name:
                  type: string
                  description: Required unless using `app_id`. The name of the app to run.
                app_id:
                  type: string
                  description: 'Required unless using `app_name`. The app ID of the app to run.


                    <Tip>You can find an app ID in the app URL, such as http<span>s://</span>aihub.instabase.com/hub/apps/**528c36e8-ac5b-490d-a41b-7eec9c404b87**.</Tip>

                    '
                owner:
                  type: string
                  description: 'The account that generated the app. If not specified, defaults to your AI Hub username.


                    For custom apps belonging to you, accept the default. For AI Hub Marketplace apps published by Instabase, specify `instabase`.

                    '
                batch_id:
                  type: integer
                  description: Required unless using `input_dir`. The batch ID of a batch created with the [Batches endpoint](/api-sdk/api-reference/batches/create-batch/). All files uploaded to the batch are used as input for the run.
                input_dir:
                  type: string
                  description: Required unless using `batch_id`. The path of the input folder in a connected drive or Instabase Drive. See [Specifying file paths](/api-sdk/api-reference/run-reference/).
                version:
                  type: string
                  description: Version of the app to use. If not specified, defaults to the latest production version.
                output_workspace:
                  type: string
                  description: 'The workspace in which to run the app. Output saves to the specified workspace. If not defined, the default is your personal workspace.


                    <Note>Service accounts don''t have personal workspaces. If making this call from a service account, you must specify a value for either `output_workspace` or `output_dir`.</Note>

                    '
                output_dir:
                  type: string
                  description: Defines a specific location for the output to be saved in a connected drive or Instabase Drive. If defined, overrides the `output_workspace` value. See [Specifying file paths](/api-sdk/api-reference/run-reference/).
                settings:
                  type: object
                  description: JSON object containing settings for the app run.
                  properties:
                    keys:
                      type: object
                      description: 'Configure runtime values for any custom and secret keys referenced in the app. Undefined keys run without a value.

                        '
                      properties:
                        custom:
                          type: object
                          description: 'Configure any custom keys, using key/value pairs. In the key/value pair, define the key as the name of an existing key used in your app, and define the value as any custom value.


                            <Note>Any keys being defined by API should correspond to keys listed on the app **Overview** page, on the **Keys** tab.</Note>

                            '
                          additionalProperties: true
                        secret:
                          type: object
                          description: 'Configure any secret keys, using key/value pairs. In the key/value pair, define the key as the name of an existing secret key used in your app, and define the value as any secret in the organization''s secrets vault. For guidance on managing secrets, see [Managing secrets](/admin/secret-management/) or refer to the [Secrets endpoints](/api-sdk/api-reference/secrets/).


                            <Note>Any keys being defined by API should correspond to keys listed on the app **Overview** page, on the **Keys** tab.</Note>

                            '
                          additionalProperties:
                            type: string
                    runtime_config:
                      type: object
                      description: A dictionary supporting select runtime configurations, such as generating retrievable PDFs of processed documents. For all other runtime configurations, use the `keys` parameter.
                      properties:
                        generate_post_process_pdf:
                          type: boolean
                          description: 'Set to `true` to generate a retrievable PDF for each document the app processes, including separate PDFs for each document created by split classification. PDF generation is supported only for documents less than 100 pages in length.


                            <Note>When getting run results, use the [`include_source_info` query parameter](/api-sdk/api-reference/runs/get-run-results#request.query.include_source_info.include_source_info) to return the file path for any generated PDFs in your results. File paths are returned under `files/documents/post_processed_pdf_path`.</Note>

                            '
                        instabase:
                          type: object
                          description: A dictionary supporting select runtime configurations.
                          properties:
                            pdf:
                              type: object
                              description: A dictionary supporting select runtime configurations dealing with PDF input documents.
                              properties:
                                passwords:
                                  type: object
                                  description: A dictionary with titles of encrypted PDF documents as keys and passwords for those documents as values.
                                  additionalProperties:
                                    type: string
                    tags:
                      type: array
                      items:
                        type: string
                      description: 'List of string tags to attach to this run. Combined length of all tags must not exceed 500 characters.

                        '
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/run'
          description: Run started successfully.
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
          description: Error response.
      x-fern-examples:
      - code-samples:
        - sdk: curl
          name: Simple request
          code: "curl \"${API_ROOT}/v2/apps/runs\" \\\n  -H \"Authorization: Bearer ${API_TOKEN}\" \\\n  -H \"IB-Context: ${IB_CONTEXT}\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n        \"batch_id\": <BATCH-ID>,\n        \"app_name\": \"<APP-NAME>\"\n      }'\n"
        - sdk: python
          name: Simple request with SDK
          code: "from aihub import AIHub\n\nclient = AIHub(\n    api_root=\"https://aihub.instabase.com/api\",\n    api_key=\"abcdefghijklmnopqrst1234567890\",\n    ib_context=\"john.doe_acme.com\"\n)\n\nrun = client.apps.runs.create(\n    app_name=\"MyApp\",\n    batch_id=12345\n)\n\nprint(f\"Run ID: {run.id}\")\n"
        - sdk: python
          name: Simple request without SDK
          code: "import requests\n\nurl = \"https://aihub.instabase.com/api/v2/apps/runs\"\n\nheaders = {\n    \"Authorization\": \"Bearer abcdefghijklmnopqrst1234567890\",\n    \"IB-Context\": \"john.doe_acme.com\"\n}\n\n# create the request payload\ndata = {\n    \"batch_id\": 12345,\n    \"app_name\": \"My App\"\n}\n\n# make the POST request\nresponse = requests.post(url, headers=headers, json=data)\n\n# handle the response\nif response.status_code == 200:\n    print(f\"Run started with ID: {response.json()['id']}\")\nelse:\n    print(f\"Error: {response.status_code} - {response.text}\")\n"
        - sdk: curl
          name: Complex request
          code: "curl \"${API_ROOT}/v2/apps/runs\" \\\n  -H \"Authorization: Bearer ${API_TOKEN}\" \\\n  -H \"IB-Context: ${IB_CONTEXT}\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n        \"batch_id\": \"<BATCH-ID>\",\n        \"app_name\": \"<APP-NAME>\",\n        \"settings\": {\n          \"runtime_config\": {\n            \"generate_post_process_pdf\": true,\n            \"instabase\": {\n              \"pdf\": {\n                \"passwords\": {\n                  \"test1.pdf\": \"abc123\",\n                  \"scott.pdf\": \"tiger\"\n                }\n              }\n            }\n          }\n        }\n      }'\n"
        - sdk: python
          name: Complex request with SDK
          code: "from aihub import AIHub\n\nclient = AIHub(\n    api_root=\"https://aihub.instabase.com/api\",\n    api_key=\"abcdefghijklmnopqrst1234567890\",\n    ib_context=\"john.doe_acme.com\"\n)\n\nrun = client.apps.runs.create(\n    app_name=\"MyApp\",\n    batch_id=12345,\n    settings={\n        \"runtime_config\": {\n            \"generate_post_process_pdf\": True,\n            \"instabase\": {\n                \"pdf\": {\n                    \"passwords\": {\n                        \"test1.pdf\": \"abc123\",\n                        \"scott.pdf\": \"tiger\"\n                    }\n                }\n            }\n        }\n    }\n)\nprint(f\"Run ID: {run.id}\")\n"
        - sdk: python
          name: Complex request without SDK
          code: "import requests\n\nurl = \"https://aihub.instabase.com/api/v2/apps/runs\"\n\nheaders = {\n    \"Authorization\": \"Bearer abcdefghijklmnopqrst1234567890\",\n    \"IB-Context\": \"john.doe_acme.com\"\n}\n\n# create the request payload\ndata = {\n    \"batch_id\": 12345,\n    \"app_name\": \"My App\",\n    \"settings\": {\n        \"runtime_config\": {\n            \"generate_post_process_pdf\": True,\n            \"instabase\": {\n                \"pdf\": {\n                    \"passwords\": {\n                        \"test1.pdf\": \"abc123\",\n                        \"scott.pdf\": \"tiger\"\n                    }\n                }\n            }\n        }\n    }\n}\n\n# make the POST request\nresponse = requests.post(url, headers=headers, json=data)\n\n# handle the response\nif response.status_code == 200:\n    print(f\"Run started with ID: {response.json()['id']}\")\nelse:\n    print(f\"Error: {response.status_code} - {response.text}\")\n"
    get:
      operationId: listRuns
      x-fern-audiences:
      - public
      tags:
      - Runs
      summary: List runs
      description: Return a list of runs. Use query parameters to filter results.
      parameters:
      - $ref: '#/components/parameters/ib_context'
      - in: query
        name: app_id
        schema:
          type: string
        description: Filter runs by app ID.
      - in: query
        name: app_name
        schema:
          type: string
        description: Filter runs by app name.
      - in: query
        name: deployment_id
        schema:
          type: string
        description: Filter runs by deployment ID.
      - in: query
        name: username
        schema:
          type: string
        description: Filter runs initiated by the specified user (username).
      - in: query
        name: run_id
        schema:
          type: string
        description: Filter specific run by run ID.
      - in: query
        name: status
        schema:
          type: array
          items:
            type: string
        description: Filter jobs by status, such as COMPLETE, RUNNING, or FAILED.
      - in: query
        name: output_workspaces
        schema:
          type: array
          items:
            type: string
        description: Filter runs by the run's output workspace. By default, all runs across all workspaces you have access to are returned, use this query parameter to filter by specific workspace names. You must have access to the named workspaces.
      - in: query
        name: from_timestamp
        schema:
          type: integer
        description: Filter runs starting from this timestamp. Timestamp in Unix time in seconds. Defaults to 24 hours before the current time.
      - in: query
        name: to_timestamp
        schema:
          type: integer
        description: Filter runs up to this timestamp. Timestamp in Unix time in seconds. Defaults to the current time.
      - in: query
        name: limit
        schema:
          type: integer
        description: Number of results to return.
      - in: query
        name: offset
        schema:
          type: integer
        description: Offset of the first result to return.
      - in: query
        name: sort_by
        schema:
          type: string
          enum:
          - start_timestamp
          - status
        description: Field to sort results by.
      - in: query
        name: order
        schema:
          type: string
          enum:
          - ASCENDING
          - DESCENDING
        description: Order of sorting, such as ASCENDING or DESCENDING.
      responses:
        '200':
          description: A list of all runs.
          content:
            application/json:
              schema:
                type: object
                properties:
                  runs:
                    type: array
                    items:
                      $ref: '#/components/schemas/run'
        default:
          description: Error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
      x-fern-examples:
      - code-samples:
        - sdk: curl
          code: "curl \"${API_ROOT}/v2/apps/runs\" \\\n  -H \"Authorization: Bearer ${API_TOKEN}\" \\\n  -H \"IB-Context: ${IB_CONTEXT}\"\n"
        - sdk: python
          name: with SDK
          code: "from aihub import AIHub\n\nclient = AIHub(\n    api_root=\"https://aihub.instabase.com/api\",\n    api_key=\"abcdefghijklmnopqrst1234567890\",\n    ib_context=\"john.doe_acme.com\"\n)\n\nresponse = client.apps.runs.list()\n\nprint(f\"third run ID: {response.runs[2].id}\")  # 0-based indexing\n"
        - sdk: python
          name: without SDK
          code: "import requests\n\nurl = \"https://aihub.instabase.com/api/v2/apps/runs\"\n\nheaders = {\n    \"Authorization\": \"Bearer abcdefghijklmnopqrst1234567890\",\n    \"IB-Context\": \"john.doe_acme.com\"\n}\n\n# make the GET request\nresponse = requests.get(url, headers=headers)\n\n# handle the response\nif response.status_code == 200:\n    # the next line assumes the call returned at least 3 runs\n    print(f\"third run ID: {response.json()['runs'][2]['id']}\")\nelse:\n    print(f\"Error: {response.status_code} - {response.text}\")\n"
  /v2/apps/deployments/{deployment-id}/runs:
    post:
      operationId: runDeployment
      x-fern-audiences:
      - public
      tags:
      - Runs
      summary: Run deployment
      description: '<span class="badge">Commercial & Enterprise</span>


        Run an AI Hub deployment by its deployment ID. The input for the run is specified using a batch ID or file path.


        <Info>Use the UI to optionally [configure email notifications or webhooks](/automate/deployments#configuring-notifications) for certain events within the deployed app''s lifecycle.</Info>


        <Note>Any specified input or output is validated against the context set by the `IB-Context` header. For example, if the context is set to your community account, but the batch ID used as input for the run is stored in your organization, the call fails.</Note>

        '
      parameters:
      - $ref: '#/components/parameters/ib_context'
      - in: path
        name: deployment-id
        schema:
          type: string
          default: false
        required: true
        description: 'The deployment ID.


          <Tip>Find the deployment ID by opening the deployment in AI Hub and looking at the site URL, such as https<span>://</span>aihub.instabase.com/deployments/**01902d6f-bb35-74cb-bd27-c09b38bbf20a**/runs.</Tip>

          '
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                batch_id:
                  type: integer
                  description: Required unless using `input_dir` or `manual_upstream_integration`. The batch ID of a batch created with the [Batches endpoint](/api-sdk/api-reference/batches/create-batch/). All files uploaded to the batch are used as input for the run.
                input_dir:
                  type: string
                  description: Required unless using `batch_id` or `manual_upstream_integration`. The path of the input folder in a connected drive or Instabase Drive. See [Specifying file paths](/api-sdk/api-reference/run-reference/).
                manual_upstream_integration:
                  type: boolean
                  description: Use the deployment's upstream integration as a source rather than a `batch_id` or `input_dir`. Requires an upstream integration to be configured for the deployment.
                from_timestamp:
                  type: number
                  description: Required if `manual_upstream_integration` is true and the upstream integration is a mailbox integration. Specifies the earliest date in Unix time milliseconds from which to pull emails.
                to_timestamp:
                  type: number
                  description: Required if `manual_upstream_integration` is true and the upstream integration is a mailbox integration. Specifies the latest date in Unix time milliseconds from which to pull emails.
                version:
                  type: string
                  description: Version of the app to use. If not specified, defaults to the latest production version.
                output_dir:
                  type: string
                  description: Defines a specific location for the output to be saved in a connected drive or Instabase Drive. If defined, overrides the output workspace configured for the deployment. See [Specifying file paths](/api-sdk/api-reference/run-reference).
                settings:
                  type: object
                  description: JSON object containing settings for the deployment run.
                  properties:
                    keys:
                      type: object
                      description: 'Define the values for any custom or secret keys configured under your deployment''s *Runtime configurations* settings. Key values passed via API override any key values defined in the deployment configuration.

                        '
                      properties:
                        custom:
                          type: object
                          description: 'Configure any custom keys, using key/value pairs. In the key/value pair, define the key as the name of an existing key used in your deployment, and define the value as any custom value.


                            <Note>Any keys being defined by API should correspond to keys listed under your deployment''s *Runtime configuration* settings. For keys included in the `custom` object, match against the keys listed on the **Custom keys** tab of the runtime configuration.</Note>

                            '
                          additionalProperties: true
                        secret:
                          type: object
                          description: 'Configure any secret keys, using key/value pairs. In the key/value pair, define the key as the name of an existing secret key used in your deployment, and define the value as any secret in the organization''s secrets vault. For guidance on managing secrets, see [Managing secrets](/admin/secret-management/) or refer to the [Secrets endpoints](/api-sdk/api-reference/secrets/).


                            <Note>Any keys being defined by API should correspond to keys listed under your deployment''s *Runtime configuration* settings. For keys included in the `secret` object, match against the keys listed on the **Secret keys** tab of the runtime configuration.</Note>

                            '
                          additionalProperties:
                            type: string
                    runtime_config:
                      type: object
                      description: A dictionary supporting select runtime configurations, such as generating retrievable PDFs of processed documents. For all other runtime configurations, use the `keys` parameter.
                      properties:
                        generate_post_process_pdf:
                          type: boolean
                          description: 'Set to `true` to generate a retrievable PDF for each document the app processes, including separate PDFs for each document created by split classification.


                            <Note>When getting run results, use the [`include_source_info` query parameter](/api-sdk/api-reference/runs/get-run-results#request.query.include_source_info.include_source_info) to return the file path for any generated PDFs in your results. File paths are returned under `files/documents/post_processed_pdf_path`.</Note>

                            '
                        instabase:
                          type: object
                          description: A dictionary supporting select runtime configurations.
                          properties:
                            pdf:
                              type: object
                              description: A dictionary supporting select runtime configurations dealing with PDF input documents.
                              properties:
                                passwords:
                                  type: object
                                  description: A dictionary with titles of encrypted PDF documents as keys and passwords for those documents as values.
                                  additionalProperties:
                                    type: string
                    tags:
                      type: array
                      items:
                        type: string
                      description: 'List of string tags to attach to this run. Combined length of all tags must not exceed 500 characters.

                        '
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/run'
          description: Successfully initiated an asynchronous operation to run the deployment.
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
          description: Error response.
      x-fern-examples:
      - code-samples:
        - sdk: curl
          code: "curl \"${API_ROOT}/v2/apps/deployments/<DEPLOYMENT-ID>/runs\" \\\n  -H \"Authorization: Bearer ${API_TOKEN}\" \\\n  -H \"IB-Context: ${IB_CONTEXT}\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n        \"batch_id\": <BATCH-ID>,\n      }'\n"
        - sdk: python
          name: Use batch ID with SDK
          code: "from aihub import AIHub\n\nclient = AIHub(\n    api_root=\"https://aihub.instabase.com/api\",\n    api_key=\"abcdefghijklmnopqrst1234567890\",\n    ib_context=\"john.doe_acme.com\"\n)\n\nrun = client.apps.deployments.runs.create(\n    deployment_id=\"12345678-abcde-1234-abcd-123456789012\",\n    batch_id=12345\n)\n\nprint(f\"run ID: {run.id}\")\n"
        - sdk: python
          name: Use batch ID without SDK
          code: "import requests\n\ndeployment_id = \"12345678-abcde-1234-abcd-123456789012\"\nurl = f\"https://aihub.instabase.com/api/v2/apps/deployments/{deployment_id}/runs\"\n\nheaders = {\n    \"Authorization\": \"Bearer abcdefghijklmnopqrst1234567890\",\n    \"IB-Context\": \"john.doe_acme.com\"\n}\n\n# create the request payload\ndata = {\"batch_id\": 12345}\n\n# make the POST request\nresponse = requests.post(url, headers=headers, json=data)\n\n# handle the response\nif response.status_code == 202:\n    print(f\"Deployment run started with ID: {response.json()['id']}\")\nelse:\n    print(f\"Error: {response.status_code} - {response.text}\")\n"
        - sdk: python
          name: Use input dir with SDK
          code: "from aihub import AIHub\n\nclient = AIHub(\n    api_root=\"https://aihub.instabase.com/api\",\n    api_key=\"abcdefghijklmnopqrst1234567890\",\n    ib_context=\"john.doe_acme.com\"\n)\n\norganization_id = \"acme\"\nworkspace = \"MyWorkspace\"\ndrive_name = \"My Google Drive\"\nfolder = \"My Drive/input_files/documents/\"\ninput_dir = f\"{organization_id}/{workspace}/fs/{drive_name}/{folder}\"\n\nrun = client.apps.deployments.runs.create(\n    deployment_id=\"12345678-abcde-1234-abcd-123456789012\",\n    input_dir=input_dir\n)\n\nprint(f\"run ID: {run.id}\")\n"
        - sdk: python
          name: Use input dir without SDK
          code: "import requests\n\ndeployment_id = \"12345678-abcde-1234-abcd-123456789012\"\nurl = f\"https://aihub.instabase.com/api/v2/apps/deployments/{deployment_id}/runs\"\n\nheaders = {\n    \"Authorization\": \"Bearer abcdefghijklmnopqrst1234567890\",\n    \"IB-Context\": \"john.doe_acme.com\"\n}\n\norganization_id = \"acme\"\nworkspace = \"MyWorkspace\"\ndrive_name = \"My Google Drive\"\nfolder = \"My Drive/input_files/documents/\"\ninput_dir = f\"{organization_id}/{workspace}/fs/{drive_name}/{folder}\"\n\n# create the request payload\ndata = {\"input_dir\": input_dir}\n\n# make the POST request\nresponse = requests.post(url, headers=headers, json=data)\n\n# handle the response\nif response.status_code == 202:\n    print(f\"Deployment run started with ID: {response.json()['id']}\")\nelse:\n    print(f\"Error: {response.status_code} - {response.text}\")\n"
  /v2/apps/runs/{run_id}:
    get:
      operationId: getRunStatus
      x-fern-audiences:
      - public
      tags:
      - Runs
      summary: Get run status
      description: Get the status of a run.
      parameters:
      - $ref: '#/components/parameters/run_id'
      - $ref: '#/components/parameters/ib_context'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/run'
          description: Successful response.
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
          description: Error response.
      x-fern-examples:
      - code-samples:
        - sdk: curl
          code: "curl \"${API_ROOT}/v2/apps/runs/<RUN-ID>\" \\\n  -H \"Authorization: Bearer ${API_TOKEN}\" \\\n  -H \"IB-Context: ${IB_CONTEXT}\"\n"
        - sdk: python
          name: with SDK
          code: "from aihub import AIHub\n\nclient = AIHub(\n    api_root=\"https://aihub.instabase.com/api\",\n    api_key=\"abcdefghijklmnopqrst1234567890\",\n    ib_context=\"john.doe_acme.com\"\n)\n\nresponse = client.apps.runs.status(\n    run_id=\"a1b2c3d4-e5f6-7890-abcd-ef1234567890\"\n)\n\nprint(f\"Run status: {response.status}\")\n"
        - sdk: python
          name: without SDK
          code: "import requests\n\nrun_id = \"a1b2c3d4-e5f6-7890-abcd-ef1234567890\"\nurl = f\"https://aihub.instabase.com/api/v2/apps/runs/{run_id}\"\n\nheaders = {\n    \"Authorization\": \"Bearer abcdefghijklmnopqrst1234567890\",\n    \"IB-Context\": \"john.doe_acme.com\"\n}\n\n# make the GET request\nresponse = requests.get(url, headers=headers)\n\n# handle the response\nif response.status_code == 200:\n    print(f\"Run status: {response.json()['status']}\")\nelse:\n    print(f\"Error: {response.status_code} - {response.text}\")\n"
    delete:
      operationId: deleteRun
      x-fern-audiences:
      - public
      tags:
      - Runs
      summary: Delete run
      description: 'Deletes a specified automation app run and optionally its associated database data, input files, output files, and logs. This is an asynchronous operation that must be [checked for completion](/api-sdk/api-reference/jobs/job-status).


        <Warning>Deleting the run''s input files also deletes the batch that the run processed.</Warning>

        '
      parameters:
      - $ref: '#/components/parameters/run_id'
      - $ref: '#/components/parameters/ib_context'
      - in: query
        name: delete_db_data
        schema:
          type: boolean
          default: true
        description: Delete the run's database data.
      - in: query
        name: delete_input
        schema:
          type: boolean
          default: true
        description: Delete the run's input files.
      - in: query
        name: delete_output
        schema:
          type: boolean
          default: true
        description: Delete the run's output files.
      - in: query
        name: delete_logs
        schema:
          type: boolean
          default: true
        description: Delete the run's logs.
      responses:
        '202':
          description: Run deleted successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  delete_input_dir_job_id:
                    type: string
                    description: Job ID for deleting the input directory.
                    nullable: true
                  delete_output_dir_job_id:
                    type: string
                    description: Job ID for deleting the output directory.
                    nullable: true
                  delete_log_dir_job_id:
                    type: string
                    description: Job ID for deleting the log directory.
                    nullable: true
        default:
          description: Error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
      x-fern-examples:
      - code-samples:
        - sdk: curl
          code: "curl -X DELETE \"${API_ROOT}/v2/apps/runs/<RUN-ID>\" \\\n  -H \"Authorization: Bearer ${API_TOKEN}\" \\\n  -H \"IB-Context: ${IB_CONTEXT}\"\n"
        - sdk: python
          name: with SDK
          code: "import time\nfrom aihub import AIHub\n\nclient = AIHub(\n    api_root=\"https://aihub.instabase.com/api\",\n    api_key=\"abcdefghijklmnopqrst1234567890\",\n    ib_context=\"john.doe_acme.com\"\n)\n\nresponse = client.apps.runs.delete(\n    run_id=\"a1b2c3d4-e5f6-7890-abcd-ef1234567890\"\n)\n\njob_ids = [\n    response.delete_input_dir_job_id,\n    response.delete_output_dir_job_id,\n    response.delete_log_dir_job_id\n]\n\n# remove empty job IDs\njob_ids = [job_id for job_id in job_ids if job_id]\n\n# poll for job completion\nwhile job_ids:\n    for job_id in job_i

# --- truncated at 32 KB (65 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/instabase/refs/heads/main/openapi/instabase-runs-api-openapi.yml