---
title: "Upload a new file"
method: POST
path: "/api/files"
tags: ["FileUploads"]
---

# Upload a new file

`POST /api/files`

## Request

- Base URL: `https://api.sponsorunited.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.sponsorunited.com/api/files`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/sponsorunited/apis/sponsorunited-api/docs/api/files/post.ts> (a function with typed inputs; its response is checked against the schema)

Stores a file, generates a thumbnail if necessary, and returns its details.

## Request body `multipart/form-data`

- FileUploadRequest: Request schema for uploading a file
  - `file` string, binary, required: The file to upload. Must be a PDF, PPT, PPTX, XLS, XLSX, or CSV. Max size 20MB.
  - `generate_thumbnail` boolean: Whether to generate a thumbnail for the uploaded file.

## Response `200`

The uploaded file details

- FileUploadResource: File upload details.
  - `id` integer: Unique identifier of the file upload
  - `original_name` string: The original name of the file
  - `stored_name` string: The stored name of the file
  - `mime_type` string: The MIME type of the file
  - `file_size` integer: The size of the file in bytes
  - `file_hash` string: A hash of the file for integrity verification
  - `url` string: The URL where the file can be accessed
  - `created_at` string, date-time: Timestamp when the file was created
  - `updated_at` string, date-time: Timestamp when the file was last updated
  - `user` object: The user who uploaded the file
    - `id` integer: Unique identifier of the user
    - `name` string: Name of the user
  - `thumbnail` object: Thumbnail of the file
    - `id` integer: Unique identifier of the thumbnail
    - `original_url` string: Original URL of the thumbnail
    - `image_url` string: Image URL of the thumbnail
    - `resized_image_url` string: Resized image URL of the thumbnail
    - `extension` string: File extension of the thumbnail
    - `mime_type` string: MIME type of the thumbnail
    - `file_size` integer: File size of the thumbnail in bytes
    - `width` integer: Width of the thumbnail in pixels
    - `height` integer: Height of the thumbnail in pixels

## Other responses

- `400`: Invalid request

---

[API](https://skmtc.dev/sponsorunited/apis/sponsorunited-api.md) - [All operations](https://skmtc.dev/sponsorunited/apis/sponsorunited-api/llms.txt) - [OpenAPI document](https://skmtc.dev/sponsorunited/apis/sponsorunited-api/revisions/cbf1ca5bff8f?raw)
