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

# Uploading a file or creating a directory

> Upload a file or create a directory to provide one of the body params. You can not provide both at the same time. **Note**: If you upload a file, use the `multipart/form-data` post. For creating a directory, use the regular `application/json` post.



## OpenAPI

````yaml /openapi.yaml post /files
openapi: 3.1.1
info:
  title: MijnKlantportaal API
  version: v1
servers:
  - url: https://api.mijnklantportaal.nl/v1
security:
  - APIKey: []
tags:
  - name: Agreements API
  - name: Appointments API
  - name: Customers API
  - name: Customer Groups API
  - name: Customer Invoices API
  - name: Customer Offers API
  - name: Customer Subscriptions API
  - name: Customer Subscription Packages API
  - name: Files API
  - name: File Request API
  - name: File Share API
  - name: Invoices API
  - name: Payment Links API
  - name: Punch Cards API
  - name: Tickets API
  - name: Webhooks API
paths:
  /files:
    post:
      tags:
        - Files API
      summary: Uploading a file or creating a directory
      description: >-
        Upload a file or create a directory to provide one of the body params.
        You can not provide both at the same time. **Note**: If you upload a
        file, use the `multipart/form-data` post. For creating a directory, use
        the regular `application/json` post.
      operationId: post-files
      parameters:
        - name: directory
          in: query
          description: ID of the directory to place the file or directory in.
          required: false
          schema:
            type: string
            example: fsd_abc12345678
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: The file you want to upload
          application/json:
            schema:
              type: object
              properties:
                directory:
                  type: string
                  example: Contracts
                  description: Name of the directory to create
      responses:
        '201':
          description: Returning the created file or directory
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileOrDirectory'
        '422':
          description: Something is wrong with the posted data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error_ApiError'
        '426':
          description: The file exceeds the available storage space for this license
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error_ApiError'
components:
  schemas:
    FileOrDirectory:
      type: object
      description: File or Directory
      properties:
        id:
          type: string
          example: fsf_abc12345678
          description: >-
            ID of the file or directory. Files are starting with `fsf_`,
            directories with `fsd_`.
        type:
          type: string
          example: file
          description: Type of this content item. Can be `file` or `directory`.
        name:
          type: string
          example: contract_v2.pdf
          description: Name of the file or directory
        size:
          type: integer
          nullable: true
          example: 1284
          description: Size of the file in bytes. Will be `null` for directories.
        mime:
          type: string
          nullable: true
          example: application/pdf
          description: The mime-type of the file. Will be `null` for directories.
        fileShareId:
          type: string
          nullable: true
          example: fss_abc12345678
          description: ID of the Share this file or directory is shared in, if shared.
        createdAt:
          type: string
          example: '2024-04-29T21:00:00+02:00'
          description: >-
            Date and time when the payment link was created. Written in ATOM
            format.
    Error_ApiError:
      type: object
      properties:
        message:
          type: string
          description: Explanation what went wrong
  securitySchemes:
    APIKey:
      type: http
      scheme: bearer

````