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

# Upload a file

`POST /api/v4/files`

Uploads a file that can later be attached to a post.

This request can either be a multipart/form-data request with a channel_id, files and optional
client_ids defined in the FormData, or it can be a request with the channel_id and filename
defined as query parameters with the contents of a single file in the body of the request.

## Query parameters

- `channel_id` string
- `filename` string

## Response `201`

Corresponding lists of the provided client_ids and the metadata that has been stored in the database for each one

- object
  - `file_infos` 38cb7293FileInfo[] — A list of file metadata that has been stored in the database
    - `id` string — The unique identifier for this file
    - `user_id` string — The ID of the user that uploaded this file
    - `post_id` string — If this file is attached to a post, the ID of that post
    - `create_at` integer — The time in milliseconds a file was created
    - `update_at` integer — The time in milliseconds a file was last updated
    - `delete_at` integer — The time in milliseconds a file was deleted
    - `name` string — The name of the file
    - `extension` string — The extension at the end of the file name
    - `size` integer — The size of the file in bytes
    - `mime_type` string — The MIME type of the file
    - `width` integer — If this file is an image, the width of the file
    - `height` integer — If this file is an image, the height of the file
    - `has_preview_image` boolean — If this file is an image, whether or not it has a preview-sized version
  - `client_ids` string[] — A list of the client_ids that were provided in the request

## Other responses

- `400` — Invalid or missing parameters in URL or request body
- `401` — No access token provided
- `403` — Do not have appropriate permissions
- `413` — Content too large
- `501` — Feature is disabled

---

[API](https://skmtc.dev/infomaniak/apis/api-reference-developer-tools.md) · [All operations](https://skmtc.dev/infomaniak/apis/api-reference-developer-tools/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/infomaniak/api-reference-developer-tools/revisions/667aae28fec6/schema)
