# boomcast.ai site webhook

Point an IDE at this file, or at `https://boomcast.ai/openapi.json`. The site implements one HTTPS POST endpoint. boomcast.ai calls that endpoint. The path is whatever URL is saved on the project.

The shared secret is shown once in boomcast.ai when the connection is saved or reset. Store it on the site. Do not log it.

## Verify the request

Headers:

- `Content-Type: application/json`
- `X-BoomCast-Timestamp`: ISO-8601 time, identical to `timestamp` in the body
- `X-BoomCast-Signature`: lowercase hex HMAC-SHA256
- `X-Signature`: the same hex value
- `X-Idempotency-Key`: the pending update id, or `{pendingUpdateId}:read` for a read

The signature is `HMAC-SHA256(secret, timestamp + "." + canonicalJson)`. `canonicalJson` is the parsed body with the `signature` field removed:

- Objects use sorted keys. Skip a key whose value is missing.
- Arrays keep their order.
- Strings, numbers, booleans, and null use JSON encoding. Do not escape slashes or non-ASCII characters.
- There is no whitespace.

Reject the request when the timestamp is missing, not a date, or more than 5 minutes from the current time. Compare the hex with a constant-time comparison.

## Request body

```json
{
  "action": "update_text",
  "target_type": "custom_field",
  "target_id": "page:home:heading",
  "field": "heading",
  "value": "Lunch until 3",
  "image_url": null,
  "timestamp": "2026-11-30T18:00:00.000Z",
  "pending_update_id": "8d0c1c3a-1d5e-4c2a-9c1a-0b6e2f4a7d11",
  "phone_e164": "+14055550100",
  "permissions_version": 3,
  "signature": "hex-hmac"
}
```

`action` is one of `update_price`, `update_text`, `replace_image`, `update_hours`, or `update_metafield`.

`target_type` is `custom_field`, `gutenberg`, `elementor`, `woocommerce`, `acf`, `post_meta`, or `option`.

`value` is the new content. It can also be an operation:

- `{ "op": "catalog" }` asks for the editable targets. Do not change the site.
- `{ "op": "read" }` asks for the current value of `target_id`. Do not change the site.
- `{ "op": "add" }` or `{ "op": "delete" }` changes a list target such as a team member, gallery photo, menu item, or paragraph.
- `"ping"`, or `pending_update_id` equal to `"test"`, is a connection test. Do not change the site.

A price is a decimal string such as `"4.50"`. A photo change includes `image_url`.

## Hours

A text can say hours in free form, such as `Mon - Fri 11am - 9:30pm`. boomcast.ai turns that into one open time and one close time. Day words choose the target, such as `hours:monsat` or `hours:sun`. They are not written into the stored value.

The catalog target chooses how that range is written. Set these fields on an `update_hours` target:

```json
{
  "id": "hours:monsat",
  "type": "custom_field",
  "name": "Monday–Saturday hours",
  "field": "hours",
  "action": "update_hours",
  "hoursFormat": "ampm",
  "hoursExample": "11:00 AM – 9:00 PM",
  "hoursPattern": "^\\d{1,2}:00 (AM|PM) – \\d{1,2}:00 (AM|PM)$"
}
```

`hoursFormat` is one of:

- `ampm` writes `11:00 AM – 9:30 PM`
- `ampm_on_the_hour` uses that same shape and refuses a time that is not `:00`
- `compact` writes `11am – 9:30pm`
- `twenty_four` writes `11:00-21:30`
- `structured` writes `{ "open": "11:00", "close": "21:30" }`

`hoursPattern` is an optional regular expression. boomcast.ai checks the formatted value before the update and does not post a value the pattern rejects. `hoursExample` is the sample sent back to the texter when the pattern does not match.

When `hoursFormat` is omitted, boomcast.ai copies the shape of the current value returned by `{ "op": "read" }`. A current value of `11:00 AM – 9:00 PM` makes `11am - 9:30pm` go out as `11:00 AM – 9:30 PM`.

A saved permission id is sent only when that id is in the catalog. Otherwise boomcast.ai picks the catalog row the text names. `menu_item` and `menu_price` use a `menu:item:…` id. Replacing a named photo uses that photo's `image:…` id. Adding a photo uses the gallery list id, with `value` `{ "op": "add", "url": "<image_url>" }` and `image_url` set. `hours` uses `hours:…`. Event, special, announcement, contact, promotion, service, team, holiday, and FAQ permissions are posted only when the catalog has that id or tag. A text that matches more than one row is not posted. A file path is not repeated back to the texter.

## Choosing which elements the catalog returns

boomcast.ai does not crawl the page. The catalog response is the list of elements a text can change. The site chooses that list. Return it on every `{ "op": "catalog" }` request. A newly chosen element is available on the next read. The webhook URL and the shared secret stay the same.

Give every target a stable `id`, a human `name`, a `field`, a `tag`, an `action`, and a `preview` of the current value. `name` is what a person would say. `preview` may be the current text or file path. Never put a file path or URL in `name`.

### The site has an admin panel

Add a selector to that admin panel. The person who runs the site checks the elements to expose. Persist each choice with its stable id. When boomcast.ai asks for the catalog, return only the checked elements.

Pre-fill the selector with the best-guess list below so the admin corrects a guess instead of starting from a blank page. Show the human name, the id, and the kind (gallery, menu item, hours, contact). Saving the selector does not call boomcast.ai. The next catalog request picks up the change.

If the site has an admin panel, build this selector. Do not hard-code the catalog when an admin could choose.

### The site has no admin panel

Guess from element ids, classes, headings, and repeated structure. Use the first confident match. Expose the content a customer would ask to change. Skip navigation, footer chrome, scripts, logos, favicons, social icons, and decorative backgrounds.

| What you find in the markup | Catalog target |
| --- | --- |
| `gallery`, `carousel`, `slider`, `lightbox`, or a photo grid. Classes and ids such as `gallery`, `carousel`, `slider`, `slides`. | One list: `id` `gallery`, `field` `gallery`, `tag` `gallery`, `action` `replace_image`, `name` `Gallery`. An added photo is `{ "op": "add", "url" }` on this id. |
| One named photo that is not inside the gallery, such as a storefront, hero, or about image. | `id` `image:{slug}`, `field` `image`, `tag` `image`, `action` `replace_image`, `name` a label such as `Storefront photo`. |
| A food or drink menu: repeated dishes with a name and a price. A nav link named Menu is not a menu. | For each dish, three rows sharing one stem. `menu:item:{section}:{index}:name` (`field` `name`, `tag` `menu_item`, `action` `update_text`). `:desc` for the description. `:price` (`field` `price`, `tag` `menu_price`, `action` `update_price`). `name` on each row is the dish name. `preview` is the current name, description, or price. |
| Open and close times. | `hours:monsat` and `hours:sun`, `field` `hours`, `tag` `hours`, `action` `update_hours`, plus `hoursFormat`. |
| Phone, email, or street address. | `contact:…`, `tag` `contact`, `action` `update_text`. |
| Staff names, roles, or bios. | `team`, or `team:…` for one person. `tag` `team`. |
| Events and dates. | `event`, `tag` `event`. |
| Daily or weekly specials. | `special`, `tag` `special`. |
| A banner or homepage note. | `announcement`, `tag` `announcement`. |
| Questions and answers. | `faq`, `tag` `faq`. |
| Coupons and offers. | `promotion`, `tag` `promotion`. |
| Services or packages. | `service`, `tag` `service`. |
| Holiday closures. | `holiday`, `tag` `holiday`, `action` `update_hours`. |

### Keep the guess from hitting the wrong element

- A carousel or photo grid is one gallery list. Do not emit a separate gallery target for every `<img>` inside it.
- A storefront or hero photo is `image:{slug}`. Do not give it `id` `gallery` or `tag` `gallery`.
- An added photo belongs on the gallery list. A replacement belongs on the named `image:…` row the text names.
- A dish name, its description, and its price share the same `menu:item:{section}:{index}` stem. The price row is the only one with `action` `update_price`.
- Keep section and index stable across catalog reads. Derive them from stored order, not from the order of DOM nodes that can shuffle.
- One element, one id. Do not list the same photo or the same dish twice.
- Prefer a short human `name`. `Gallery`, `Fajitas Supreme`, and `Monday–Saturday hours` are useful. `/assets/img/building.jpg` is not.
- When a selector exists, it replaces the guess. The guess is only the suggested starting set.

```json
{
  "ok": true,
  "catalog": {
    "adapters": ["custom"],
    "targets": [
      { "id": "gallery", "type": "custom_field", "name": "Gallery", "field": "gallery", "tag": "gallery", "action": "replace_image", "preview": "4 photos" },
      { "id": "image:building", "type": "custom_field", "name": "Storefront photo", "field": "image", "tag": "image", "action": "replace_image", "preview": "/assets/img/building.jpg" },
      { "id": "menu:item:dinner:0:name", "type": "custom_field", "name": "Fajitas Supreme", "field": "name", "tag": "menu_item", "action": "update_text", "preview": "Fajitas Supreme" },
      { "id": "menu:item:dinner:0:desc", "type": "custom_field", "name": "Fajitas Supreme", "field": "desc", "tag": "menu_item", "action": "update_text", "preview": "Steak, chicken and shrimp." },
      { "id": "menu:item:dinner:0:price", "type": "custom_field", "name": "Fajitas Supreme", "field": "price", "tag": "menu_price", "action": "update_price", "preview": "18.00" }
    ]
  }
}
```

## Responses

Return JSON and a 2xx status only after the signature is valid.

Catalog:

```json
{ "ok": true, "catalog": { "adapters": ["custom"], "targets": [{ "id": "page:home:heading", "type": "custom_field", "name": "Home heading", "field": "heading", "tag": "text", "action": "update_text", "preview": "Lunch until 2" }] } }
```

Read:

```json
{ "ok": true, "value": "Lunch until 2" }
```

Connection test:

```json
{ "ok": true, "pong": true }
```

A repeated `pending_update_id` that was already applied:

```json
{ "ok": true, "idempotent": true }
```

An applied change:

```json
{ "ok": true, "result": { "updated": "page:home:heading" } }
```

Errors use `{ "error": "reason" }`:

- `400` when the body is not JSON
- `401` when the signature or timestamp is invalid
- `422` when the signed change cannot be applied
- `503` when the site has no shared secret

## Implementation order

1. Read the raw body and parse it as JSON.
2. Verify the timestamp and signature.
3. Handle `catalog`, `read`, and `ping` without writing.
4. If `pending_update_id` was already applied, return `idempotent`.
5. Apply `action` to `target_id` and store that id so a retry does not apply twice.
