---
title: "Prepare a file upload (step 1 of 3)"
method: POST
path: "/v1/direct_uploads"
tags: ["Files"]
---

# Prepare a file upload (step 1 of 3)

`POST /v1/direct_uploads`

## Request

- Base URL: `https://api.revdoku.com`
- URL: `https://api.revdoku.com/v1/direct_uploads`
- Auth: HTTP bearer

Returns a storage URL. Then PUT the bytes to direct_upload.url with exactly direct_upload.headers and no API key (step 2), and save the file with POST /v1/mailboxes/{mailbox_id}/files (step 3). Identical content at the same path returns skipped=true and duplicate=true without an upload.

## Request body

- PrepareFileUploadRequest
  - `mailbox_id` string, required
  - `path` string, required: Destination path in the mailbox. Paths under _email/ return EMAIL_PATH_READ_ONLY.
  - `existing_file_policy` 'replace' | 'skip': skip returns the existing file without an upload when the path exists.
  - `blob` UploadBlob, required
    - `filename` string, required
    - `byte_size` integer, required
    - `checksum` string, required
    - `content_type` string, required
    - `sha256` string, required
    - `purpose` 'mailbox_file', required
  - `account_id` string
  - `reason` string, nullable: Optional purpose for this action. AI agents should explain intentional reads and changes when known; omit when unknown. Do not include secrets, file contents, or transcripts.

## Response `200`

Identical content; nothing to upload

- object
  - `success` true, required
  - `data` PreparedFileUpload, required: A new upload returns signed_id and direct_upload. Identical content returns skipped=true, duplicate=true, file and version without a storage upload.
    - `signed_id` string
    - `filename` string
    - `byte_size` integer
    - `checksum` string
    - `content_type` string
    - `direct_upload` StorageUpload
      - `url` string, uri, required
      - `headers` object, required
    - `file` MailboxFile
      - `id` string, required
      - `mailbox_id` string
      - `basename` string
      - `path` string, required
      - `role` string
      - `created_by_system` string
      - `deleted` boolean
      - `version_reasons` FileVersionReason[]
        - `version_id` string
        - `reason` string
        - `created_by_id` string
        - `version_number` integer
        - `created_at` string, date-time
      - `lock` object
      - `current_file_version` FileVersion
        - `id` string, required
        - `file_id` string, required
        - `name` string
        - `mime_type` string
        - `sha256` string
        - `reason` string, nullable
        - `created_by_system` string
        - `deleted` boolean: True for the version that records a deletion.
        - `ready` boolean
        - `has_text` boolean
        - `version_number` integer, required
        - `byte_size` integer
        - `created_at` string, date-time
        - `created_by` FileActor
          - `id` string
          - `name` string
          - `email` string
        - `updated_by` FileActor
          - `id` string
          - `name` string
          - `email` string
        - `created_by_agent` object
        - `updated_by_agent` object
        - `created_by_api_key` object
        - `updated_by_api_key` object
        - `read` boolean
        - `read_at` string, date-time, nullable
        - `read_by` FileActor
          - `id` string
          - `name` string
          - `email` string
        - `read_by_api_key` FileKey
          - `id` string
          - `label` string
          - `token_type` string
      - `created_by` FileActor
        - `id` string
        - `name` string
        - `email` string
      - `created_at` string, date-time
      - `updated_at` string, date-time
      - `deleted_at` string, date-time
      - `created_by_agent` object
      - `updated_by_agent` object
      - `created_by_api_key` object
      - `updated_by_api_key` object
      - `read` boolean
      - `read_at` string, date-time, nullable
      - `read_by` FileActor
        - `id` string
        - `name` string
        - `email` string
      - `read_by_api_key` FileKey
        - `id` string
        - `label` string
        - `token_type` string
    - `version` FileVersion
      - `id` string, required
      - `file_id` string, required
      - `name` string
      - `mime_type` string
      - `sha256` string
      - `reason` string, nullable
      - `created_by_system` string
      - `deleted` boolean: True for the version that records a deletion.
      - `ready` boolean
      - `has_text` boolean
      - `version_number` integer, required
      - `byte_size` integer
      - `created_at` string, date-time
      - `created_by` FileActor
        - `id` string
        - `name` string
        - `email` string
      - `updated_by` FileActor
        - `id` string
        - `name` string
        - `email` string
      - `created_by_agent` object
      - `updated_by_agent` object
      - `created_by_api_key` object
      - `updated_by_api_key` object
      - `read` boolean
      - `read_at` string, date-time, nullable
      - `read_by` FileActor
        - `id` string
        - `name` string
        - `email` string
      - `read_by_api_key` FileKey
        - `id` string
        - `label` string
        - `token_type` string
    - `skipped` boolean
    - `duplicate` boolean
    - `reason` string
    - `details` object

## Other responses

- `201`: Created
- `default`: Request failed. See error.code. Any 429 or 503 response with Retry-After (for example 503 EMAIL_LABELING_PENDING or 503 EMAIL_INDEX_BUILDING): wait that many seconds, then try the read again. 429 EMAIL_SEND_RATE_LIMITED has no Retry-After. Never retry EMAIL_LOOP_DETECTED.

---

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