HSX_E_TOKEN_KEY_CUSTODY_MISSING

Escrowed HSX_TOKEN_KEY not found in local custody.

What this error means

The runtime binding references an escrowed HSX_TOKEN_KEY, but the key is not in local custody. Nothing was mutated. The key cannot be read back from the deployed Worker (Cloudflare secrets are write-only).

When this error stops a command, hs-x exits with code 1. With --json, the failure is reported as a structured error whose code field is HSX_E_TOKEN_KEY_CUSTODY_MISSING — stable to match on in scripts and agents.

Likely causes

  • The hs-x state directory ($XDG_STATE_HOME/hs-x/token-key-custody.*) or macOS Keychain item was deleted or not restored on this machine
  • You are deploying from a different machine than the one that created the unlinked deploy

How to fix it

  • Restore $XDG_STATE_HOME/hs-x/token-key-custody.json + token-key-custody.key (or the dev.hs-x.token-key Keychain item) from a backup of the original machine
  • If the key is unrecoverable: existing installs keep working on the already-deployed Worker, but the only re-key path is asking customers to reinstall (see docs/token-key-custody.md)

Still stuck? Re-run the command with --debug for the wire-level detail, or hs-x doctor to check accounts, link state, and connectivity in one pass.