# This file was auto-generated by Fern from our API Definition.

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..requests.workflow_reference import WorkflowReferenceParams
from ..types.max_page_size import MaxPageSize
from ..types.next_page_token import NextPageToken
from ..types.run_metadata import RunMetadata
from ..types.run_priority import RunPriority
from ..types.run_secrets import RunSecrets
from ..types.sort_by import SortBy
from ..types.sort_dir import SortDir
from ..types.workflow_run import WorkflowRun
from ..types.workflow_run_status import WorkflowRunStatus
from .raw_client import AsyncRawWorkflowRunsClient, RawWorkflowRunsClient
from .requests.workflow_runs_create_batch_request_inputs_item import WorkflowRunsCreateBatchRequestInputsItemParams
from .requests.workflow_runs_create_request_file import WorkflowRunsCreateRequestFileParams
from .requests.workflow_runs_create_request_outputs_item import WorkflowRunsCreateRequestOutputsItemParams
from .types.workflow_runs_create_batch_response import WorkflowRunsCreateBatchResponse
from .types.workflow_runs_delete_response import WorkflowRunsDeleteResponse
from .types.workflow_runs_list_response import WorkflowRunsListResponse

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class WorkflowRunsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawWorkflowRunsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawWorkflowRunsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawWorkflowRunsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        status: typing.Optional[WorkflowRunStatus] = None,
        workflow_id: typing.Optional[str] = None,
        batch_id: typing.Optional[str] = None,
        file_name_contains: typing.Optional[str] = None,
        sort_by: typing.Optional[SortBy] = None,
        sort_dir: typing.Optional[SortDir] = None,
        next_page_token: typing.Optional[NextPageToken] = None,
        max_page_size: typing.Optional[MaxPageSize] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowRunsListResponse:
        """
        List runs of a Workflow. Workflows are sequences of steps that process files and data in a specific order to achieve a desired outcome. A WorkflowRun represents a single execution of a workflow against a file.

        Parameters
        ----------
        status : typing.Optional[WorkflowRunStatus]

        workflow_id : typing.Optional[str]
            Filters workflow runs by the workflow ID. If not provided, runs for all workflows are returned.

            Example: `"workflow_BMdfq_yWM3sT-ZzvCnA3f"`

        batch_id : typing.Optional[str]
            Filters workflow runs by the batch ID. This is useful for fetching all runs for a given batch created via the [Batch Run Workflow](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/batch-run-workflow) endpoint.

            Example: `"batch_7Ws31-F5"`

        file_name_contains : typing.Optional[str]
            Filters runs by the name of the file. Only returns runs where the file name contains this string.

            Example: `"invoice"`

        sort_by : typing.Optional[SortBy]

        sort_dir : typing.Optional[SortDir]

        next_page_token : typing.Optional[NextPageToken]

        max_page_size : typing.Optional[MaxPageSize]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRunsListResponse
            You will get a list of summaries for each workflow run. These are shortened versions of the full WorkflowRun object.

            To get the full object, use the [Get WorkflowRun](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/get-workflow-run) endpoint.

        Examples
        --------
        from extend_ai import Extend

        client = Extend(
            token="YOUR_TOKEN",
        )
        client.workflow_runs.list(
            next_page_token="xK9mLPqRtN3vS8wF5hB2cQ==:zWvUxYjM4nKpL7aDgE9HbTcR2mAyX3/Q+CNkfBSw1dZ=",
        )
        """
        _response = self._raw_client.list(
            status=status,
            workflow_id=workflow_id,
            batch_id=batch_id,
            file_name_contains=file_name_contains,
            sort_by=sort_by,
            sort_dir=sort_dir,
            next_page_token=next_page_token,
            max_page_size=max_page_size,
            request_options=request_options,
        )
        return _response.data

    def create(
        self,
        *,
        workflow: WorkflowReferenceParams,
        file: WorkflowRunsCreateRequestFileParams,
        outputs: typing.Optional[typing.Sequence[WorkflowRunsCreateRequestOutputsItemParams]] = OMIT,
        priority: typing.Optional[RunPriority] = OMIT,
        metadata: typing.Optional[RunMetadata] = OMIT,
        secrets: typing.Optional[RunSecrets] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowRun:
        """
        Run a workflow with a file. A workflow is a sequence of steps that process files and data in a specific order to achieve a desired outcome.

        Parameters
        ----------
        workflow : WorkflowReferenceParams

        file : WorkflowRunsCreateRequestFileParams
            The file to be processed. Supported file types can be found [here](https://docs.extend.ai/2026-02-09/product/general/supported-file-types). Files can be provided as a URL, an Extend file ID, or raw text. If you wish to process more at a time, consider using the [Batch Run Workflow](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/batch-run-workflow) endpoint.

        outputs : typing.Optional[typing.Sequence[WorkflowRunsCreateRequestOutputsItemParams]]
            Predetermined outputs to be used for the workflow run. Generally not recommended for most use cases, however, can be useful in cases of overriding a classification in a workflow, or a subset of extraction fields when data is known.

        priority : typing.Optional[RunPriority]

        metadata : typing.Optional[RunMetadata]

        secrets : typing.Optional[RunSecrets]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRun
            Successfully created workflow run

        Examples
        --------
        from extend_ai import Extend

        client = Extend(
            token="YOUR_TOKEN",
        )
        client.workflow_runs.create(
            workflow={"id": "workflow_BMdfq_yWM3sT-ZzvCnA3f"},
            file={"url": "url"},
        )
        """
        _response = self._raw_client.create(
            workflow=workflow,
            file=file,
            outputs=outputs,
            priority=priority,
            metadata=metadata,
            secrets=secrets,
            request_options=request_options,
        )
        return _response.data

    def retrieve(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WorkflowRun:
        """
        Once a workflow has been run, you can check the status and output of a specific WorkflowRun.

        Parameters
        ----------
        id : str
            The ID of the workflow run.

            Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRun
            Successfully retrieved workflow run

        Examples
        --------
        from extend_ai import Extend

        client = Extend(
            token="YOUR_TOKEN",
        )
        client.workflow_runs.retrieve(
            id="workflow_run_id_here",
        )
        """
        _response = self._raw_client.retrieve(id, request_options=request_options)
        return _response.data

    def update(
        self,
        id: str,
        *,
        name: typing.Optional[str] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowRun:
        """
        You can update the name and metadata of an in progress WorkflowRun at any time using this endpoint.

        Parameters
        ----------
        id : str
            The ID of the workflow run.

            Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`

        name : typing.Optional[str]
            An optional name that can be assigned to a specific WorkflowRun

        metadata : typing.Optional[typing.Dict[str, typing.Any]]
            A metadata object that can be assigned to a specific WorkflowRun. If metadata already exists on this WorkflowRun, the newly incoming metadata will be merged with the existing metadata, with the incoming metadata taking field precedence.

            You can include any arbitrary `key : value` pairs in this object.

            To categorize workflow runs for billing and usage tracking, include `extend:usage_tags` with an array of string values (e.g., `{"extend:usage_tags": ["production", "team-eng", "customer-123"]}`). Tags must contain only alphanumeric characters, hyphens, and underscores; any special characters will be automatically removed.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRun
            Successfully updated workflow run

        Examples
        --------
        from extend_ai import Extend

        client = Extend(
            token="YOUR_TOKEN",
        )
        client.workflow_runs.update(
            id="workflow_run_id_here",
        )
        """
        _response = self._raw_client.update(id, name=name, metadata=metadata, request_options=request_options)
        return _response.data

    def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WorkflowRunsDeleteResponse:
        """
        Delete a workflow run and all associated data from Extend. This operation is permanent and cannot be undone.

        This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.

        Parameters
        ----------
        id : str
            The ID of the workflow run.

            Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRunsDeleteResponse
            Successfully deleted workflow run

        Examples
        --------
        from extend_ai import Extend

        client = Extend(
            token="YOUR_TOKEN",
        )
        client.workflow_runs.delete(
            id="workflow_run_id_here",
        )
        """
        _response = self._raw_client.delete(id, request_options=request_options)
        return _response.data

    def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WorkflowRun:
        """
        Cancel a running workflow run by its ID. This endpoint allows you to stop a workflow run that is currently in progress.

        Note: Only workflow runs with a status of `PROCESSING` or `PENDING` can be cancelled. Workflow runs that are completed, failed, in review, rejected, or already cancelled cannot be cancelled.

        Parameters
        ----------
        id : str
            The ID of the workflow run.

            Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRun
            Successfully cancelled workflow run

        Examples
        --------
        from extend_ai import Extend

        client = Extend(
            token="YOUR_TOKEN",
        )
        client.workflow_runs.cancel(
            id="workflow_run_id_here",
        )
        """
        _response = self._raw_client.cancel(id, request_options=request_options)
        return _response.data

    def create_batch(
        self,
        *,
        workflow: WorkflowReferenceParams,
        inputs: typing.Sequence[WorkflowRunsCreateBatchRequestInputsItemParams],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowRunsCreateBatchResponse:
        """
        This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.

        Unlike the single [Run Workflow](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/run-workflow) endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a `batchId`.

        Our recommended usage pattern is to integrate with [Webhooks](https://docs.extend.ai/2026-02-09/product/webhooks/configuration) for consuming results, using the `metadata` and `batchId` to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the [List Workflow Runs](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/list-workflow-runs) endpoint to fetch all runs via a batch, and then [Get Workflow Run](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/get-workflow-run) to fetch the full outputs each run.

        **Priority:** All workflow runs created through this batch endpoint are automatically assigned a priority of 90.

        **Processing and Monitoring:**
        Upon successful submission, the endpoint returns a `batchId`. The individual workflow runs are then queued for processing.

        - **Monitoring:** Track the progress and consume results of individual runs using [Webhooks](https://docs.extend.ai/2026-02-09/product/webhooks/configuration). Subscribe to events like `workflow_run.completed`, `workflow_run.failed`, etc. The webhook payload for these events will include the corresponding `batchId` and the `metadata` you provided for each input.
        - **Fetching Results:** You can also use the [List Workflow Runs](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/list-workflow-runs) endpoint and filter using the `batchId` query param.

        Parameters
        ----------
        workflow : WorkflowReferenceParams

        inputs : typing.Sequence[WorkflowRunsCreateBatchRequestInputsItemParams]
            An array of input objects to be processed by the workflow. Each object represents a single workflow run to be created. The array must contain at least 1 input and at most 1000 inputs.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRunsCreateBatchResponse
            Successfully queued batch workflow run

        Examples
        --------
        from extend_ai import Extend

        client = Extend(
            token="YOUR_TOKEN",
        )
        client.workflow_runs.create_batch(
            workflow={"id": "workflow_BMdfq_yWM3sT-ZzvCnA3f"},
            inputs=[{"file": {"url": "url"}}],
        )
        """
        _response = self._raw_client.create_batch(workflow=workflow, inputs=inputs, request_options=request_options)
        return _response.data


class AsyncWorkflowRunsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawWorkflowRunsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawWorkflowRunsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawWorkflowRunsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        status: typing.Optional[WorkflowRunStatus] = None,
        workflow_id: typing.Optional[str] = None,
        batch_id: typing.Optional[str] = None,
        file_name_contains: typing.Optional[str] = None,
        sort_by: typing.Optional[SortBy] = None,
        sort_dir: typing.Optional[SortDir] = None,
        next_page_token: typing.Optional[NextPageToken] = None,
        max_page_size: typing.Optional[MaxPageSize] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowRunsListResponse:
        """
        List runs of a Workflow. Workflows are sequences of steps that process files and data in a specific order to achieve a desired outcome. A WorkflowRun represents a single execution of a workflow against a file.

        Parameters
        ----------
        status : typing.Optional[WorkflowRunStatus]

        workflow_id : typing.Optional[str]
            Filters workflow runs by the workflow ID. If not provided, runs for all workflows are returned.

            Example: `"workflow_BMdfq_yWM3sT-ZzvCnA3f"`

        batch_id : typing.Optional[str]
            Filters workflow runs by the batch ID. This is useful for fetching all runs for a given batch created via the [Batch Run Workflow](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/batch-run-workflow) endpoint.

            Example: `"batch_7Ws31-F5"`

        file_name_contains : typing.Optional[str]
            Filters runs by the name of the file. Only returns runs where the file name contains this string.

            Example: `"invoice"`

        sort_by : typing.Optional[SortBy]

        sort_dir : typing.Optional[SortDir]

        next_page_token : typing.Optional[NextPageToken]

        max_page_size : typing.Optional[MaxPageSize]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRunsListResponse
            You will get a list of summaries for each workflow run. These are shortened versions of the full WorkflowRun object.

            To get the full object, use the [Get WorkflowRun](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/get-workflow-run) endpoint.

        Examples
        --------
        import asyncio

        from extend_ai import AsyncExtend

        client = AsyncExtend(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.workflow_runs.list(
                next_page_token="xK9mLPqRtN3vS8wF5hB2cQ==:zWvUxYjM4nKpL7aDgE9HbTcR2mAyX3/Q+CNkfBSw1dZ=",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            status=status,
            workflow_id=workflow_id,
            batch_id=batch_id,
            file_name_contains=file_name_contains,
            sort_by=sort_by,
            sort_dir=sort_dir,
            next_page_token=next_page_token,
            max_page_size=max_page_size,
            request_options=request_options,
        )
        return _response.data

    async def create(
        self,
        *,
        workflow: WorkflowReferenceParams,
        file: WorkflowRunsCreateRequestFileParams,
        outputs: typing.Optional[typing.Sequence[WorkflowRunsCreateRequestOutputsItemParams]] = OMIT,
        priority: typing.Optional[RunPriority] = OMIT,
        metadata: typing.Optional[RunMetadata] = OMIT,
        secrets: typing.Optional[RunSecrets] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowRun:
        """
        Run a workflow with a file. A workflow is a sequence of steps that process files and data in a specific order to achieve a desired outcome.

        Parameters
        ----------
        workflow : WorkflowReferenceParams

        file : WorkflowRunsCreateRequestFileParams
            The file to be processed. Supported file types can be found [here](https://docs.extend.ai/2026-02-09/product/general/supported-file-types). Files can be provided as a URL, an Extend file ID, or raw text. If you wish to process more at a time, consider using the [Batch Run Workflow](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/batch-run-workflow) endpoint.

        outputs : typing.Optional[typing.Sequence[WorkflowRunsCreateRequestOutputsItemParams]]
            Predetermined outputs to be used for the workflow run. Generally not recommended for most use cases, however, can be useful in cases of overriding a classification in a workflow, or a subset of extraction fields when data is known.

        priority : typing.Optional[RunPriority]

        metadata : typing.Optional[RunMetadata]

        secrets : typing.Optional[RunSecrets]

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRun
            Successfully created workflow run

        Examples
        --------
        import asyncio

        from extend_ai import AsyncExtend

        client = AsyncExtend(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.workflow_runs.create(
                workflow={"id": "workflow_BMdfq_yWM3sT-ZzvCnA3f"},
                file={"url": "url"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            workflow=workflow,
            file=file,
            outputs=outputs,
            priority=priority,
            metadata=metadata,
            secrets=secrets,
            request_options=request_options,
        )
        return _response.data

    async def retrieve(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WorkflowRun:
        """
        Once a workflow has been run, you can check the status and output of a specific WorkflowRun.

        Parameters
        ----------
        id : str
            The ID of the workflow run.

            Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRun
            Successfully retrieved workflow run

        Examples
        --------
        import asyncio

        from extend_ai import AsyncExtend

        client = AsyncExtend(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.workflow_runs.retrieve(
                id="workflow_run_id_here",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.retrieve(id, request_options=request_options)
        return _response.data

    async def update(
        self,
        id: str,
        *,
        name: typing.Optional[str] = OMIT,
        metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowRun:
        """
        You can update the name and metadata of an in progress WorkflowRun at any time using this endpoint.

        Parameters
        ----------
        id : str
            The ID of the workflow run.

            Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`

        name : typing.Optional[str]
            An optional name that can be assigned to a specific WorkflowRun

        metadata : typing.Optional[typing.Dict[str, typing.Any]]
            A metadata object that can be assigned to a specific WorkflowRun. If metadata already exists on this WorkflowRun, the newly incoming metadata will be merged with the existing metadata, with the incoming metadata taking field precedence.

            You can include any arbitrary `key : value` pairs in this object.

            To categorize workflow runs for billing and usage tracking, include `extend:usage_tags` with an array of string values (e.g., `{"extend:usage_tags": ["production", "team-eng", "customer-123"]}`). Tags must contain only alphanumeric characters, hyphens, and underscores; any special characters will be automatically removed.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRun
            Successfully updated workflow run

        Examples
        --------
        import asyncio

        from extend_ai import AsyncExtend

        client = AsyncExtend(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.workflow_runs.update(
                id="workflow_run_id_here",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(id, name=name, metadata=metadata, request_options=request_options)
        return _response.data

    async def delete(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> WorkflowRunsDeleteResponse:
        """
        Delete a workflow run and all associated data from Extend. This operation is permanent and cannot be undone.

        This endpoint can be used if you'd like to manage data retention on your own rather than automated data retention policies. Or make one-off deletions for your downstream customers.

        Parameters
        ----------
        id : str
            The ID of the workflow run.

            Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRunsDeleteResponse
            Successfully deleted workflow run

        Examples
        --------
        import asyncio

        from extend_ai import AsyncExtend

        client = AsyncExtend(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.workflow_runs.delete(
                id="workflow_run_id_here",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(id, request_options=request_options)
        return _response.data

    async def cancel(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> WorkflowRun:
        """
        Cancel a running workflow run by its ID. This endpoint allows you to stop a workflow run that is currently in progress.

        Note: Only workflow runs with a status of `PROCESSING` or `PENDING` can be cancelled. Workflow runs that are completed, failed, in review, rejected, or already cancelled cannot be cancelled.

        Parameters
        ----------
        id : str
            The ID of the workflow run.

            Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRun
            Successfully cancelled workflow run

        Examples
        --------
        import asyncio

        from extend_ai import AsyncExtend

        client = AsyncExtend(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.workflow_runs.cancel(
                id="workflow_run_id_here",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.cancel(id, request_options=request_options)
        return _response.data

    async def create_batch(
        self,
        *,
        workflow: WorkflowReferenceParams,
        inputs: typing.Sequence[WorkflowRunsCreateBatchRequestInputsItemParams],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WorkflowRunsCreateBatchResponse:
        """
        This endpoint allows you to efficiently initiate large batches of workflow runs in a single request (up to 1,000 in a single request, but you can queue up multiple batches in rapid succession). It accepts an array of inputs, each containing a file and metadata pair. The primary use case for this endpoint is for doing large bulk runs of >1000 files at a time that can process over the course of a few hours without needing to manage rate limits that would likely occur using the primary run endpoint.

        Unlike the single [Run Workflow](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/run-workflow) endpoint which returns the details of the created workflow runs immediately, this batch endpoint returns a `batchId`.

        Our recommended usage pattern is to integrate with [Webhooks](https://docs.extend.ai/2026-02-09/product/webhooks/configuration) for consuming results, using the `metadata` and `batchId` to match up results to the original inputs in your downstream systems. However, you can integrate in a polling mechanism by using a combination of the [List Workflow Runs](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/list-workflow-runs) endpoint to fetch all runs via a batch, and then [Get Workflow Run](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/get-workflow-run) to fetch the full outputs each run.

        **Priority:** All workflow runs created through this batch endpoint are automatically assigned a priority of 90.

        **Processing and Monitoring:**
        Upon successful submission, the endpoint returns a `batchId`. The individual workflow runs are then queued for processing.

        - **Monitoring:** Track the progress and consume results of individual runs using [Webhooks](https://docs.extend.ai/2026-02-09/product/webhooks/configuration). Subscribe to events like `workflow_run.completed`, `workflow_run.failed`, etc. The webhook payload for these events will include the corresponding `batchId` and the `metadata` you provided for each input.
        - **Fetching Results:** You can also use the [List Workflow Runs](https://docs.extend.ai/2026-02-09/developers/api-reference/endpoints/workflow/list-workflow-runs) endpoint and filter using the `batchId` query param.

        Parameters
        ----------
        workflow : WorkflowReferenceParams

        inputs : typing.Sequence[WorkflowRunsCreateBatchRequestInputsItemParams]
            An array of input objects to be processed by the workflow. Each object represents a single workflow run to be created. The array must contain at least 1 input and at most 1000 inputs.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        WorkflowRunsCreateBatchResponse
            Successfully queued batch workflow run

        Examples
        --------
        import asyncio

        from extend_ai import AsyncExtend

        client = AsyncExtend(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.workflow_runs.create_batch(
                workflow={"id": "workflow_BMdfq_yWM3sT-ZzvCnA3f"},
                inputs=[{"file": {"url": "url"}}],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_batch(
            workflow=workflow, inputs=inputs, request_options=request_options
        )
        return _response.data
