---
title: "Stage an in-place edit of a live preview (add/replace/remove files)"
method: POST
path: "/previews/{id}/revisions/init"
tags: ["Previews"]
---

# Stage an in-place edit of a live preview (add/replace/remove files)

`POST /previews/{id}/revisions/init`

## Request

- Base URL: `https://api.nippy.host`
- URL: `https://api.nippy.host/previews/{id}/revisions/init`
- Auth: `bearer` (a scheme the document does not define)

## Path parameters

- `id` string, required

## Request body

- InitPreviewRevisionDto
  - `upserts` InitUploadFileDto[]: Files to add or replace. A path that already exists is a replace; a new path is an append.
    - `name` string, required: Filename including extension
    - `size` number, required: File size in bytes
    - `contentType` string, required: MIME type the browser will use when uploading
  - `deletes` string[]: Relative paths to remove from the live preview.

## Response `200`

Revision staged — PUT upserts to the returned URLs

- APIInitPreviewUploadResponse
  - `uploadBatchId` string, required
  - `previewId` string, required
  - `slug` string, required: Server-assigned random preview name
  - `expiresAt` string, date-time, required: Presigned upload URLs stop working at this time
  - `files` APIPresignedFile[], required
    - `name` string, required: Original filename as supplied to /uploads/init
    - `uploadUrl` string, required: Presigned PUT URL — bind exact ContentType + Content-Length
    - `key` string, required: R2 object key the file will land at

## Other responses

- `400`: Validation failed
- `401`: Not authenticated
- `403`: Not the preview owner
- `404`: Preview not found
- `409`: Preview is expired (read-only during grace) or was promoted

---

[API](https://skmtc.dev/nippy/apis/nippy-backend-api.md) · [All operations](https://skmtc.dev/nippy/apis/nippy-backend-api/llms.txt) · [OpenAPI document](https://skmtc.dev/nippy/apis/nippy-backend-api/revisions/7ab23f040a55?raw)
