> ## Documentation Index
> Fetch the complete documentation index at: https://magica-adi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload a file

> Multipart upload. Stores the file and returns an attachment id.
Pass `chatId` only to attach it to an existing chat. Omitting `chatId`
does not create a chat — use `attachmentIds` on send, or upload in
the same request on `/completions`.
Images, video, and audio. 20 MB per file, 8 files.




## OpenAPI

````yaml /openapi.yaml post /uploads
openapi: 3.1.0
info:
  title: Galaxy Agent API
  version: 1.0.0
  description: |
    Public REST for agent chats, Magica tools, and run status.
    Authenticate with `Authorization: Bearer gxk_live_…`.
servers:
  - url: https://magica-backend-oda9.onrender.com/api/v1
    description: Production
  - url: http://localhost:4000/api/v1
    description: Local
security:
  - bearerAuth: []
tags:
  - name: Chats
  - name: Messages
  - name: Runs
  - name: Magica
paths:
  /uploads:
    post:
      tags:
        - Messages
      summary: Upload a file
      description: |
        Multipart upload. Stores the file and returns an attachment id.
        Pass `chatId` only to attach it to an existing chat. Omitting `chatId`
        does not create a chat — use `attachmentIds` on send, or upload in
        the same request on `/completions`.
        Images, video, and audio. 20 MB per file, 8 files.
      operationId: uploadFiles
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                files:
                  type: array
                  items:
                    type: string
                    format: binary
                chatId:
                  type: string
                  format: uuid
      responses:
        '201':
          description: Files stored
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadResult'
        '400':
          description: Type or size rejected
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: S3 or Transloadit is not configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    UploadResult:
      type: object
      required:
        - attachments
      properties:
        chatId:
          type: string
          format: uuid
          nullable: true
          description: Set only when you passed `chatId`. Upload does not create a chat.
        attachments:
          type: array
          items:
            type: object
            required:
              - id
              - filename
              - mimeType
              - status
            properties:
              id:
                type: string
                format: uuid
              filename:
                type: string
              mimeType:
                type: string
              url:
                type: string
                nullable: true
              status:
                type: string
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        code:
          type: string
          examples:
            - UNAUTHORIZED
            - CHAT_NOT_FOUND
            - RUN_ACTIVE
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key created in the product. Shown once, prefix `gxk_live_`.

````

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