---
title: "Create File"
method: POST
path: "/file"
tags: ["File"]
---

# Create File

`POST /file`

## Request

- Base URL: `https://oneuptime.com/api`
- URL: `https://oneuptime.com/api/file`
- Auth: API key in header `APIKey`
- TypeScript: <https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/docs/file/post.ts> (a function with typed inputs; its response is checked against the schema)

Endpoint to create a new File

## Request body

- object
  - `data` FileCreateSchema, required: Create schema for File model. Create
    - `file` string, binary: The file's content. Permissions - Create: [Logged in User], Read: [Logged in User], Update: [No access - you don't have permission for this operation]
    - `name` string, required: Any friendly name of this object. Permissions - Create: [Logged in User], Read: [Logged in User], Update: [No access - you don't have permission for this operation]
    - `fileType` 'audio/aac' | 'image/png' | 'image/jpeg' | 'image/svg+xml' | 'image/gif' | 'image/webp' | 'image/x-icon' | 'image/bmp' | 'image/tiff' | 'image/avif' | 'image/heic' | 'application/pdf' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'text/plain' | 'text/markdown' | 'text/csv' | 'application/rtf' | 'application/vnd.oasis.opendocument.text' | 'application/json' | 'application/zip' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.oasis.opendocument.spreadsheet' | 'application/vnd.ms-powerpoint' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'application/vnd.oasis.opendocument.presentation' | 'application/vnd.tcpdump.pcap', required: The file's media type, such as image/png. Permissions - Create: [Logged in User], Read: [Logged in User], Update: [No access - you don't have permission for this operation]
    - `slug` string: Friendly globally unique name for your object. Permissions - Create: [Logged in User], Read: [Logged in User], Update: [No access - you don't have permission for this operation]

## Response `201`

Created successfully

- object
  - `data` FileReadSchema: Read schema for File model. Read
    - `file` string, binary: The file's content. Permissions - Create: [Logged in User], Read: [Logged in User], Update: [No access - you don't have permission for this operation]
    - `name` string, required: Any friendly name of this object. Permissions - Create: [Logged in User], Read: [Logged in User], Update: [No access - you don't have permission for this operation]
    - `fileType` 'audio/aac' | 'image/png' | 'image/jpeg' | 'image/svg+xml' | 'image/gif' | 'image/webp' | 'image/x-icon' | 'image/bmp' | 'image/tiff' | 'image/avif' | 'image/heic' | 'application/pdf' | 'application/msword' | 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' | 'text/plain' | 'text/markdown' | 'text/csv' | 'application/rtf' | 'application/vnd.oasis.opendocument.text' | 'application/json' | 'application/zip' | 'application/vnd.ms-excel' | 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | 'application/vnd.oasis.opendocument.spreadsheet' | 'application/vnd.ms-powerpoint' | 'application/vnd.openxmlformats-officedocument.presentationml.presentation' | 'application/vnd.oasis.opendocument.presentation' | 'application/vnd.tcpdump.pcap', required: The file's media type, such as image/png. Permissions - Create: [Logged in User], Read: [Logged in User], Update: [No access - you don't have permission for this operation]
    - `slug` string: Friendly globally unique name for your object. Permissions - Create: [Logged in User], Read: [Logged in User], Update: [No access - you don't have permission for this operation]
    - `isPublic` boolean: Whether anyone may read the file without signing in. Set by OneUptime: every upload starts private, and a file becomes public only when a record that shows it to everyone, such as a public note or a probe's icon, is published. Permissions - Create: [No access - you don't have permission for this operation], Read: [Logged in User], Update: [No access - you don't have permission for this operation]
    - `imageAccessToken` string: Addresses the file in a link (/file/image/access-token/<token>) without its ID. Opening it still takes the right to see the file. Set by OneUptime. Permissions - Create: [No access - you don't have permission for this operation], Read: [Logged in User], Update: [No access - you don't have permission for this operation]

## Other responses

- `400`: Bad request. This response indicates that the request was malformed or contained invalid data.
- `401`: Unauthorized. This response indicates that the request requires user authentication.
- `402`: Payment Required. This response indicates that the request requires payment or a valid subscription.
- `403`: Forbidden. This response indicates that the server understood the request, but refuses to authorize it.
- `405`: Project not found. This response indicates that the requested project does not exist or is not accessible.
- `408`: Request Timeout. This response indicates that the server timed out waiting for the request.
- `415`: Unable to reach server. This response indicates that the server is currently unreachable or down.
- `422`: Not authorized. This response indicates that the user does not have permission to access the requested resource.
- `500`: Internal Server Error. This response indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

---

[API](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification.md) - [All operations](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/llms.txt) - [OpenAPI document](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/revisions/ba3307d00304?raw)
