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

# Upload an attachment

> Upload a multipart file with the default storage target, as used by contexts.uploadFile(). Use the returned FileAsset handle in input.message.input.files. Its id differs from storageFileId. File parsing may still be pending when the upload returns.



## OpenAPI

````yaml /api/openapi.sdk.json post /api/ai/contexts/file
openapi: 3.0.3
info:
  title: XpertAI SDK HTTP API
  version: 1.0.0
  description: >-
    Current HTTP endpoints used by the SDK guide. Authenticate with a
    server-side API Key using Authorization: Bearer <API_KEY> or x-api-key.
    These endpoints do not require ChatKit. The reference covers the guide
    examples, not every method exported by the SDK. Check deployment support
    before using additional fields.
servers:
  - url: https://api.xpertai.cn
    description: XpertAI API. Replace with your own API origin for private deployments.
security:
  - ApiKeyBearer: []
  - ApiKeyHeader: []
tags:
  - name: Assistants
  - name: Threads
  - name: Runs
  - name: Contexts
  - name: Store
paths:
  /api/ai/contexts/file:
    post:
      tags:
        - Contexts
      summary: Upload an attachment
      description: >-
        Upload a multipart file with the default storage target, as used by
        contexts.uploadFile(). Use the returned FileAsset handle in
        input.message.input.files. Its id differs from storageFileId. File
        parsing may still be pending when the upload returns.
      operationId: upload_file
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
              required:
                - file
      responses:
        '201':
          description: Successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentFile'
              example:
                id: 55555555-5555-4555-8555-555555555555
                storageFileId: 66666666-6666-4666-8666-666666666666
                originalName: manual.pdf
                mimeType: application/pdf
                parseStatus: pending
        '400':
          description: Invalid input, identifier mismatch or invalid operation state.
        '401':
          description: Missing or invalid API Key.
        '403':
          description: The caller cannot access the requested resource.
        '404':
          description: Resource not found or unavailable to the caller.
components:
  schemas:
    AgentFile:
      type: object
      properties:
        id:
          type: string
          description: FileAsset ID. Pass the returned handle in message.input.files.
        fileId:
          type: string
        storageFileId:
          type: string
          description: >-
            StorageFile ID for knowledgebase document associations; do not
            substitute the FileAsset ID.
        url:
          type: string
        originalName:
          type: string
        size:
          type: integer
        mimeType:
          type: string
        status:
          type: string
        parseStatus:
          type: string
        parseMode:
          type: string
        purpose:
          type: string
      required:
        - id
  securitySchemes:
    ApiKeyBearer:
      type: http
      scheme: bearer
      description: Server-side API Key; do not expose it in browser code.
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````

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