# Add an Edit button to your website

Let your visitors edit a photo, video, document, spreadsheet, presentation,
PDF, drawing or recording without leaving your site and without a Culacc
account. They press **Edit**, a Culacc window opens over your page, they pick
an app, and the result is saved in your Culacc storage and sent back to your
page and your server.

## The apps your visitors can use

| App | For | Opens |
|---|---|---|
| Image editor | quick crops, rotate, brightness | JPG, PNG, WebP, GIF, AVIF |
| PhotoCraft | layers, masks, brushes (Photoshop-style) | PNG, JPG, WebP |
| LightCraft | light and colour (Lightroom-style) | JPG, PNG, TIFF, WebP |
| VectorCraft | vector drawings | SVG, PDF |
| PdfCraft | combine, fill in, sign, comment | PDF |
| WordCraft | documents | DOCX, DOC, ODT, RTF |
| GridCraft | spreadsheets | XLSX, XLS, ODS, CSV |
| DeckCraft | presentations | PPTX |
| CADCraft | CAD drawings | DXF, DWG |
| DesignCraft | page layout (InDesign-style) | IDML, INDD |
| SoundCraft | audio: cut, fade, many tracks | WAV, MP3, FLAC, OGG, M4A |
| Video trimmer | trim and crop video | MP4, MOV, WebM |
| Google Docs, Sheets & Slides | in the visitor's own Google account | Office files |

The Crafting apps (PhotoCraft to SoundCraft) run in the visitor's browser. You
choose which apps appear.

## 1. Set it up in Culacc

**Settings → Developers → Edit with Culacc**: add your site under **Allowed
sites** (`http://localhost` works while you build), switch on the apps you
want, and choose what happens on save: replace the file, keep the original,
or keep every version. Make a key with **files:write**.

## 2. Your server starts a session

```js
const { Culacc } = require('@culacc/sdk');
const culacc = new Culacc({ key: process.env.CULACC_KEY });

app.post('/api/culacc-session', requireLogin, async (req, res) => {
  const { editorUrl } = await culacc.edit.createSession({
    origin: 'https://your-site.com',
    fileId: req.body.fileId,            // leave out to let the visitor add a new file
    apps: ['photocraft', 'image-editor'],
    externalRef: String(req.user.id),
  });
  res.json({ editorUrl });              // the page never sees your key
});
```

## 3. Your page opens it

```html
<script src="https://culacc.com/api/edit/sdk.js"></script>
<button id="edit">Edit</button>
<script>
  CulaccEditor.attach('#edit', {
    session: () => fetch('/api/culacc-session', {
      method: 'POST', headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ fileId: 4821 }),
    }).then((r) => r.json()),
    onSave: (result) => { preview.src = result.url + '?v=' + result.revision; },
  });
</script>
```

It opens as a window over the page (full screen on phones), a popup, or a
full-page redirect. The result has the file's id, name, size and published
address.

## 4. Your server hears about every save

Subscribe to the `file.edited` webhook: it arrives even if the visitor closes
the tab, with the `externalRef` you passed.

## Costs

You pay for what your visitors use; they pay nothing. Storage at your usual
price, traffic 10 GB a month free then €1 per TB, editing time 60 CPU minutes a
month free then €0.20 per CPU hour, all under one monthly spending limit you
set.

## Reference

- [Edit with Culacc](/developers#edit-with-culacc) in the API reference
- [Upload files of any size](/developers/upload-files/)
