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

# Create File

> Upload a new file to the app. Optionally specify a bucket.



## OpenAPI

````yaml post /apps/{app_id}/files
openapi: 3.0.0
info:
  version: 1.0.0
  title: API
servers: []
security: []
paths:
  /apps/{app_id}/files:
    post:
      summary: Create File
      description: Upload a new file to the app. Optionally specify a bucket.
      parameters:
        - schema:
            type: string
          required: true
          description: The ID of the app
          name: app_id
          in: path
        - schema:
            type: string
            description: Optional bucket name for storage operations
            example: cortex-eu
          required: false
          name: bucket
          in: query
      requestBody:
        description: File data and options for upload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAppFileSchema'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateAppFileSchema'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppFileSchema'
components:
  schemas:
    CreateAppFileSchema:
      type: object
      properties:
        file:
          anyOf:
            - type: string
              format: binary
            - $ref: '#/components/schemas/FileDataSchema'
            - type: string
          description: >-
            File to be uploaded. It can be a file object, a base64 encoded
            string, or a file data object containing base64 data, name, and
            type.
        file_url:
          type: string
          description: URL of the file to be uploaded
          example: https://example.com/files/document.pdf
        allowed_types:
          $ref: '#/components/schemas/FileAllowedTypesSchema'
        document_extract_contents:
          type: boolean
          description: Flag indicating whether to extract contents from the document
          example: false
        document_extract_images:
          type: boolean
          description: Flag indicating whether to extract images from the document
          example: false
        document_extract_pages:
          type: boolean
          description: Flag indicating whether to extract pages from the document
          example: false
        document_pages:
          type: array
          items:
            type: number
          maxItems: 1024
          description: Array of page numbers to extract from the document
          example:
            - 1
            - 2
            - 3
        document_max_pages:
          type: number
          minimum: 1
          description: Maximum number of pages to extract from the document
          example: 10
        storage:
          $ref: '#/components/schemas/AppFileStorageSchema'
        visibility:
          $ref: '#/components/schemas/FileVisibilitySchema'
        bucket:
          type: string
          description: Storage bucket for the file
          example: cortex-eu
        region:
          type: string
          description: Region on R2/cloudflare
          example: cortex-eu
    AppFileSchema:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the file
        file_id:
          type: string
          description: File identifier used in the storage system
        file_filename:
          type: string
          description: Name of the file
          example: document.pdf
        file_size:
          type: number
          description: Size of the file in bytes
          example: 1024
        file_mimetype:
          type: string
          description: MIME type of the file
          example: application/pdf
        file_url:
          type: string
          description: URL to access the file
        file_format:
          type: string
          enum:
            - DOCUMENT
          description: Format of the file
          example: DOCUMENT
        file_status:
          type: string
          enum:
            - PROCESSING
            - PROCESSED
            - FAILED
          description: Current status of the file
          example: PROCESSED
        file_status_message:
          type: string
          description: >-
            Status message providing additional information about the file
            status
        document:
          $ref: '#/components/schemas/DocumentSchema'
        document_extract_contents:
          type: boolean
          description: Flag indicating whether to extract contents from the document
        document_extract_images:
          type: boolean
          description: Flag indicating whether to extract images from the document
        document_extract_pages:
          type: boolean
          description: Flag indicating whether to extract pages from the document
        document_pages:
          type: array
          items:
            type: number
          maxItems: 1024
          description: Array of page numbers to extract from the document
          example:
            - 1
            - 2
            - 3
        document_progress:
          type: number
          description: Progress of the document extraction process
        storage:
          $ref: '#/components/schemas/AppFileStorageSchema'
        created_at:
          type: string
          nullable: true
          description: Timestamp when the file was created
          format: date
      required:
        - id
        - file_id
        - file_filename
        - file_size
        - file_mimetype
        - file_url
        - created_at
      description: Detailed information about a file
    FileDataSchema:
      type: object
      properties:
        data:
          type: string
          description: URL, Raw or Base64 encoded file data.
          example: SGVsbG8sIHdvcmxkIQ==
        type:
          type: string
          maxLength: 64
          description: Mime type of the file, if not provided it will be inferred.
          example: application/pdf
        name:
          type: string
          minLength: 1
          description: Name of the file.
          example: document.pdf
        encoding:
          type: string
          enum:
            - base64
            - raw
          description: >-
            Encoding of the file data when it's a direct input, by default
            base64 is expected.
          example: base64
      required:
        - data
      description: Data payload for creating a file
    FileAllowedTypesSchema:
      type: array
      nullable: true
      items:
        type: string
        maxLength: 255
      maxItems: 255
      default:
        - '*/*'
      description: >-
        The allowed mime types for the file field (e.g. image/*,
        application/pdf)
    AppFileStorageSchema:
      type: string
      enum:
        - PERSISTENT
        - TEMPORARY
      default: PERSISTENT
      description: >-
        Whether the file is stored permanently or temporarily, indicating the
        storage type
      example: PERSISTENT
    FileVisibilitySchema:
      type: string
      enum:
        - PUBLIC
        - PRIVATE
      description: >-
        Whether the file is private or public, private files URLs are signed
        with a token and can be accessed temporarily
      example: PRIVATE
    DocumentSchema:
      type: object
      properties:
        filename:
          type: string
          description: Name of the document file
        filetype:
          type: string
          description: Type of the document file
        contents:
          type: array
          items:
            $ref: '#/components/schemas/DocumentContentSchema'
          description: >-
            Array of document contents (only available if extract_contents is
            true)
        images:
          type: array
          items:
            $ref: '#/components/schemas/DocumentImageSchema'
          description: Array of document images (only available if extract_images is true)
        extracted_pages:
          type: string
          description: >-
            Extracted pages from the document (only available if extract_pages
            is true)
        time:
          type: number
          description: Time taken to process the document
      required:
        - filename
        - filetype
        - contents
        - images
      description: Document data associated with the file
    DocumentContentSchema:
      type: object
      properties:
        id:
          type: number
          description: Unique identifier for the content
        type:
          type: string
          enum:
            - TITLE
            - TEXT
            - UNTEXT
            - NARRATIVETEXT
            - BULLETEDTEXT
            - ABSTRACT
            - THREADING
            - FORM
            - FIELD-NAME
            - VALUE
            - LINK
            - COMPOSITEELEMENT
            - IMAGE
            - PICTURE
            - FIGURECAPTION
            - FIGURE
            - CAPTION
            - LIST
            - LISTITEM
            - LIST-ITEM
            - CHECKED
            - UNCHECKED
            - ADDRESS
            - EMAILADDRESS
            - PAGEBREAK
            - FORMULA
            - TABLE
            - HEADER
            - HEADLINE
            - SUBHEADLINE
            - PAGE-HEADER
            - SECTION-HEADER
            - FOOTER
            - FOOTNOTE
            - PAGE-FOOTER
          description: Type of the content element
        content:
          type: string
          description: Content text
        content_as_html:
          type: string
          description: Content text in HTML format
        page:
          type: number
          description: Page number where the content is located in the document
        parent:
          type: number
          description: Parent content identifier
      required:
        - id
        - type
        - content
        - page
      description: Detailed information about the content of a document
    DocumentImageSchema:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the image
        file_id:
          type: string
          description: File identifier associated with the image
        image_url:
          type: string
          description: URL of the image
        type:
          type: string
          description: Type of the image
        page:
          type: number
          description: Page number where the image is located in the document
        height:
          type: number
          description: Height of the image
        width:
          type: number
          description: Width of the image
      required:
        - id
        - file_id
        - image_url
        - type
        - page
        - height
        - width
      description: Detailed information about an image in a document

````