# edit

URL: /business/nouns/file/edit · Id: `verb:File.edit` · Call: `await $.File.edit({ … })` (SDK) or the `do` tool at `https://api.sb/mcp`. Inputs says what to pass, Outputs what returns, When it waits who approves.

> Edit makes a new File from an existing one by instruction, such as upscaling or animating a still, and leaves the source unchanged.

Edit makes a new [File](/business/nouns/file) from an existing one by instruction, such as upscaling or animating a still, and leaves the source unchanged.

## Inputs
| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | [File](/business/nouns/file) | Yes | The source File. |
| `instruction` | `text` | Yes | What to change. |
| `references` | list of [File](/business/nouns/file) | No | Further Files the edit follows. |
| `format` | `json` | No | Aspect ratio, resolution, duration and file type of the result. |

## Outputs
| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `file` | [File](/business/nouns/file) | Yes | The new File, which records its source. |

## Effects
- Emits [`File.edited`](/business/events/File.edited).
- Performed by the [Content Lead](/agents/marketing/content-lead).
- Two-way: it runs at once, in the `try`, `send` and `do` modes.
- Runs as a background Action and copies the result into Storage before `done`.
- Never changes the source File.

## Refuses when
| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | [File.edit](/business/nouns/file/edit) |

## When it waits
| Gate | Default |
| --- | --- |
| Decision class | Low: two-way, nothing at stake |
| [Delay window](/systems/trust-and-governance/controls/one-way-windows) | None: it runs once review passes. |
| Limit | The call [Limit](/business/nouns/limit) of the [Permission](/business/nouns/permission) it runs under. |
| Over the Limit | It waits `pending` for an [Approval](/business/nouns/approval) from the [Founder](/agents/founding/founder). Approved, it runs; refused, it ends `refused` with [`limit-exceeded`](/code/api/errors/limit-exceeded); unanswered by its deadline, it ends `canceled`. |

## Example

**Ask**

```text
Edit the latest file.
```

**API**

```bash
curl -X POST https://api.sb/tutorloop.com/files/file_1/edit \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"instruction":"Example instruction"}'
```

```json
{
  "api": "https://api.sb/tutorloop.com",
  "file": {
    "$id": "https://api.sb/tutorloop.com/files/file_1",
    "$type": "File",
    "contentType": "Example content type",
    "size": 1
  },
  "action": {
    "$id": "https://api.sb/tutorloop.com/actions/action_1",
    "operation": "File.edit",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/tutorloop.com/actions/action_1"
  }
}
```

**SDK**

```ts
import { $ } from 'startup-builder'

const file = await $.File.edit({ file: 'file_1', instruction: 'Example instruction' })
```

**CLI**

```bash
npx startup-builder do File.edit --json '{"file":"file_1","instruction":"Example instruction"}'
```

**MCP**

```json
{
  "name": "do",
  "arguments": {
    "code": "return await $.File.edit({ file: 'file_1', instruction: 'Example instruction' })"
  }
}
```