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

# Upload A File

> 向 UQPAY 上传文件。上传文件的最大大小为 `20MB`。支持的文件类型包括 `jpeg`、`png`、`jpg`、`doc`、`docx`、`pdf`。上传文件后，API 会返回一个 file_id。在我们的其他端点中，可按需将该文件 ID 作为 attachments 对象的一部分进行引用。



## OpenAPI

````yaml /zh/account-center/v1.6/supporting.yaml post /v1/files/upload
openapi: 3.0.2
info:
  version: 0.0.1
  x-source-en-commit: 8315da9
  x-source-en-path: account-center/v1.6/supporting.yaml
  title: Supporting Services
servers:
  - url: https://files.uqpaytech.com/api
    description: Sandbox 基础 URL。
  - url: https://files.uqpay.com/api
    description: 生产环境基础 URL。
security: []
tags:
  - name: File Service
paths:
  /v1/files/upload:
    post:
      tags:
        - File Service
      summary: Upload A File
      description: >-
        向 UQPAY 上传文件。上传文件的最大大小为 `20MB`。支持的文件类型包括
        `jpeg`、`png`、`jpg`、`doc`、`docx`、`pdf`。上传文件后，API 会返回一个
        file_id。在我们的其他端点中，可按需将该文件 ID 作为 attachments 对象的一部分进行引用。
      operationId: upload-file
      parameters:
        - $ref: '#/components/parameters/XOnBehalfOf'
        - $ref: '#/components/parameters/XIdempotencyKey'
        - $ref: '#/components/parameters/Notes'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  type: string
                  format: binary
      responses:
        '200':
          description: OK——文件上传成功。
          headers:
            x-response-id:
              $ref: '#/components/headers/XResponseId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadFileResponse'
                title: UploadFileResponse
      security:
        - XAuthToken: []
components:
  parameters:
    XOnBehalfOf:
      in: header
      name: x-on-behalf-of
      schema:
        type: string
      required: false
      description: >-
        设置为关联账户 ID 的值。更多信息参见
        [列出关联账户](/zh/account-center/v1.6/api-reference/list-connected-accounts)
      example: 18523f72-f4de-4f9c-bb8e-ec7d1c4f32be
    XIdempotencyKey:
      in: header
      name: x-idempotency-key
      schema:
        type: string
        format: uuid
      required: true
      description: >-
        用于保持操作幂等性的唯一标识符（UUID），确保同一操作的重复执行不会产生意外影响或重复结果。在出现网络错误、重试或失败时，它有助于保持数据一致性。
      example: 2adesf8e-9d63-44bc-b975-9b6ae3440dde
    Notes:
      name: notes
      description: 所上传文件的备注，最大长度为 50 个字符。
      in: query
      required: false
      schema:
        type: string
        maxLength: 50
  headers:
    XResponseId:
      description: 响应的全局唯一标识符（UUID v4）。在与 UQPAY 支持团队沟通时，有助于定位某个请求。
      schema:
        type: string
        format: uuid
        example: 2adba88e-9d63-44bc-b975-9b6ae3440dde
  schemas:
    UploadFileResponse:
      type: object
      required:
        - create_time
        - file_id
        - file_name
        - file_type
        - size
        - notes
      properties:
        create_time:
          type: string
          description: 文件上传的时间戳。
          example: '2024-08-22T17:12:58+08:00'
        file_id:
          type: string
          description: 所上传文件的唯一标识符。在其他 API 调用中使用该 ID 来引用此文件。
          example: b3d9d2d5-4c12-4946-a09d-953e82sed2b0
        file_name:
          type: string
          description: 所上传文件的原始名称（含扩展名）。
          example: example.png
        file_type:
          type: string
          description: 文件扩展名类型（例如 `png`、`pdf`、`docx`）。
          example: png
        size:
          type: integer
          description: 文件大小，单位为字节。
          example: 123456
        notes:
          type: string
          description: 与该文件关联的可选备注。
          example: This is a note
  securitySchemes:
    XAuthToken:
      type: apiKey
      in: header
      name: x-auth-token
      description: 用于请求 API 的 Token。

````