# REST API

> The Webstory REST API, for scripts and apps that don't use MCP: base address, sign-in, lists, errors and every endpoint.

The REST API does the same things as the [agent tools](/agents/tools), with the same permissions and the same [limits](/agents/limits). Use it from scripts and apps that don't speak MCP.

## Base address

```text
https://webstoryapp.com/api/v1/agent
```

## Sign in

Get a token with OAuth, exactly as for an agent, with `https://webstoryapp.com/api/v1/agent` as the `resource`. See [Authentication](/agents/authentication). Send it on every request:

```http
Authorization: Bearer <access token>
```

## Conventions

- JSON in and out, with `snake_case` field names.
- Path parts such as `{story_id}` are arguments. Other arguments go in the query string (GET) or a JSON body (POST, PUT).
- Lists take `limit` (1 to 50, default 20) and `cursor`, and answer `next_cursor`, which is null on the last page.
- Errors come back as `{ "error": "…", "code": "…" }` with an HTTP status. See [Errors](/agents/errors).
- Requests that change something take an `Idempotency-Key` header. Send the same value when you retry, so the change isn't made twice.
- Times are ISO 8601 in UTC. Lengths are in seconds.

## Endpoints

| Method | Path | Tool | Scope |
| --- | --- | --- | --- |
| `GET` | `/api/v1/agent/workspace` | [`get_workspace`](/agents/tools/get_workspace) | Any |
| `GET` | `/api/v1/agent/stories` | [`list_stories`](/agents/tools/list_stories) | `stories:read` |
| `GET` | `/api/v1/agent/stories/{story_id}` | [`get_story`](/agents/tools/get_story) | `stories:read` |
| `GET` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}` | [`get_reel`](/agents/tools/get_reel) | `stories:read` |
| `GET` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}/share` | [`get_reel_share`](/agents/tools/get_reel_share) | `stories:read` |
| `POST` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}/share-links` | [`create_share_link`](/agents/tools/create_share_link) | `stories:share` |
| `GET` | `/api/v1/agent/stories/{story_id}/stats` | [`get_story_stats`](/agents/tools/get_story_stats) | `insights:read` |
| `GET` | `/api/v1/agent/comments` | [`list_comments`](/agents/tools/list_comments) | `comments:read` |
| `GET` | `/api/v1/agent/chats` | [`list_chats`](/agents/tools/list_chats) | `chats:read` |
| `GET` | `/api/v1/agent/chats/{chat_id}` | [`get_chat`](/agents/tools/get_chat) | `chats:read` |
| `GET` | `/api/v1/agent/orders` | [`list_orders`](/agents/tools/list_orders) | `orders:read` |
| `GET` | `/api/v1/agent/orders/{order_id}` | [`get_order`](/agents/tools/get_order) | `orders:read` |
| `PUT` | `/api/v1/agent/notification-endpoint` | [`set_notification_endpoint`](/agents/tools/set_notification_endpoint) | `notifications` |
| `GET` | `/api/v1/agent/brands` | [`list_brands`](/agents/tools/list_brands) | `stories:read` |
| `POST` | `/api/v1/agent/stories` | [`create_story`](/agents/tools/create_story) | `stories:edit` |
| `PATCH` | `/api/v1/agent/stories/{story_id}` | [`update_story`](/agents/tools/update_story) | `stories:edit` |
| `POST` | `/api/v1/agent/stories/{story_id}/reels` | [`add_reels`](/agents/tools/add_reels) | `stories:edit` |
| `PATCH` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}` | [`update_reel`](/agents/tools/update_reel) | `stories:edit` |
| `POST` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}/move` | [`move_reel`](/agents/tools/move_reel) | `stories:edit` |
| `POST` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}/duplicate` | [`duplicate_reel`](/agents/tools/duplicate_reel) | `stories:edit` |
| `DELETE` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}` | [`remove_reel`](/agents/tools/remove_reel) | `stories:edit` |
| `POST` | `/api/v1/agent/stories/{story_id}/replace-text` | [`replace_text`](/agents/tools/replace_text) | `stories:edit` |
| `GET` | `/api/v1/agent/stories/{story_id}/preview` | [`create_preview`](/agents/tools/create_preview) | `stories:read` |
| `GET` | `/api/v1/agent/media` | [`list_media`](/agents/tools/list_media) | `media:read` |
| `POST` | `/api/v1/agent/media/imports` | [`import_media`](/agents/tools/import_media) | `media:upload` |
| `POST` | `/api/v1/agent/media/files` | [`upload_file`](/agents/tools/upload_file) | `media:upload` |
| `POST` | `/api/v1/agent/media/uploads` | [`create_upload`](/agents/tools/create_upload) | `media:upload` |
| `POST` | `/api/v1/agent/media/upload-pages` | [`create_upload_page`](/agents/tools/create_upload_page) | `media:upload` |
| `GET` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}/elements` | [`list_reel_elements`](/agents/tools/list_reel_elements) | `stories:read` |
| `PUT` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}/buttons` | [`set_button`](/agents/tools/set_button) | `stories:edit` |
| `DELETE` | `/api/v1/agent/stories/{story_id}/reels/{reel_id}/buttons/{button_id}` | [`remove_button`](/agents/tools/remove_button) | `stories:edit` |
| `PUT` | `/api/v1/agent/stories/{story_id}/side-buttons` | [`set_side_button`](/agents/tools/set_side_button) | `stories:edit` |
| `GET` | `/api/v1/agent/changes` | [`list_changes`](/agents/tools/list_changes) | `stories:read` |
| `POST` | `/api/v1/agent/changes/{change_id}/undo` | [`undo_change`](/agents/tools/undo_change) | `stories:edit` |

## OpenAPI

The OpenAPI description of the REST API is at [/openapi.json](/openapi.json), generated from the same definitions as the server. Webstory also serves it at `https://webstoryapp.com/api/v1/openapi.json`.

Source: https://docs.webstoryapp.com/api
