---
title: "Presign a chat attachment upload"
method: POST
path: "/chat/threads/{chatId}/attachments/presign"
tags: ["Chat"]
---

# Presign a chat attachment upload

`POST /chat/threads/{chatId}/attachments/presign`

## Request

- Base URL: `https://viral.app/api/v1`
- URL: `https://viral.app/api/v1/chat/threads/{chatId}/attachments/presign`
- Auth: API key in header `x-api-key`

Step one of sending a file. Creates an attachment slot in the conversation and returns its id with an upload URL valid for 5 minutes: PUT the file's bytes to `signedUrl` with the `Content-Type` you declared as `mimeType`, then pass the id in `attachmentIds` of `POST /chat/threads/{chatId}/messages` (up to 10 per message). Until a message carries it, nobody sees the attachment. Images take up to 25 MB, PDFs up to 25 MB and videos up to 512 MB; at most 30 unsent uploads per conversation and hour. A sent file is served from a permanent public URL, which deleting the message does not revoke.

## Path parameters

- `chatId` string, required

## Request body

- object
  - `fileName` string, required
  - `mimeType` 'image/jpeg' | 'image/png' | 'image/webp' | 'image/gif' | 'video/mp4' | 'video/quicktime' | 'video/webm' | 'application/pdf', required
  - `sizeBytes` integer, required

## Response `200`

OK

- object
  - `attachmentId` string, required
  - `signedUrl` string, uri, required

## Other responses

- `400`: 400
- `401`: 401
- `402`: 402
- `404`: 404
- `408`: 408
- `429`: 429
- `500`: 500

---

[API](https://skmtc.dev/viral/apis/viral-app-api.md) · [All operations](https://skmtc.dev/viral/apis/viral-app-api/llms.txt) · [OpenAPI document](https://skmtc.dev/viral/apis/viral-app-api/revisions/31e97fa79ef1?raw)
