← Back to docs

API Reference

REST API for building custom integrations.

Authentication

Send your site's public site key in the X-Jamwidgets-Key header. A missing or unknown key returns 401.

curl https://jamwidgets.com/api/v1/comments/my-page \
  -H "X-Jamwidgets-Key: your-site-key"

These routes don't take the site key. A token in the URL authorizes them instead: /subscribe/confirm/{token}, /unsubscribe/{token} (links in subscriber emails), and /deploy/complete/{batchId} (the deploy callback).

Visitor headers

The widgets also send these headers. They're optional unless noted. The server stores hashes, not the raw IDs.

  • X-Jamwidgets-Visitor: a random ID kept in the browser's local storage. It ties reactions, poll votes and dismissed announcements to one visitor, and counts unique views. Required for POST/DELETE /reactions and POST /polls/{slug}/vote; without it they return 400. For views and announcements without it, the server uses the IP address and user agent instead.
  • X-Jamwidgets-Session: a random ID for the browser tab session. It groups a visitor's comments, reactions, form submissions and subscriptions into one session for analytics. Without it, the server uses a daily hash of the IP address and user agent.
  • X-Jamwidgets-Path: the page path, by default window.location.pathname. Analytics credit those same events to this page. Without it, comments and reactions use the pageId, and form submissions and subscriptions aren't tied to a page or session.

Base URL

https://jamwidgets.com/api/v1

Errors

Errors return a 4xx or 5xx status with this JSON body. code is one of authentication, authorization, badRequest, validation, notFound, unavailable, database or exception. Validation errors add validationErrors.errors, a list of { field, code, message }.

{
  "status": "Bad Request",
  "message": "Invalid email address",
  "code": "badRequest"
}

Endpoints

Bodies are JSON. Fields marked ? are optional. Comment, form, subscribe, waitlist and feedback bodies also accept a _gotcha honeypot field; leave it empty.

Site

GET
/site

Site name, slug, and showPoweredBy, which is true when the plan requires the footer

Returns { "site_config": { name, slug, showPoweredBy } }

Comments

GET
/comments/{pageId}

List approved comments for a page as threads; ?limit (default 100, max 500) and ?after

Returns { "comment_threads": [{ id, authorName, content, createdAt, replies: [...] }] }

POST
/comments/{pageId}

Create a new comment

Body { authorName, content, authorEmail?, parentId? }; returns { "comment": { id, pageId, parentId, authorName, content, isApproved } }

Reactions

GET
/reactions/{pageId}

Get reaction counts for a page

Returns { "reaction_counts_with_user": { pageId, counts: { "like": 3 }, userReactions: [...] } }

POST
/reactions/{pageId}

Add a reaction (needs X-Jamwidgets-Visitor)

Body { reactionType? } (default "like"); returns { "reaction": { pageId, reactionType, count } }

DELETE
/reactions/{pageId}

Remove a reaction (needs X-Jamwidgets-Visitor)

Body and response as for POST

Forms

POST
/forms/{slug}/submit

Submit form data

Body: one key per form field name; the form's required fields must be present. Returns { success, message }

Subscriptions

POST
/subscribe

Subscribe an email address

Body { email }; returns { success, message }

GETPOST
/subscribe/confirm/{token}

Confirm subscription. No site key. GET returns an HTML page with a confirm button; POST (no body) confirms and returns an HTML result page.

GETPOST
/unsubscribe/{token}

Unsubscribe. No site key. GET returns an HTML page with an unsubscribe button; POST (no body) unsubscribes and returns an HTML result page.

Waitlist

POST
/waitlist

Join the waitlist

Body { email, name?, source?, metadata? }; returns { success, message, position? }

Feedback

POST
/feedback

Submit feedback

Body { content, feedbackType?, email?, pageUrl? }; feedbackType is bug, feature or general (default). Returns { success, message }

Polls

GET
/polls/{slug}

Get poll data

Returns { "poll_with_results": { id, slug, question, options: [{ id, text }], settings, endsAt, isActive, results, totalVotes, userVotes } }

POST
/polls/{slug}/vote

Vote on a poll (needs X-Jamwidgets-Visitor)

Body { selectedOptions: ["optionId"] }; returns { "vote_response": { success, results, totalVotes } }

Views

GET
/views/{pageId}

Get view counts

Returns { "page_view_counts": { pageId, views, uniqueVisitors } }

POST
/views/{pageId}

Record a view

No body; returns { "record_view_response": { views, uniqueVisitors, isNewVisitor } }

POST
/e

Record a pageview for analytics (no cookies). Body: { "path": "/post", "sessionId": "optional" }; returns 204

Announcements

GET
/announcements

List active announcements this visitor hasn't dismissed

Returns { "announcements": [{ id, content, announcementType, linkUrl, linkText, isDismissible }] }

POST
/announcements/{id}/dismiss

Dismiss an announcement

No body; returns { "success": true }

Posts

GET
/posts

List published posts; ?limit (default 100, max 500), ?offset, ?tag

Returns { "posts": [...], "total": 12 }. Each post has id, title, slug, content (Markdown), contentJson, excerpt, coverImage, metaTitle, metaDescription, tags, publishedAt

GET
/posts/{slug}

Get a single post

Returns { "public_post": { ... } } with the same fields

Galleries

GET
/galleries

List published galleries; ?limit and ?after (a cursor)

Returns { "galleries": [{ id, title, slug, description, cover, photoCount, publishedAt }], "nextCursor": null }

GET
/galleries/{slug}

Get a gallery; add ?tag=portraits to filter photos

Returns { "gallery": { id, title, slug, description, photos: [...] } }. Each photo has id, width, height, variants: [{ width, height, url }], altText, caption, tags

GET
/galleries/{slug}/random

Get a random or seeded photo; ?seed and ?tag

Returns { "gallery_photo": { ... } } with the photo fields above

Deploy hooks

On Team, Jamwidgets can rebuild a statically generated site when you publish a post, republish an edited one, or publish, unpublish or reorder galleries. Set the provider in the site's settings under Deploy hook provider. Vercel and Netlify take a deploy hook URL. GitHub (the GitHub App, or a personal access token with Contents write access) sends a repository_dispatch event to the repository you choose.

GitHub event

With a personal access token, you can set the event type in the site's settings; it defaults to deploy. The GitHub App always sends deploy. GitHub only runs workflows for repository_dispatch from the default branch. The payload names the site, so one repository can serve several Jamwidgets sites:

{
  "action": "deploy",
  "client_payload": {
    "site_slug": "my-blog",
    "jamwidgets_callback_url": "https://jamwidgets.com/api/v1/deploy/complete/…",
    "jamwidgets_batch_id": "…"
  }
}
  • site_slug is the site's slug in Jamwidgets. Use it to pick what to build when several sites share a repository.
  • jamwidgets_callback_url and jamwidgets_batch_id are sent only when the site's Notification timing is Deploy callback.

Notification timing

Subscriber emails for a new post wait for the deploy, so the link in the email works.

  • Fixed delay sends them a set number of minutes after the deploy is triggered, whether or not it succeeded.
  • Deploy callback sends them when your workflow sends a POST to jamwidgets_callback_url after a successful deploy.
  • With Deploy callback, the Fallback timeout (60 minutes by default) still sends them if no callback arrives in time, including after a failed deploy. A callback is a way to send sooner, not a guarantee that the deploy succeeded.

The callback is POST /deploy/complete/{batchId} with no body and no site key; it returns { "ok": true, "processed": 1 }. The URL itself authorizes the call, so keep it out of logs.

on:
  repository_dispatch:
    types: [deploy]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      # Build and deploy as usual; the build fetches the new post.
      - run: npm ci && npm run build
      # Only needed with Notification timing → Deploy callback.
      - name: Tell Jamwidgets the deploy finished
        if: ${{ success() && github.event.client_payload.jamwidgets_callback_url != '' }}
        env:
          CALLBACK_URL: ${{ github.event.client_payload.jamwidgets_callback_url }}
        run: curl --fail --silent --show-error --request POST "$CALLBACK_URL"

CORS & Origin Validation

You can configure allowed origins for your site in the dashboard. If set, browser requests whose Origin header isn't on the list are refused. Matching ignores a leading www.and the scheme's default port. An entry without a scheme, such as example.com, matches both http and https, and a localhost entry without a port matches any local dev port.

Requests without an Origin header, such as the Astro content loader at build time, are server-side calls and are accepted with your site key.

Leave allowed origins empty to accept requests from any origin.