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

# Move documents into a datasource (async)

> Move documents (identified by their parse job IDs, e.g. the job_id returned by parseDocument) into an existing datasource or a newly created one. Returns a workflow_id to poll for completion.



## OpenAPI

````yaml /api-v2.json post /documents/move
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:
  /documents/move:
    post:
      tags:
        - Documents
      summary: Move documents into a datasource (async)
      description: >-
        Move documents (identified by their parse job IDs, e.g. the job_id
        returned by parseDocument) into an existing datasource or a newly
        created one. Returns a workflow_id to poll for completion.
      operationId: moveDocuments
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MoveDocumentsRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MoveDocumentsResponse'
        '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 MoveDocumentsRequest,
            MetadataConfigRequest, MetadataField


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


            request = MoveDocumentsRequest(
                documents=["job_8f3c1a2b9d4e", "job_1e2d3c4b5a6f"],
                new_datasource_name="Support Tickets Q1",
                metadata_config=MetadataConfigRequest(
                    type="custom",
                    fields=[
                        MetadataField(
                            name="ticket_priority",
                            type="string",
                            description="Priority level of the support ticket",
                            index=True,
                        ),
                    ],
                ),
            )


            response = client.documents.move(request)

            print(f"workflow_id={response.workflow_id}
            documents_count={response.documents_count}")
        - lang: TypeScript
          label: TypeScript
          source: >-
            import { MeibelClient } from "meibel";


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


            const result = await client.documents.move({
              documents: ["job_7f3a1b2c9e", "job_9d2e4f6a1b"],
              newDatasourceName: "Support Tickets Q1",
              metadataConfig: {
                type: "custom",
                fields: [
                  {
                    name: "ticket_priority",
                    type: "string",
                    description: "Priority level of the support ticket",
                    index: true,
                  },
                  {
                    name: "resolved_at",
                    type: "datetime",
                    description: "Timestamp when the ticket was resolved",
                  },
                ],
              },
            });


            console.log(`Workflow ${result.workflowId} moving
            ${result.documentsCount} documents into ${result.datasourceId}`);
        - 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\tresp, err := client.Documents.Move(context.Background(), v2.MoveDocumentsRequest{\n\t\tDocuments:         []string{\"job_7f3a9c21\", \"job_9b1e4d88\"},\n\t\tNewDatasourceName: v2.String(\"Acme Corp Contracts\"),\n\t\tMetadataConfig: &v2.MetadataConfigRequest{\n\t\t\tType: \"custom\",\n\t\t\tFields: []v2.MetadataField{\n\t\t\t\t{\n\t\t\t\t\tName:        \"contract_date\",\n\t\t\t\t\tType:        \"datetime\",\n\t\t\t\t\tDescription: \"Date the contract was signed\",\n\t\t\t\t\tIndex:       true,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"workflow_id: %s, documents_count: %d\\n\", resp.WorkflowID, resp.DocumentsCount)\n}"
components:
  schemas:
    MoveDocumentsRequest:
      properties:
        documents:
          items:
            type: string
          type: array
          title: Documents
          description: >-
            Job IDs of the documents to move (e.g. the job_id returned by
            parseDocument)
        datasource_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Datasource Id
          description: >-
            Existing datasource to move documents into. Mutually exclusive with
            new_datasource_name.
        new_datasource_name:
          anyOf:
            - type: string
            - type: 'null'
          title: New Datasource Name
          description: >-
            Name for a new datasource created to hold the documents. Mutually
            exclusive with datasource_id.
        metadata_config:
          anyOf:
            - $ref: '#/components/schemas/MetadataConfigRequest'
            - type: 'null'
          description: >-
            Optional metadata extraction config applied to a newly created
            datasource. Ignored when datasource_id is set.
      type: object
      required:
        - documents
      title: MoveDocumentsRequest
      description: >-
        Move documents into a datasource.


        The documents are referenced by the job IDs returned when they were
        parsed

        (e.g. the job_id from `parseDocument` / `client.documents.parse(...)`),

        not by object-storage paths.


        Either target an existing datasource with datasource_id, or create a new

        one by supplying new_datasource_name. Customer and project context are

        injected from request headers, not the body.
    MoveDocumentsResponse:
      properties:
        datasource_id:
          type: string
          title: Datasource Id
          description: ID of the datasource the documents are being moved into
        workflow_id:
          type: string
          title: Workflow Id
          description: ID of the move workflow - poll for completion
        documents_count:
          type: integer
          title: Documents Count
          description: Number of documents submitted for move
      type: object
      required:
        - datasource_id
        - workflow_id
        - documents_count
      title: MoveDocumentsResponse
      description: Result of starting an asynchronous document move workflow.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MetadataConfigRequest:
      properties:
        type:
          type: string
          enum:
            - catalog
            - custom
          title: Type
          description: >-
            Use 'catalog' to select a pre-built extraction model (set model_id);
            use 'custom' to define your own fields (set fields)
        model_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Model Id
          description: >-
            Pre-built model ID from the metadata model catalog — required when
            type is 'catalog'
        fields:
          anyOf:
            - items:
                $ref: '#/components/schemas/MetadataField'
              type: array
            - type: 'null'
          title: Fields
          description: Custom field definitions to extract — required when type is 'custom'
      type: object
      required:
        - type
      title: MetadataConfigRequest
      description: Configure automatic metadata extraction from documents on ingest.
    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
    MetadataField:
      properties:
        name:
          type: string
          title: Name
          description: Field name (snake_case)
        type:
          type: string
          enum:
            - string
            - integer
            - float
            - boolean
            - datetime
            - uuid
            - geo
            - list[string]
          title: Type
          description: Data type of the field
        description:
          type: string
          title: Description
          description: What this field captures
        index:
          type: boolean
          title: Index
          description: Whether this field is indexed for filtering
          default: true
      type: object
      required:
        - name
        - type
        - description
      title: MetadataField
      description: A single field extracted from documents during ingest.
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: Meibel-API-Key

````