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

# Create Batch Execution



## OpenAPI

````yaml /api-v2.json post /batch-executions
openapi: 3.1.0
info:
  title: Meibel AI API
  summary: Meibel Gateway Service
  description: >-
    Our API allows you to interact with our services. Read the
    [docs](https://docs.meibel.ai) to learn how to use it.
  version: 0.6.4
servers:
  - url: https://api.meibel.ai/v2
    description: Meibel API (v2)
  - url: https://api.dev.meibel.ai/v2
    description: Meibel Dev API (v2)
  - url: http://localhost:8000/v2
    description: Local Development
security: []
tags:
  - name: Datasources
    description: v2 datasource management
  - name: Data Elements
    description: v2 data element CRUD and search
  - name: File Upload
    description: Upload files to a datasource and track upload progress
  - name: Ingest
    description: Trigger and monitor datasource ingestion
  - name: Datasource Downloads
    description: Export all datasource content as a zip archive
  - name: Table Descriptions
    description: v2 table and column descriptions
  - name: Metadata Model Catalog
    description: v2 metadata model catalog
  - name: Confidence Scoring
    description: v2 confidence scoring jobs and summaries
  - name: Documents
    description: Parse and transform documents into structured data
  - name: Agents
    description: Agent definition management
  - name: Sessions
    description: Agent session (execution) management and chat
  - name: Execution Policies
    description: Data access and tool usage constraints scoped to agent sessions
  - name: Artifact Schemas
    description: Agent artifact schema management
paths:
  /batch-executions:
    post:
      tags:
        - Batch Executions
      summary: Create Batch Execution
      operationId: createExecution
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBatchExecutionRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchExecutionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
      x-codeSamples:
        - lang: Python
          label: Python
          source: |-
            import os
            from meibel import MeibelClient
            from meibel.models import (
                CreateBatchExecutionRequest,
                LegacyBatchSpecJson,
                LegacyBatchInputConfig,
                LegacyBatchOutputConfig,
                LegacyBatchExecutionParams,
            )

            client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])

            batch_spec_json = LegacyBatchSpecJson(
                name="invoice-extraction-run",
                version="1.0.0",
                agent="agent_def_7f3a9c2b",
                user_message="Extract line items and totals from each invoice.",
                input=LegacyBatchInputConfig(
                    datasource_id="ds_invoices_2024",
                ),
                output=LegacyBatchOutputConfig(
                    datasource_id="ds_invoice_results",
                ),
                execution=LegacyBatchExecutionParams(
                    concurrency=5,
                    retry_limit=2,
                ),
            )

            execution = client.batches.executions.create(
                CreateBatchExecutionRequest(batch_spec_json=batch_spec_json)
            )

            print(f"Execution ID: {execution.id}, status: {execution.status}")
        - lang: TypeScript
          label: TypeScript
          source: >-
            import { MeibelClient } from "meibel";


            const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY
            });


            const execution = await client.batches.executions.create({
              batch_spec_json: {
                name: "invoice-extraction-batch",
                version: "1.0.0",
                agent: "agent_def_7f3a9c",
                user_message: "Extract line items and totals from each invoice.",
                input: {
                  datasource_id: "ds_invoices_2024",
                  filters: {
                    media_types: ["application/pdf"],
                    regex: "^invoice_.*\\.pdf$",
                  },
                },
                output: {
                  datasource_id: "ds_extracted_results",
                },
                execution: {
                  concurrency: 5,
                  retry_limit: 2,
                },
              },
            });


            console.log(`Batch execution ${execution.id} status:
            ${execution.status}`);
        - lang: Go
          label: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"os\"\n\n\tv2 \"github.com/meibel-ai/meibel-go/v2\"\n)\n\nfunc main() {\n\tclient := v2.NewClient(v2.WithAPIKey(os.Getenv(\"MEIBEL_API_KEY\")))\n\n\texecution, err := client.Batches.Executions.Create(context.Background(), v2.CreateBatchExecutionRequest{\n\t\tBatchSpecJson: v2.LegacyBatchSpecJson{\n\t\t\tName:        \"invoice-extraction-run\",\n\t\t\tAgent:       \"agent_8f3d2a1c\",\n\t\t\tUserMessage: v2.String(\"Extract line items and totals from each invoice\"),\n\t\t\tInput: v2.LegacyBatchInputConfig{\n\t\t\t\tDatasourceId: \"ds_9b7e1234\",\n\t\t\t\tFilters: &v2.LegacyBatchInputFilters{\n\t\t\t\t\tMediaTypes: []string{\"application/pdf\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\tOutput: &v2.LegacyBatchOutputConfig{\n\t\t\t\tDatasourceId: v2.String(\"ds_output_4d2f0a\"),\n\t\t\t},\n\t\t\tExecution: &v2.LegacyBatchExecutionParams{\n\t\t\t\tConcurrency: v2.Int(5),\n\t\t\t\tRetryLimit:  v2.Int(3),\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tfmt.Println(\"error creating batch execution:\", err)\n\t\treturn\n\t}\n\n\tfmt.Printf(\"execution id: %s, status: %s\\n\", execution.Id, execution.Status)\n}"
components:
  schemas:
    CreateBatchExecutionRequest:
      properties:
        batch_spec_json:
          $ref: '#/components/schemas/LegacyBatchSpecJson'
      type: object
      required:
        - batch_spec_json
      title: CreateBatchExecutionRequest
      description: >-
        Legacy request body for POST /batch-execution/ (pre-DEL-1376 compat
        shim).
    BatchExecutionResponse:
      properties:
        id:
          type: string
          title: Id
          description: Execution ID — also the Temporal workflow ID for direct queries
        batch_definition_id:
          type: string
          title: Batch Definition Id
          description: FK to the BatchDefinition this execution ran against
        customer_id:
          type: string
          title: Customer Id
        project_id:
          type: string
          title: Project Id
        agent_urn:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Urn
        batch_spec_json:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Batch Spec Json
          description: Optional override for the tool's parameters schema
        agent_spec_json:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Agent Spec Json
        input_datasource_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Input Datasource Id
        output_datasource_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Datasource Id
        input_overrides:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Input Overrides
          description: Optional override for the tool's parameters schema
        total_items:
          anyOf:
            - type: integer
            - type: 'null'
          title: Total Items
        succeeded:
          anyOf:
            - type: integer
            - type: 'null'
          title: Succeeded
        failed:
          anyOf:
            - type: integer
            - type: 'null'
          title: Failed
        start_time:
          type: string
          format: date-time
          title: Start Time
        end_time:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: End Time
        status:
          type: string
          title: Status
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Overall error message
        items:
          anyOf:
            - items:
                $ref: '#/components/schemas/BatchItemResult'
              type: array
            - type: 'null'
          title: Items
          description: Per-item results (populated on completion by status callback)
      type: object
      required:
        - id
        - batch_definition_id
        - customer_id
        - project_id
        - start_time
        - status
      title: BatchExecutionResponse
      description: >-
        Response shape for a single batch execution. The legacy
        `batch_spec_json` / `agent_spec_json` / `agent_urn` /
        `input_datasource_id` fields are kept for client compatibility (DEL-1376
        §5.5) — they are reconstructed from the linked BatchDefinition by the
        router, not stored on the execution row.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LegacyBatchSpecJson:
      properties:
        name:
          type: string
          title: Name
        version:
          anyOf:
            - type: string
            - type: 'null'
          title: Version
        agent:
          type: string
          title: Agent
          description: AgentDefinition ID
        user_message:
          anyOf:
            - type: string
            - type: 'null'
          title: User Message
        input:
          $ref: '#/components/schemas/LegacyBatchInputConfig'
        output:
          anyOf:
            - $ref: '#/components/schemas/LegacyBatchOutputConfig'
            - type: 'null'
        execution:
          anyOf:
            - $ref: '#/components/schemas/LegacyBatchExecutionParams'
            - type: 'null'
        additional_properties:
          additionalProperties: true
          type: object
          title: Additional Properties
          default: {}
      type: object
      required:
        - name
        - agent
        - input
      title: LegacyBatchSpecJson
      description: LegacyBatchSpecJson
    BatchItemResult:
      properties:
        input_data_element_id:
          type: string
          title: Input Data Element Id
        filename:
          type: string
          title: Filename
        status:
          type: string
          title: Status
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
        output_artifacts:
          anyOf:
            - items:
                anyOf:
                  - additionalProperties: true
                    type: object
                  - type: 'null'
              type: array
            - type: 'null'
          title: Output Artifacts
        attempts:
          anyOf:
            - type: integer
            - type: 'null'
          title: Attempts
          default: 1
      type: object
      required:
        - input_data_element_id
        - filename
        - status
      title: BatchItemResult
      description: Per-item result from the Temporal workflow.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    LegacyBatchInputConfig:
      properties:
        datasource_id:
          type: string
          title: Datasource Id
        filters:
          anyOf:
            - $ref: '#/components/schemas/LegacyBatchInputFilters'
            - type: 'null'
      type: object
      required:
        - datasource_id
      title: LegacyBatchInputConfig
      description: LegacyBatchInputConfig
    LegacyBatchOutputConfig:
      properties:
        datasource_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Datasource Id
      type: object
      title: LegacyBatchOutputConfig
      description: LegacyBatchOutputConfig
    LegacyBatchExecutionParams:
      properties:
        concurrency:
          anyOf:
            - type: integer
              maximum: 999
              minimum: 1
            - type: 'null'
          title: Concurrency
          default: 10
        retry_limit:
          anyOf:
            - type: integer
              maximum: 999
              minimum: 0
            - type: 'null'
          title: Retry Limit
          default: 2
      type: object
      title: LegacyBatchExecutionParams
      description: LegacyBatchExecutionParams
    LegacyBatchInputFilters:
      properties:
        regex:
          anyOf:
            - type: string
            - type: 'null'
          title: Regex
        media_types:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Media Types
        element_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Element Ids
        additional_properties:
          additionalProperties: true
          type: object
          title: Additional Properties
          default: {}
      type: object
      title: LegacyBatchInputFilters
      description: LegacyBatchInputFilters
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: Meibel-API-Key

````