# Upload a file

> Upload one nonempty file with a supported extension: DOCX, MD/Markdown, HTML/HTM, TXT, RTF, ODT, PDF, JPEG/JPG, PNG, WebP, or GIF.

See [files and retention](https://revise.io/developer/docs/revise-api/files) for integration guidance.

## TypeScript

```ts
import { ReviseClient } from "@reviseio/api";

const revise = new ReviseClient({ apiKey: process.env.REVISE_API_KEY! });
const result = await revise.files.upload(
  { filename: "report.md", data: new TextEncoder().encode("# Quarterly report") },
  { idempotencyKey: "upload-42" },
);
```

`POST https://revise.io/api/v1/files`

Upload one nonempty file with a supported extension: DOCX, MD/Markdown, HTML/HTM, TXT, RTF, ODT, PDF, JPEG/JPG, PNG, WebP, or GIF. Text, Markdown, and HTML must be UTF-8. Prompt targets accept only DOCX, Markdown, HTML, and text; other formats must be converted first. There is no public upload-list or original-file-download endpoint.

## Authorization

`Authorization: Bearer <key>` with an API key from https://revise.io/console/api-keys.

## Headers

- `Idempotency-Key` (string, required): min length 1. max length 200

## Body

- `file` (string<binary>, required): One nonempty file, at most 18 MiB. Accounts may retain up to 100 undeleted uploads totaling 256 MiB. Filename: at most 255 bytes, with no path separators or control characters. DOCX/ODT expanded archives are limited to 128 MiB; DOCX archives may contain at most 10,000 entries.
- `lifetime` (string): Ephemeral files can be claimed by one request and are deleted immediately on success. Failed or cancelled requests retain their source for 24 hours; unused uploads expire 24 hours after upload. Persistent templates remain until explicit deletion.. one of "ephemeral", "persistent"

## Responses

### 200 `File`

Idempotent upload replay

- Header `Location`: Account-authenticated path to retrieve this resource.
- Header `Idempotent-Replayed`: Present with value true on an idempotent replay.
- `id` (string, required)
- `filename` (string, required): Empty once expired or deleted.
- `bytes` (integer, required)
- `sha256` (string, required)
- `status` (string, required): one of "uploaded", "expired", "deleted"
- `created_at` (string<date-time>, required)
- `expires_at` (string | null, required)
- `deleted_at` (string | null, required)
- `lifetime` (string, required): one of "ephemeral", "persistent"

### 201 `File`

Uploaded file metadata. Store its ID for job creation or later deletion.

- Header `Location`: Account-authenticated path to retrieve this resource.
- Header `Idempotent-Replayed`: Present with value true on an idempotent replay.
- `id` (string, required)
- `filename` (string, required): Empty once expired or deleted.
- `bytes` (integer, required)
- `sha256` (string, required)
- `status` (string, required): one of "uploaded", "expired", "deleted"
- `created_at` (string<date-time>, required)
- `expires_at` (string | null, required)
- `deleted_at` (string | null, required)
- `lifetime` (string, required): one of "ephemeral", "persistent"

### default `Error`

Error

- `error` (object, required)
  - `code` (string, required)
  - `message` (string, required)
  - `details` (object)
