> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simplehost.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a Site

> PUT /api/v1/publish/:slug — Publish a new version of an existing site

## Update an Existing Site

Publish a new version of an existing site. Uses hash deduplication — files with matching hashes are copied server-side and don't need to be re-uploaded.

```
PUT /api/v1/publish/:slug
```

### Path Parameters

<ParamField path="slug" type="string" required>
  The site slug to update (e.g., `bright-canvas-a7k2`).
</ParamField>

### Headers

| Header          | Required | Description          |
| --------------- | -------- | -------------------- |
| `Content-Type`  | Yes      | `application/json`   |
| `Authorization` | Yes      | `Bearer sh_live_...` |

### Request Body

Same as [Create a Site](/api-reference/publish). The `files` array contains the complete file manifest for the new version.

<ParamField body="files" type="array" required>
  Complete file manifest for the new version. Include **all** files, not just changed ones.
</ParamField>

### Example

```bash theme={null}
curl -X PUT https://simplehost.dev/api/v1/publish/bright-canvas-a7k2 \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sh_live_your_key_here" \
  -d '{
    "files": [
      {
        "path": "index.html",
        "size": 2048,
        "contentType": "text/html",
        "hash": "newsha256hash64charslong..."
      },
      {
        "path": "style.css",
        "size": 512,
        "contentType": "text/css",
        "hash": "f6e5d4c3b2a1f6e5d4c3b2a1f6e5d4c3b2a1f6e5d4c3b2a1f6e5d4c3b2a1f6e5"
      }
    ]
  }'
```

### Response (200)

```json theme={null}
{
  "slug": "bright-canvas-a7k2",
  "siteUrl": "https://bright-canvas-a7k2.simplehost.dev/",
  "upload": {
    "versionId": "01jm4new789ghi012",
    "uploads": [
      {
        "path": "index.html",
        "method": "PUT",
        "url": "https://simplehost.dev/api/v1/_upload/...",
        "headers": { "Content-Type": "text/html" }
      }
    ],
    "skipped": [
      {
        "path": "style.css",
        "reason": "hash_match"
      }
    ],
    "finalizeUrl": "https://simplehost.dev/api/v1/publish/bright-canvas-a7k2/finalize",
    "expiresInSeconds": 3600
  }
}
```

### How Deduplication Works

1. Include the `hash` field (SHA-256) for each file in the manifest
2. The API compares each hash against the previous version's files
3. Files with matching hashes appear in the `skipped` array — they are copied server-side
4. Only files in the `uploads` array need to be uploaded

<Tip>
  Always include hashes when updating. Without hashes, every file is treated as new and must be re-uploaded.
</Tip>

After uploading the non-skipped files, call [Finalize](/api-reference/finalize) with the new `versionId`.
