# Contentful, Sanity, JSON feeds and Braze catalogs

> Keep message copy in your CMS. Herald syncs it into your library, so agents test and pick from the copy your team already writes.

:::note Built and tested against each vendor's documented API, and checked against live Contentful and JSON feed data; tell us if anything differs in your account.:::

## What you'll need

- **Contentful:** the space ID, the environment (default `master`), the content type that holds your messages, and a **Content Delivery API** token for that space (Settings → API keys).
- **Sanity:** the project ID, the dataset (default `production`), and a GROQ query that returns your messages. A read token only if the dataset is private (Settings → API → Tokens, Viewer).
- **JSON feed:** a public `https` URL that returns your messages as JSON, and a bearer token if the feed needs one.
- **Braze catalog:** a Braze connection in **Settings → Sending & SDK**, and the catalog's name.

## What it does

Data in. Each item becomes a message variant in your Herald library, under one library message per source and channel (for example "[contentful] push library"). Agents can then use those variants like copy written in Herald. Edits in your CMS update the variant on the next sync, and an item removed from the source is archived. Contentful locales come in as translations.

## Supported data

| Data | Direction | Mode | Notes |
|---|---|---|---|
| Message copy (title, subject, body, CTA, deep link, image, HTML body, tags) | In | Daily, or **Sync now** | One variant per item |
| Translations | In | With each sync | Contentful locales |

## Connect

1. In **Settings → Content sources**, turn on the source.
2. Fill in its fields and paste the token in the token field. The token is saved encrypted when you press **Save**, and never shown again.
3. Press **Test connection**. You see up to three mapped items from the source.
4. Press **Sync now**. The run appears in the sync history with how many items were created, updated, archived or skipped.

## How matching works

Each item is matched to its variant by its id in the source (`sys.id` in Contentful, `_id` in Sanity, `id` in a JSON feed, the item id in a Braze catalog). An item without a body is skipped and listed in the run's errors.

## Configure

Field mapping says where each part of the message lives in your items. The defaults:

| Field | Contentful | Sanity | JSON feed |
|---|---|---|---|
| Id | `sys.id` | `_id` | `id` |
| Title | `fields.title` | `title` | `title` |
| Body | `fields.body` | `body` | `body` |
| Tags | `metadata.tags[*].sys.id` | `tags` | `tags` |

Paths use dots, `[0]` for an index and `[*]` for every item in a list. A JSON feed can page by a cursor in the response (`nextPath` and the query `param` that carries it) or by page number (`param` and `pageSize`).

## Limits

- 100 items per page and 500 pages per sync, so up to 50,000 items per source.
- Each request times out after 10 seconds, and redirects aren't followed.
- A JSON feed's host must be public: private and local addresses are refused.
- An item is archived only after a complete listing, so a failed sync never archives anything.

## Validate your setup

**Test connection** shows up to three items as Herald will store them: the id, title, body and any translations. If the body is empty, fix the mapping before you sync.

## Troubleshooting

Each sync is listed under the source with its status and first error.

### Common errors

| Error | What to do |
|---|---|
| Add a Contentful Content Delivery API token | Paste the space's delivery token and press **Save**. |
| Content URL must be public https | Use an `https` URL on a public host. |
| invalid or missing body | Point the body mapping at the field that holds your message text. |
| Choose the Braze connection to read the catalog from | Pick the Braze connection, then save. |
| The saved token can't be read; save it again | Paste the token again and press **Save**. |
