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

# Upload a file

> Upload a new file to the organization's file storage



## OpenAPI

````yaml post /files/upload
openapi: 3.1.0
info:
  title: BitGPT 402pay API
  description: Full description of private and dev-availble API endpoints
  version: 1.0.0
  termsOfService: https://bitgpt.xyz/terms
  contact:
    name: API Support
    url: https://help.bitgpt.xyz
    email: support@bitgpt.xyz
servers:
  - url: https://api.bitgpt.xyz
    description: Production API server
security: []
tags:
  - name: Payments
    description: Invoice and payment management endpoints
  - name: Products
    description: Product management endpoints
  - name: dev-api
    description: Developer API endpoints
externalDocs:
  description: Full BitGPT 402pay API documentation
  url: https://docs.bitgpt.xyz
paths:
  /files/upload:
    post:
      tags:
        - Files
        - dev-api
      summary: Upload a file
      description: Upload a new file to the organization's file storage
      operationId: uploadFile
      requestBody:
        $ref: '#/components/requestBodies/uploadFileRequest'
      responses:
        '200':
          $ref: '#/components/responses/uploadFileResponse'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
      security:
        - BearerAuth: []
          ApiKeyAuth: []
components:
  requestBodies:
    uploadFileRequest:
      required: true
      content:
        multipart/form-data:
          schema:
            $ref: '#/components/schemas/uploadFileRequest'
  responses:
    '400':
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: integer
                enum:
                  - 400
                  - 401
                  - 403
                  - 404
                description: Status code of the response
              data:
                type:
                  - object
                  - 'null'
                description: Response data containing the requested object
              error:
                type:
                  - string
                  - 'null'
                examples:
                  - Invalid email address
                description: Error message of the response, human readable
              message:
                type: 'null'
              env:
                type: string
                enum:
                  - development
                  - production
                description: API environment
              log:
                type:
                  - string
                  - object
                  - 'null'
                examples:
                  - request_id: req_1234567890
                  - Some pertinent log message
                description: Useful informaiton, not always present, to debug the response
              validator:
                type:
                  - object
                  - 'null'
                examples:
                  - email: Invalid email address
                    password: Password is required
                description: >-
                  Validator response object, each key is the field name and
                  value is the error message
              support_id:
                type:
                  - string
                  - 'null'
                format: uuid
                examples:
                  - support_uuidv7-something-else
                description: >-
                  Support ID linked to the response, used to identify it when
                  talking with our team
            required:
              - status
              - error
              - message
              - env
              - log
              - validator
              - support_id
    '401':
      description: Access token is missing or invalid
      content:
        application/json:
          schema:
            allOf:
              - type: object
                properties:
                  status:
                    type: integer
                    enum:
                      - 400
                      - 401
                      - 403
                      - 404
                    description: Status code of the response
                  data:
                    type:
                      - object
                      - 'null'
                    description: Response data containing the requested object
                  error:
                    type:
                      - string
                      - 'null'
                    examples:
                      - Invalid email address
                    description: Error message of the response, human readable
                  message:
                    type: 'null'
                  env:
                    type: string
                    enum:
                      - development
                      - production
                    description: API environment
                  log:
                    type:
                      - string
                      - object
                      - 'null'
                    examples:
                      - request_id: req_1234567890
                      - Some pertinent log message
                    description: >-
                      Useful informaiton, not always present, to debug the
                      response
                  validator:
                    type:
                      - object
                      - 'null'
                    examples:
                      - email: Invalid email address
                        password: Password is required
                    description: >-
                      Validator response object, each key is the field name and
                      value is the error message
                  support_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    examples:
                      - support_uuidv7-something-else
                    description: >-
                      Support ID linked to the response, used to identify it
                      when talking with our team
                required:
                  - status
                  - error
                  - message
                  - env
                  - log
                  - validator
                  - support_id
              - properties:
                  status:
                    type: integer
                    enum:
                      - 401
    '403':
      description: You do not have the required permissions to access this resource
      content:
        application/json:
          schema:
            allOf:
              - type: object
                properties:
                  status:
                    type: integer
                    enum:
                      - 400
                      - 401
                      - 403
                      - 404
                    description: Status code of the response
                  data:
                    type:
                      - object
                      - 'null'
                    description: Response data containing the requested object
                  error:
                    type:
                      - string
                      - 'null'
                    examples:
                      - Invalid email address
                    description: Error message of the response, human readable
                  message:
                    type: 'null'
                  env:
                    type: string
                    enum:
                      - development
                      - production
                    description: API environment
                  log:
                    type:
                      - string
                      - object
                      - 'null'
                    examples:
                      - request_id: req_1234567890
                      - Some pertinent log message
                    description: >-
                      Useful informaiton, not always present, to debug the
                      response
                  validator:
                    type:
                      - object
                      - 'null'
                    examples:
                      - email: Invalid email address
                        password: Password is required
                    description: >-
                      Validator response object, each key is the field name and
                      value is the error message
                  support_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    examples:
                      - support_uuidv7-something-else
                    description: >-
                      Support ID linked to the response, used to identify it
                      when talking with our team
                required:
                  - status
                  - error
                  - message
                  - env
                  - log
                  - validator
                  - support_id
              - properties:
                  status:
                    type: integer
                    enum:
                      - 403
    uploadFileResponse:
      description: File uploaded successfully
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/Response200'
              - $ref: '#/components/schemas/uploadFileResponse'
  schemas:
    uploadFileRequest:
      type: object
      description: Request body for uploading a file
      properties:
        file:
          type: string
          format: binary
          description: The file to upload
        name:
          type: string
          description: Optional custom name for the file
          maxLength: 255
      required:
        - file
    Response200:
      type: object
      properties:
        status:
          type: integer
          enum:
            - 200
            - 201
            - 202
          description: Status code of the response
        data:
          type:
            - object
            - array
            - 'null'
          description: Response data containing the requested object
        error:
          type:
            - string
            - 'null'
          examples:
            - Invalid email address
          description: Error message of the response, human readable
        message:
          type:
            - string
            - 'null'
          examples:
            - Resource created successfully
          description: Message of the response, human readable
        env:
          type: string
          enum:
            - development
            - production
          description: API environment
        log:
          type:
            - string
            - object
            - 'null'
          examples:
            - request_id: req_1234567890
            - Some pertinent log message
          description: Useful informaiton, not always present, to debug the response
        validator:
          type:
            - object
            - 'null'
          examples:
            - email: Invalid email address
              password: Password is required
          description: >-
            Validator response object, each key is the field name and value is
            the error message
        support_id:
          type:
            - string
            - 'null'
          format: uuid
          examples:
            - support_uuidv7-something-else
          description: >-
            Support ID linked to the response, used to identify it when talking
            with our team
      required:
        - status
        - data
        - message
        - env
      examples:
        - status: 200
          data:
            id: '123'
          error: null
          log: null
          validator: null
          support_id: null
          message: Resource created successfully
          env: development
    uploadFileResponse:
      type: object
      description: Response containing the uploaded file information
      properties:
        data:
          $ref: '#/components/schemas/file'
      required:
        - data
      examples:
        - id: file_0198042e-6dde-7b9c-bc91-452a7e0c833b
          name: uploaded-file.jpg
          url: >-
            https://assets.bitgpt.xyz/org_uploads/org_0196b0e9-11d8-7f26-b1d2-bd47054e4827/image/0198042e-6dde-76e0-b817-3afb324e29ac.jpg
          size: 1060793
          mime_type: image/jpeg
          type: image
          is_duplicate: true
    file:
      type: object
      description: >-
        File object containing file identifier and URL for accessing the file
        resource
      properties:
        id:
          type: string
          description: Unique identifier for the file
          examples:
            - file_0196b6e6-54e3-796d-9c6a-2862a5fef597
        name:
          type: string
          description: Original filename
          examples:
            - 4.jpg
        url:
          type:
            - string
            - 'null'
          format: uri
          description: URL for accessing the file resource
          examples:
            - >-
              https://assets.bitgpt.xyz//app/public/src/storage/uploads/image/2025/05/09/0196b6e6-54e3-7290-9d73-0074c623e368.jpg
        mime_type:
          type: string
          description: MIME type of the file
          examples:
            - image/jpeg
        type:
          type: string
          description: >-
            Type of the file (e.g., image, document, video, audio, archive,
            general)
          enum:
            - image
            - document
            - video
            - audio
            - archive
            - general
          examples:
            - image
        is_duplicate:
          type: boolean
          description: Indicates if the file is a duplicate
          examples:
            - true
        hash:
          type: string
          description: File hash for duplicate detection
          examples:
            - 04b9e2ec43133ae7287f97764c0beda19f304374e1d6bfe4fcc36ad54502e5dc
        organization_id:
          type: string
          description: Organization identifier that owns the file
          examples:
            - org_0196b0e9-11d8-7f26-b1d2-bd47054e4827
        original_name:
          type: string
          description: Original filename as uploaded
          examples:
            - 4.jpg
        filename:
          type: string
          description: Generated filename for storage
          examples:
            - 0198042e-6dde-76e0-b817-3afb324e29ac.jpg
        filepath:
          type: string
          description: Full path to the file in storage
          examples:
            - >-
              org_uploads/org_0196b0e9-11d8-7f26-b1d2-bd47054e4827/image/0198042e-6dde-76e0-b817-3afb324e29ac.jpg
        file_size:
          type: integer
          description: File size in bytes (alternative to size field)
          examples:
            - 1060793
        created_at:
          type: string
          format: mysql-date-time
          description: Timestamp when the file was created
          examples:
            - '2025-07-13 16:26:48.415'
        updated_at:
          type:
            - string
            - 'null'
          format: mysql-date-time
          description: Timestamp when the file was last updated
          examples:
            - null
      examples:
        - id: file_0196b6e6-54e3-796d-9c6a-2862a5fef597
          url: >-
            https://assets.bitgpt.xyz//app/public/src/storage/uploads/image/2025/05/09/0196b6e6-54e3-7290-9d73-0074c623e368.jpg
        - id: file_0198042e-6dde-7b9c-bc91-452a7e0c833b
          name: 4.jpg
          url: >-
            https://assets.bitgpt.xyz/org_uploads/org_0196b0e9-11d8-7f26-b1d2-bd47054e4827/image/0198042e-6dde-76e0-b817-3afb324e29ac.jpg
          file_size: 1060793
          mime_type: image/jpeg
          is_duplicate: true
        - id: file_0198042e-6dde-7b9c-bc91-452a7e0c833b
          hash: 04b9e2ec43133ae7287f97764c0beda19f304374e1d6bfe4fcc36ad54502e5dc
          organization_id: org_0196b0e9-11d8-7f26-b1d2-bd47054e4827
          original_name: 4.jpg
          filename: 0198042e-6dde-76e0-b817-3afb324e29ac.jpg
          filepath: >-
            org_uploads/org_0196b0e9-11d8-7f26-b1d2-bd47054e4827/image/0198042e-6dde-76e0-b817-3afb324e29ac.jpg
          mime_type: image/jpeg
          file_size: 1060793
          type: image
          created_at: '2025-07-13 16:26:48.415'
          updated_at: null
          url: >-
            https://assets.bitgpt.xyz/org_uploads/org_0196b0e9-11d8-7f26-b1d2-bd47054e4827/image/0198042e-6dde-76e0-b817-3afb324e29ac.jpg
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Send your access token as header Authorization: Bearer {accessToken}'
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Your API key that starts with sk_live or sk_test. You can create yours
        at go.bitgpt.xyz/api-keys.

````