Software Factory

Your preview talks to the Ghosty API without keys

Every preview ships GHOSTY_PREVIEW_TOKEN, a Ghosty-signed identity for the partner API. With 3 lines your app uses it instead of the partner key, so no PR needs to copy secrets.

Updated 2026-11-22

If your app calls the Ghosty partner API (/api/v2/partner/*), in production it signs with its key (X-Ghosty-Key + HMAC). In a preview there is no need to copy that key: Ghosty gives each box its own identity, like GitHub Actions or Vercel OIDC. The API accepts it as Authorization: Bearer and resolves the partner from its own records, never from what the app says.

What you get

  • GHOSTY_PREVIEW_TOKEN in every preview's environment: an EdDSA JWT with aud = ghosty-api, sub = the box, repo, pr and sha. It is re-signed on every push and expires with the box (48 h for a standalone preview). It does not exist in production.
  • Same keys and JWKS as X-Ghosty-Identity (/.well-known/preview-identity/jwks.json), with a different aud: one never works as the other.

The recipe (3 lines)

js
// Ghosty preview: no partner key, the box brings its own identity.const previewToken = !process.env.GHOSTY_PARTNER_KEY && process.env.GHOSTY_PREVIEW_TOKEN;const auth = previewToken ? { Authorization: `Bearer ${previewToken}` } : { "X-Ghosty-Key": keyId, "X-Ghosty-Ts": ts, "X-Ghosty-Sig": signCredentialBody(secret, ts, keyId, raw) };

Spread ...auth into the fetch headers and drop the "missing key" error when there is a token.

What it can do

  • Testing: whatever needs agents:read — turns (/turns, /agui), pages (/pages/*) and reads. Creating or changing agents and businesses, WhatsApp and credentials still require the partner key (403).
  • Partner: always one of the partner workspaces owned by the owner of the preview's workspace. Which one: the one named by partner: <workspace> in the .ghosty/factory.md frontmatter; otherwise the preview's own workspace; if that is not a partner, the owner's only one. None, several without saying which, or someone else's → 403 with the reason.
  • Live box: if the box no longer exists or belongs to another repo, 401. Capped at 300 calls per hour per box (429).
  • Calls show up in the partner's audit log as preview:<box>.