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

# Extract and file a folder's files

> Queues a job that matches each file directly inside the folder to one company or plan by the chosen attribute, and moves it into that company's Files directory (plus the relative destination). Re-submitting the same folder contents and settings while a job is still live returns that job.



## OpenAPI

````yaml /api-reference/cx/swagger.json post /files/{file}/_extract_and_file
openapi: 3.0.0
info:
  description: CX API.
  title: CX API
  contact:
    name: API Support
    url: https://stax.ai
    email: support@stax.ai
  version: '1.0'
servers:
  - url: https://api.cx.stax.ai
security: []
paths:
  /files/{file}/_extract_and_file:
    post:
      tags:
        - files
      summary: Extract and file a folder's files
      description: >-
        Queues a job that matches each file directly inside the folder to one
        company or plan by the chosen attribute, and moves it into that
        company's Files directory (plus the relative destination). Re-submitting
        the same folder contents and settings while a job is still live returns
        that job.
      parameters:
        - description: Source folder ID
          name: file
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/pkg_routes_files.ExtractAndFileRequest'
        description: Match attribute, destination subfolder, optional task + automation
        required: true
      responses:
        '200':
          description: Queued (or deduped) job
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg_routes_files.ExtractAndFileResponse'
        '400':
          description: Bad request - invalid body, match_on, destination, or empty folder
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '403':
          description: No write access to the folder
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '404':
          description: Folder not found
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '409':
          description: An identical job just finished; retry
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Failed to create or publish the job
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
components:
  schemas:
    pkg_routes_files.ExtractAndFileRequest:
      type: object
      properties:
        automation:
          type: string
        destination:
          type: string
        match_on:
          type: string
        task:
          type: string
    pkg_routes_files.ExtractAndFileResponse:
      type: object
      properties:
        deduped:
          type: boolean
        job_id:
          type: string
        status:
          type: string
        total:
          type: integer
  securitySchemes:
    ApiKeyAuth:
      description: CX API key. Create one in CX under Settings → Advanced → API Keys.
      in: header
      name: x-api-key
      type: apiKey

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.