Deploy code that runs on an app's events
anyhook_code_deploySave a handler that runs on every event this app receives, in an isolated sandbox, with AnyHook's retries and replay around it: no server of your own. Each run's console output and return value are stored as that delivery's response (anyhook_inspect shows them). It can also run on a cron schedule. Pro and Scale; runs are capped per month with no overage, retries, test runs and schedule firings each count, and each run and package install is charged to the monthly compute allowance (anyhook_usage shows both). Test it with anyhook_code_test before real events arrive.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | An ES module, run in a sandboxed Node.js on every event this app receives. Either `export default async function (event, { env }) {}` (event: { method, headers, body, raw_body, delivery_id, attempt }; method is always POST, and the query string, path and caller IP are not kept) or a Pipedream Node.js code step: `export default defineComponent({ async run({ steps, $ }) {} })`, where steps.trigger.event is that same event (a step reading query, path, url or client_ip needs changing) and $.export and $.flow.exit work. npm packages it imports are installed on deploy (pin as "pkg@1.2.3", like Pipedream; a new package list usually takes seconds, a large one a few minutes). @pipedream/platform is a stand-in. State between events: the app's store (store.get/set/has/delete/keys, set takes { ttl }); every data_store prop is that one store, an app prop's this.<prop>.$auth.<field> reads the secret <APP>_<FIELD>, any other prop the secret named after it (channelId → CHANNEL_ID). Throwing fails the delivery, which AnyHook retries. Templates for common actions (Slack, email, Google Sheets, Notion, Claude and more): https://anyhook.net/code-templates.md | |
| api_key | No | API key (ahk_live_...) from anyhook_quickstart. Only needed over HTTP when no Authorization header is set; ignored over stdio. | |
| appSlug | Yes | The app whose events the code runs on. | |
| enabled | No | Whether events run the code. false saves it switched off, so it runs only through anyhook_code_test. Omit: a first deploy goes live and later deploys keep the current state. Deploy off while another system still handles the same events, or both will act on each one. | |
| secrets | No | Environment variables for the code, read as env.NAME or process.env.NAME. Merged into the saved ones; null removes a name. | |
| schedule | No | Also run on a cron schedule: five fields, UTC unless prefixed CRON_TZ=Area/City, e.g. "*/15 * * * *". Each firing arrives as an anyhook.schedule event and counts as a run. null removes it; omit to keep it. Only on an app that does not verify a sender's signature. |