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

# Upload a File

> Uploads a file to your library. The file must be 5 MB or smaller.



## OpenAPI

````yaml POST /files
openapi: 3.1.0
info:
  title: Moonbase REST API
  version: v0
servers:
  - url: https://api.moonbase.ai/v0
security:
  - bearer: []
tags:
  - name: Inboxes
    description: Manage your inboxes, conversations, and messages
  - name: Collections
    description: Manage your collections and items
  - name: Marketing
    description: Manage your marketing campaigns and forms
  - name: Activities
    description: View activities and capture calls
  - name: Library
    description: Manage your meetings, files, and notes
paths:
  /files:
    post:
      tags:
        - Library
      summary: Upload a file
      description: Uploads a file to your library. The file must be 5 MB or smaller.
      parameters: []
      requestBody:
        description: The file content and optional metadata to upload.
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/FileCreateParams'
      responses:
        '201':
          description: Upload succeeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/File'
              examples:
                Default:
                  summary: Default
                  value:
                    id: 1CLJt2v5aNd8G5SGzEaeVU
                    type: file
                    name: Example
                    filename: test.txt
                    size: 3
                    download_url: >-
                      https://api.moonbase.ai/asset_redirects/1CLJt2v6592N5WQzNpjpj2?token=eyJfcmFpbHMiOnsiZGF0YSI6eyJpZCI6IjFDTEp0MnY2NTkyTjVXUXpOcGpwajIiLCJibG9iX2lkIjoiMUNMSnQydjVwa3BrQW52ZGdYZkVjRiIsImNyZWF0ZWRfYXQiOiIyMDI1LTAyLTE3VDE2OjAwOjAwLjAwMFoiLCJuYW1lIjoiZmlsZSIsInJlY29yZF9pZCI6IjFDTEp0MnY1YU5kOEc1U0d6RWFlVlUiLCJyZWNvcmRfdHlwZSI6IkxpYnJhcnlBc3NldCJ9LCJleHAiOiIyMDI1LTAyLTE3VDE3OjAwOjAwLjAwMFoiLCJwdXIiOiJyZWRpcmVjdCJ9fQ--f2913cda85a97e3a8afe3b75c764f2dcee6abf98
                    associations: []
                    created_at: '2025-02-17T16:00:00.000Z'
                    updated_at: '2025-02-17T16:00:00.000Z'
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '400'
                        title: Bad Request
                        detail: >-
                          The request could not be understood due to malformed
                          syntax or invalid parameters.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '401'
                        title: Unauthorized
                        detail: >-
                          Invalid or missing API key or JWT. You should provide
                          your Moonbase API Key or JWT in the authorization
                          header, in the format: "Authorization: Bearer
                          MOONBASE_API_KEY"
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '403'
                        title: Forbidden
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '429'
                        title: Too Many Requests
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '500'
                        title: Internal Server Error
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Errors'
              examples:
                Default:
                  summary: Default
                  value:
                    type: errors
                    errors:
                      - type: error
                        status: '503'
                        title: Service Unavailable
                        detail: >-
                          The service is temporarily unavailable, please try
                          again later.
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import fs from 'fs';

            import Moonbase from '@moonbaseai/sdk';


            const client = new Moonbase({
              apiKey: process.env['MOONBASE_API_KEY'], // This is the default and can be omitted
            });


            const moonbaseFile = await client.files.upload({ file:
            fs.createReadStream('path/to/file') });


            console.log(moonbaseFile.id);
        - lang: Python
          source: |-
            import os
            from moonbase import Moonbase

            client = Moonbase(
                api_key=os.environ.get("MOONBASE_API_KEY"),  # This is the default and can be omitted
            )
            moonbase_file = client.files.upload(
                file=b"Example data",
            )
            print(moonbase_file.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/moonbaseai/moonbase-sdk-go\"\n\t\"github.com/moonbaseai/moonbase-sdk-go/option\"\n)\n\nfunc main() {\n\tclient := moonbase.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tmoonbaseFile, err := client.Files.Upload(context.TODO(), moonbase.FileUploadParams{\n\t\tFile: io.Reader(bytes.NewBuffer([]byte(\"Example data\"))),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", moonbaseFile.ID)\n}\n"
        - lang: Ruby
          source: >-
            require "moonbase"


            moonbase = Moonbase::Client.new(api_key: "My API Key")


            moonbase_file = moonbase.files.upload(file: StringIO.new("Example
            data"))


            puts(moonbase_file)
components:
  schemas:
    FileCreateParams:
      title: FileCreateParams
      description: Parameters for uploading a `File` object.
      type: object
      properties:
        file:
          description: >-
            The raw file content to upload in a multipart/form-data request.
            Must be 5 MB or smaller.
          type: string
          format: binary
          maxLength: 5242880
        name:
          description: The display name of the file.
          type: string
        associations:
          description: >-
            Link the File to Moonbase items like a person, organization, deal,
            task, or an item in a custom collection.
          type: array
          items:
            $ref: '#/components/schemas/ItemPointerParam'
      required:
        - file
    File:
      title: File
      description: >-
        The File object represents a file that has been uploaded to your
        library.
      type: object
      properties:
        type:
          description: >-
            String representing the object’s type. Always `file` for this
            object.
          type: string
          const: file
        id:
          description: Unique identifier for the object.
          type: string
        name:
          description: The display name of the file.
          type: string
        filename:
          description: The original filename of the uploaded file.
          type: string
        size:
          description: The size of the file in bytes.
          type: number
        download_url:
          description: >-
            A temporary, signed URL to download the file content. The URL
            expires after one hour.
          type: string
          format: uri
        associations:
          description: A list of items this file is associated with.
          type: array
          items:
            $ref: '#/components/schemas/ItemPointer'
        created_at:
          description: >-
            Time at which the object was created, as an ISO 8601 timestamp in
            UTC.
          type: string
          format: date-time
        updated_at:
          description: >-
            Time at which the object was last updated, as an ISO 8601 timestamp
            in UTC.
          type: string
          format: date-time
      required:
        - name
        - type
        - id
        - filename
        - size
        - download_url
        - associations
        - created_at
        - updated_at
    Errors:
      title: Errors
      description: >-
        The Errors object is a container that holds multiple Error objects when
        an API request encounters several validation or processing issues. This
        allows the API to return comprehensive feedback about all problems
        encountered in a single response.
      type: object
      properties:
        type:
          type: string
          const: errors
        errors:
          description: A list of `Error` objects.
          type: array
          items:
            $ref: '#/components/schemas/Error'
      required:
        - type
    ItemPointerParam:
      title: ItemPointerParam
      description: A lightweight reference to an `Item` used in request bodies.
      type: object
      properties:
        type:
          description: >-
            String representing the object’s type. Always `item` for this
            object.
          type: string
          const: item
        id:
          description: Unique identifier of the item.
          type: string
      required:
        - type
        - id
    ItemPointer:
      title: ItemPointer
      description: >-
        A reference to an `Item` within a specific `Collection`, providing the
        context needed to locate the item.
      type: object
      properties:
        type:
          description: >-
            String representing the object’s type. Always `item` for this
            object.
          type: string
          const: item
        id:
          description: Unique identifier of the item.
          type: string
        collection:
          $ref: '#/components/schemas/CollectionPointer'
          description: A reference to the `Collection` containing this item.
      required:
        - collection
        - type
        - id
    Error:
      title: Error
      description: >-
        The Error object represents a single error that occurred during API
        request processing. It provides detailed information about what went
        wrong, including a unique identifier, status code, and human-readable
        descriptions to help developers understand and resolve the issue.
      type: object
      properties:
        type:
          type: string
          const: error
        id:
          description: A unique identifier for this specific error instance.
          type: string
        status:
          description: The HTTP status code for this problem, as a string.
          type: string
        code:
          description: An application-specific error code string.
          type: string
        title:
          description: A short, human-readable summary of the problem.
          type: string
        detail:
          description: A human-readable explanation of this specific error.
          type: string
        source:
          $ref: '#/components/schemas/ErrorSource'
          description: >-
            An object containing more specific information about the part of the
            request that caused the error.
        meta:
          type: object
          additionalProperties: true
      required:
        - type
    CollectionPointer:
      title: CollectionPointer
      description: >-
        A lightweight reference to a `Collection`, containing the minimal
        information needed to identify it.
      type: object
      properties:
        type:
          description: >-
            String representing the object’s type. Always `collection` for this
            object.
          type: string
          const: collection
        id:
          description: Unique identifier of the collection.
          type: string
        ref:
          description: The stable, machine-readable reference identifier of the collection.
          type: string
      required:
        - type
        - id
        - ref
    ErrorSource:
      title: ErrorSource
      description: >-
        The ErrorSource object provides additional context about the specific
        part of an API request that caused an error. It can point to either a
        field in the request document or a query parameter that contains invalid
        data.
      type: object
      properties:
        pointer:
          description: >-
            A JSON Pointer [RFC6901] to the associated entity in the request
            document.
          type: string
        parameter:
          description: A string indicating which URI query parameter caused the error.
          type: string
      required: []
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      description: Your Moonbase API key.

````