# Edit a post

Change the caption, the media, and the slides one by one.

A post has three editable surfaces, and they are separate endpoints: the caption, the media list, and the slides.

## The caption

```bash
curl -X PATCH -H "Authorization: Bearer $POSTTAR_KEY" -H "Content-Type: application/json" \
  -d '{"caption":"the new caption"}' \
  "https://api.posttar.com/v1/posts/dd8d142c-..."
```

Limited to 2200 characters, the same ceiling Instagram has.

## The slides

`GET /posts/:id/slides` returns them in order, each with its id, its layout and its text fields. From there:

- `PATCH /slides/:id` changes the text of one slide
- `POST /slides/:id/variant` swaps its layout for another
- `POST /slides/:id/reimagine` regenerates its image
- `POST /posts/:id/slides` adds one at the end
- `DELETE /slides/:id` removes one
- `POST /posts/:id/slides/order` reorders the whole set

> Image changes are metered. `GET /posts/:id/edit-budget` tells you how many you have used and how many are left on that post, as `used`, `cap` and `remaining`.

## Rewrite the first slide and reorder

Read, edit one, then set the order explicitly.

### 1. Read the slides to get their ids and current order.

```bash
curl -H "Authorization: Bearer $POSTTAR_KEY" "https://api.posttar.com/v1/posts/dd8d142c-.../slides"
```

### 2. Change the text of one slide.

```bash
curl -X PATCH -H "Authorization: Bearer $POSTTAR_KEY" -H "Content-Type: application/json" \
  -d '{"fields":{"title":"A sharper hook"}}' \
  "https://api.posttar.com/v1/slides/9f2a1c70-..."
```

### 3. Set the order. Send the complete list of slide ids, in the new order.

```bash
curl -X POST -H "Authorization: Bearer $POSTTAR_KEY" -H "Content-Type: application/json" \
  -d '{"order":["9f2a1c70-...","2b7d4e91-...","c1a8f350-..."]}' \
  "https://api.posttar.com/v1/posts/dd8d142c-.../slides/order"
```

## The media

`POST /posts/:id/media` replaces the post's media list with the one you send, in a `media` field. At most 10 items, which is the Instagram carousel limit, and an empty list removes the media. Use it when you render images yourself and want Posttar to publish those instead of the generated ones.
