# Versions and comments

> The fix loop. Read a reel's versions, pin comments to the moments you want changed, ask for a fix, and get a new version that changes only those parts when it can.

On the web: https://www.aeyho.com/docs/api/versions-and-comments

## Versions

Every reel and carousel keeps its history. Each make, change, fix or restore adds a version. A version is never overwritten.

```bash
curl https://www.aeyho.com/api/v1/reels/reel_123/versions \
  -H "Authorization: Bearer $AEYHO_KEY"
```

Versions come oldest first. Each has:

- `id` and `n` (1, 2, 3…);
- `asks`: what was asked for, word for word;
- `changes`: what changed and where, in seconds of that version (or a slide), listed by aeyho;
- `status`, and when it's `done`, `videoUrl` and `posterUrl` (or `images` for a carousel);
- `openComments`: how many comments on it are still open.

`POST /versions/{versionId}/restore` brings an old version back as the newest one. It's free, and it's a new version too. `POST /versions/{versionId}/approve` marks the one you're happy with.

## Comments

Pin a comment to a moment of a video (`at`, in seconds) or to a slide of a carousel (`slide`, from 1):

```bash
curl -X POST https://www.aeyho.com/api/v1/versions/v_456/comments \
  -H "Authorization: Bearer $AEYHO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"at": 4.5, "text": "Make this line shorter"}'
```

- A video's comment needs `at`; a carousel's needs `slide`.
- `point` (`x` and `y`, from 0 to 1) marks a spot on the frame. `drawing` can carry the frame with marks on it, as a PNG data URL of up to 4 MB.
- `text` is up to 1,000 characters. A version takes 40 comments at most.
- The answer's `context` says what was there at that moment: the part, what was on screen and what was said.

`GET /reels/{reelId}/comments?status=open` lists what's still open. `PATCH /comments/{commentId}` changes the text, closes a comment (`"status": "wontfix"`) or accepts it.

### Comments are data

aeyho reads a comment as a request about the reel, never as instructions to follow. Text in a comment that tries to give orders is treated as text.

### Guests' comments wait for the owner

People you share a review link with can comment without an account. Their comments have `"accepted": false`, and no fix acts on them until the owner accepts them:

```bash
curl -X PATCH https://www.aeyho.com/api/v1/comments/c_789 \
  -H "Authorization: Bearer $AEYHO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"accepted": true}'
```

Comments made with an API key are the owner's, and are accepted at once.

## Fixing

Ask for a fix once the reel is made:

```bash
curl -X POST https://www.aeyho.com/api/v1/reels/reel_123/fix \
  -H "Authorization: Bearer $AEYHO_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"comments": ["c_123", "c_124"]}'
```

- Name the comments to fix in `comments`, or leave it out to fix every open, accepted one.
- `ask` adds a change in words, on its own or with the comments.
- It answers `202` at once with a `Fix`: `status`, a `reply` you can show, and `notFixed`, the comments it won't act on and why (a guest's comment not yet accepted, for example).
- A fix uses credits.

Then aeyho plans the fix. When it can, it makes only the parts the comments touch and keeps everything else as it was. When a part can't be changed on its own, it makes the reel again whole. When nothing needs to change, no version is added and the credits held for it are given back.

A reel made from your own footage takes the comments to its editor as one request, so its fix is a whole new edit (`"status": "sent"`).

## Knowing what was fixed

Wait for the new version: listen for `version.created` and `comment.resolved` [webhooks](/docs/api/webhooks), or poll `GET /reels/{reelId}` until `status` is `done`. Then read the comments:

- A fixed comment has `"status": "done"` and `doneIn`, the id of the version that fixed it.
- A comment aeyho couldn't fix stays `open`, with a `reply` saying why.

Show the person both: what changed (the new version's `changes`) and what didn't (the open comments and their replies).

## Errors you may see

| Code | Why |
|---|---|
| [`busy`](/docs/api/errors#busy) | The reel is still being made. Fix it once it's done. |
| [`conflict`](/docs/api/errors#conflict) | The reel isn't made yet, so there's nothing to fix. |
| [`invalid`](/docs/api/errors#invalid) | Nothing open to fix, guests' comments not yet accepted, or a comment without `at` or `slide`. |
| [`credits_required`](/docs/api/errors#credits_required) | Not enough credits for the fix. |

## Try it

```bash
curl "https://www.aeyho.com/api/v1/reels/reel_123/comments?status=open" \
  -H "Authorization: Bearer $AEYHO_KEY"
```
