# Edit a site

`PATCH https://api.vidmoat.com/v1/interactive-sites/{id}`

- Scope: `projects.write`
- Cost: Free

Change the draft with typed ops, all applied or none; or rename the address. There is no custom code: a value outside a list is refused with the list.

### Path parameters

- `id` (string, required): The site id.

### Body

- `ops` (object[], optional): Up to 50 ops: `setTheme`, `setHeader`, `setNav`, `setFooter`, `setSettings`, `addPage`, `updatePage`, `removePage`, `movePage`, `addSection`, `updateSection`, `removeSection`, `moveSection`. See the guide.
- `rev` (integer, optional): The rev you read; a write over a newer draft is refused.
- `prefix` (string, optional): Instead of `ops`: a new address. The old one forwards for 30 days and stays yours until then.

## Response

Returns `200`.

### Response fields

- `site` (object): The site after the change.
- `results` (object[]): With `ops`: one per op, with `sectionId` for a new section.
- `held` (object): With `prefix`: the old prefix and until when it is held.

## Errors

Besides the errors any request can get ([authentication](https://developer.vidmoat.com/developer/docs/authentication#when-a-request-is-refused), [rate limits](https://developer.vidmoat.com/developer/docs/rate-limits)):

| Status | Code | When |
| --- | --- | --- |
| 404 | [`not_found`](https://developer.vidmoat.com/developer/docs/errors#not_found) | No such project, or it is not yours. The two are indistinguishable on purpose. |
| 400 | [`invalid_request`](https://developer.vidmoat.com/developer/docs/errors#invalid_request) | An op was refused (a value outside its list, over a cap, markup, an unsafe link, a video or picture that is not the account's own). The message names the op; nothing was changed. |
| 402 | [`plan_required`](https://developer.vidmoat.com/developer/docs/errors#plan_required) | Interactive sites are not on this plan, or not switched on for this account or the API. |
| 409 | [`conflict`](https://developer.vidmoat.com/developer/docs/errors#conflict) | `rev` is older than the draft, or the new prefix is taken or refused. |

## Request examples

```bash curl
curl -X PATCH https://api.vidmoat.com/v1/interactive-sites/$SITE_ID \
  -H "Authorization: Bearer $VIDMOAT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ops":[{"op":"setTheme","tone":"light","accent":"#B5361C"},{"op":"addSection","page":"","section":{"kind":"grid","heading":"Play them all","videos":["clx9abc123"]}}]}'
```

```js Node
const SITE_ID = 'REPLACE_ME';

const res = await fetch(`https://api.vidmoat.com/v1/interactive-sites/${SITE_ID}`, {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.VIDMOAT_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    ops: [
      {
        op: 'setTheme',
        tone: 'light',
        accent: '#B5361C',
      },
      {
        op: 'addSection',
        page: '',
        section: {
          kind: 'grid',
          heading: 'Play them all',
          videos: [
            'clx9abc123',
          ],
        },
      },
    ],
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? `HTTP ${res.status}`);
console.log(data);
```

```python Python
import os
import requests

SITE_ID = "REPLACE_ME"

res = requests.patch(
    f"https://api.vidmoat.com/v1/interactive-sites/{SITE_ID}",
    headers={"Authorization": f"Bearer {os.environ['VIDMOAT_KEY']}"},
    json={
      "ops": [
        {
          "op": "setTheme",
          "tone": "light",
          "accent": "#B5361C",
        },
        {
          "op": "addSection",
          "page": "",
          "section": {
            "kind": "grid",
            "heading": "Play them all",
            "videos": [
              "clx9abc123",
            ],
          },
        },
      ],
    },
    timeout=60,
)
res.raise_for_status()
print(res.json())
```

## Example response

```json
{
  "site": {
    "id": "clxsite0001",
    "prefix": "river-films",
    "url": "https://river-films.interactive.vidmoat.com",
    "status": "draft",
    "rev": 0,
    "shown": false,
    "previewUrl": "https://river-films.interactive.vidmoat.com/?preview=1763125200000.5f2c",
    "problems": []
  },
  "results": [{ "op": "addSection", "sectionId": "s_k3j9x2qa", "page": "" }]
}
```

---

Source: https://developer.vidmoat.com/developer/docs/api/interactive-sites/edit-interactive-site
Previous: [Get a site](https://developer.vidmoat.com/developer/docs/api/interactive-sites/get-interactive-site.md)
Next: [Publish a site](https://developer.vidmoat.com/developer/docs/api/interactive-sites/publish-interactive-site.md)
All documentation: https://developer.vidmoat.com/llms-full.txt
