# Deploy hooks

A deploy hook is a secret URL that triggers a rebuild of your app when POSTed — no auth header, the URL itself is the credential. Wire it into a headless CMS publish button (Sanity, Contentful, Strapi), a cron job, or a CI step so content changes redeploy the app without touching git.

**What a trigger does.** `POST https://api.percher.run/hooks/deploy/<token>` → `202 { deployId, app }`. An app with a connected GitHub/Forgejo repo rebuilds the latest commit of its tracked branch; an app without one re-runs the latest live deploy's build. If the app has never had a live deploy, the trigger returns `409 NO_DEPLOY_YET`. If its stored source has been cleaned up, it returns `410 TARBALL_GONE`. In either case, publish once (or connect a repo), then trigger the hook again.

**Create one** (the URL is shown ONCE — store it immediately):
```sh
bunx percher hook create sanity-publish
```
Dashboard: your app → Settings → Deploy hooks. MCP: `percher_hook` with `action: "create"`. Manage with `percher hook list` (name, id, created, last used) and `percher hook revoke <id>`.

**CMS recipes.** Sanity: manage.sanity.io → API → Webhooks → paste the hook URL, trigger on create/update/delete of published documents, method POST (no payload needed — Percher ignores the body). Contentful: Settings → Webhooks → paste the URL, trigger on Entry publish/unpublish. Strapi: Settings → Webhooks → paste the URL with the entry.publish / entry.unpublish events (or call it from an `afterPublish` lifecycle hook).

**Rate limit.** 6 triggers per minute per hook — beyond that the endpoint returns 429. Rapid-fire CMS saves coalesce into at most a few rebuilds; deploys still count against your plan's daily deploy quota.

**Security.** The URL is a bearer secret: anyone holding it can trigger builds (they can't read code, env vars, or anything else). Percher stores only a hash, so a lost URL can't be recovered — revoke the hook and create a fresh one to rotate. `lastUsedAt` in `percher hook list` makes a leaked URL observable: triggers you don't recognize mean it's time to rotate. Unknown tokens get a plain 404.

Full guide: https://percher.app/docs/deploy-hooks
