# The Post schema

> The shape of a saved post as data: the Post, its media, article blocks, video, title, repository and playlist parts, the bundle manifest and the capture request.

Source: https://crawl-docs.pdhq.win/advanced/post-schema/
Last updated: 2026-12-02

Every saved post is described by one `zod` schema in `packages/schema/src/index.ts`. The extension builds it, the API validates and stores it as `post.json`, and the renderer draws it. If you write your own reader or importer, this is the contract.

```ts
import { postSchema, captureRequestSchema, bundleManifestSchema } from "@social-crawl/schema";
```

## Post

| Field | Type | Notes |
| --- | --- | --- |
| `id` | string | The platform's own id. Unique together with `platform`. |
| `platform` | enum | `bluesky`, `mastodon`, `reddit`, `youtube`, `facebook`, `instagram`, `x`, `pinterest`, `linkedin`, `web` (any other site, saved as an article). |
| `url` | URL | The post's address. |
| `source` | enum | `api`, `extension` or `oembed`: how it reached the service. |
| `author` | Author | See below. |
| `text` | string | Plain text. For an article it is the plain-text version of the body. |
| `title` | string, optional | |
| `article` | Article, optional | The long body as blocks. |
| `video` | VideoInfo, optional | What a video page shows around the video (YouTube). |
| `createdAt` | ISO date, optional | When it was posted. |
| `capturedAt` | ISO date | When it was saved. |
| `media` | Media[] | Pictures, videos, sound and files. Default empty. |
| `metrics` | `{ likes, comments, shares, views }`, each optional | Default empty. |
| `titleInfo` | TitleInfo, optional | A film or show's page. |
| `quoted` | QuotedPost, optional | A post shown inside this one (X's quoted post). |
| `repo` | RepoInfo, optional | A code repository's page. |
| `playlist` | PlaylistInfo, optional | A YouTube playlist's page. |
| `linkPreviews` | LinkPreview[] (at most 8) | Cards for the links in the text. |
| `extra` | record | Platform-specific extras. Never rendered raw. |

### Author

`displayName` (required), `id`, `handle`, `url`, `avatar` (a Media) and `verified`.

### Media

| Field | Notes |
| --- | --- |
| `id` | Required. Blocks and previews refer to it. |
| `kind` | `image`, `video`, `gif`, `audio` or `file` (anything else a page offers for download, kept as it is and never opened by the app). |
| `remoteUrl`, `status` | The original address, and `local` (stored in the bundle) or `remote-only` (only the address is known). |
| `localPath`, `mimeType`, `size`, `fileName` | Where it is stored in the bundle, its type, its real size, and for a file the name to show. |
| `alt`, `width`, `height` | Text and size. |
| `posterUrl`, `posterPath` | A picture to download as the thumbnail, and where it is stored. |
| `audioUrl`, `partUrls` | For videos the page streams as separate sound, or as numbered pieces with no playlist. The server joins them. |
| `label`, `audioFormat` | The name the extension's list showed; for sound, `original`, `mp3` or `flac`. |
| `uploadId`, `audioUploadId` | A video the extension downloaded itself and uploaded in pieces (`POST /capture/uploads`). |
| `expectedBytes`, `seconds` | The size a video saved without its file had, and a saved video's length. |
| `renditions` (up to 8) | Smaller copies of a saved video: `height`, `width`, `path`, `size`. |
| `captions` (up to 20) | Subtitle files: `path` (WebVTT), `language`, `name`. |
| `transcript` | `{ path, language, lines }`: what speech recognition found, as its own file. |

### Article

`blocks` (at most 5000), `siteName`, `siteLogo` (a media id), `excerpt` and `readingMinutes`. A block is one of:

| `type` | Fields |
| --- | --- |
| `heading` | `level` 1 to 6, `inlines` |
| `paragraph`, `quote` | `inlines` |
| `list` | `ordered`, `items` (each a list of inlines) |
| `code` | `text`, `language` |
| `image` | `mediaId`, `caption`, `href` (an `http(s)` link the picture leads to) |
| `video`, `file` | `mediaId`, `caption` |
| `table` | `header`, `rows` of cells of inlines (at most 500 rows, 40 cells) |
| `rule` | none |

An **inline** is `text` plus optional `bold`, `italic`, `code`, `href` (web, ftp, sftp, magnet, mailto or tel, never `javascript:` or `data:`) and `image` (a small picture in the line, such as a README badge). An article is plain data and never HTML.

### VideoInfo

`seconds`, `subscribers`, `dateText`, `viewsText`, `likesText`, `category`, `description` (runs of text, links and times you can click), `hashtags`, `keywords`, `chapters` (`seconds`, `title`, thumbnail), `transcript` (lines with `start` and `text`), `transcriptLanguage`, `captions` (each `language`, `name`, `kind` of `manual`, `auto` or `translated`, and `vtt` text that the server stores as a file), `commentsText` and up to 100 `comments`.

### LinkPreview

`url` (as it appears in the text), `finalUrl`, `kind` (`page` or `image`), `title`, `description`, `siteName`, `imageUrl`, `imagePath`. Made by the server when the post is saved.

### TitleInfo, RepoInfo, PlaylistInfo, QuotedPost

- **TitleInfo**: `kind` (`movie`, `series`, `episode`, `other`), `name`, `year`, `plot`, `genres`, `contentRating`, `runtime`, `released`, `scores`, `trailer`, `people` (name, role, character, photo), `details` (label and value), `sections` (strips such as seasons and more like this) and `textSections` (storyline, trivia, reviews).
- **RepoInfo**: `host`, `owner`, `name`, `description`, `homepage`, `topics`, `stars`, `forks`, `watchers`, `license`, `defaultBranch`, `clone` (https, ssh, cli), `zipMediaId`, `languages` (name, percent, colour), `releases`, `contributors`, `createdAt`, `pushedAt`.
- **PlaylistInfo**: `listId`, `total`, `description`, `viewsText`, `updatedText`, `videos` (at most 300: id, url, title, channel, views, age, duration, thumbnail, `unavailable`) and `truncated`. The videos are not downloaded.
- **QuotedPost**: `url`, `authorName`, `handle`, `avatarUrl`, `text`, `imageUrl`, `video`, `createdAt`. Only a preview that links to the post.

## BundleManifest (`post.json`)

```json
{
  "version": 1,
  "post": { "...": "a Post" },
  "files": [{ "path": "images/0.jpg", "bytes": 12345, "sha256": "…64 hex digits…" }],
  "createdAt": "2026-12-02T10:00:00.000Z"
}
```

`version` is `BUNDLE_VERSION` (1). Every file has a SHA-256, so a bundle can be verified without the server.

## CaptureRequest

What the extension sends to `POST /capture`:

```json
{
  "post": { "...": "a Post without capturedAt and source" },
  "tags": ["travel", "recipes"]
}
```

`tags` (at most 100 entries) are added to the tags the post already has. They are checked with the rules in [Tags](https://crawl-docs.pdhq.win/guide/tags.md).

## Using the schema

- Parse before you trust: `postSchema.parse(data)` throws with the exact path of a wrong field.
- Add a new kind of data by extending the schema first (with limits on every string and array), then the reader, then the renderer. The tests in `packages/schema/src/index.test.ts` show the style.
