11cb0ef41Sopenharmony_ci---
21cb0ef41Sopenharmony_cititle: npm-hook
31cb0ef41Sopenharmony_cisection: 1
41cb0ef41Sopenharmony_cidescription: Manage registry hooks
51cb0ef41Sopenharmony_ci---
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci### Synopsis
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci```bash
101cb0ef41Sopenharmony_cinpm hook add <pkg> <url> <secret> [--type=<type>]
111cb0ef41Sopenharmony_cinpm hook ls [pkg]
121cb0ef41Sopenharmony_cinpm hook rm <id>
131cb0ef41Sopenharmony_cinpm hook update <id> <url> <secret>
141cb0ef41Sopenharmony_ci```
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciNote: This command is unaware of workspaces.
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci### Description
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciAllows you to manage [npm
211cb0ef41Sopenharmony_cihooks](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm),
221cb0ef41Sopenharmony_ciincluding adding, removing, listing, and updating.
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ciHooks allow you to configure URL endpoints that will be notified whenever a
251cb0ef41Sopenharmony_cichange happens to any of the supported entity types. Three different types
261cb0ef41Sopenharmony_ciof entities can be watched by hooks: packages, owners, and scopes.
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciTo create a package hook, simply reference the package name.
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ciTo create an owner hook, prefix the owner name with `~` (as in,
311cb0ef41Sopenharmony_ci`~youruser`).
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ciTo create a scope hook, prefix the scope name with `@` (as in,
341cb0ef41Sopenharmony_ci`@yourscope`).
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ciThe hook `id` used by `update` and `rm` are the IDs listed in `npm hook ls`
371cb0ef41Sopenharmony_cifor that particular hook.
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ciThe shared secret will be sent along to the URL endpoint so you can verify
401cb0ef41Sopenharmony_cithe request came from your own configured hook.
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci### Example
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ciAdd a hook to watch a package for changes:
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ci```bash
471cb0ef41Sopenharmony_ci$ npm hook add lodash https://example.com/ my-shared-secret
481cb0ef41Sopenharmony_ci```
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ciAdd a hook to watch packages belonging to the user `substack`:
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci```bash
531cb0ef41Sopenharmony_ci$ npm hook add ~substack https://example.com/ my-shared-secret
541cb0ef41Sopenharmony_ci```
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ciAdd a hook to watch packages in the scope `@npm`
571cb0ef41Sopenharmony_ci
581cb0ef41Sopenharmony_ci```bash
591cb0ef41Sopenharmony_ci$ npm hook add @npm https://example.com/ my-shared-secret
601cb0ef41Sopenharmony_ci```
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ciList all your active hooks:
631cb0ef41Sopenharmony_ci
641cb0ef41Sopenharmony_ci```bash
651cb0ef41Sopenharmony_ci$ npm hook ls
661cb0ef41Sopenharmony_ci```
671cb0ef41Sopenharmony_ci
681cb0ef41Sopenharmony_ciList your active hooks for the `lodash` package:
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ci```bash
711cb0ef41Sopenharmony_ci$ npm hook ls lodash
721cb0ef41Sopenharmony_ci```
731cb0ef41Sopenharmony_ci
741cb0ef41Sopenharmony_ciUpdate an existing hook's url:
751cb0ef41Sopenharmony_ci
761cb0ef41Sopenharmony_ci```bash
771cb0ef41Sopenharmony_ci$ npm hook update id-deadbeef https://my-new-website.here/
781cb0ef41Sopenharmony_ci```
791cb0ef41Sopenharmony_ci
801cb0ef41Sopenharmony_ciRemove a hook:
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ci```bash
831cb0ef41Sopenharmony_ci$ npm hook rm id-deadbeef
841cb0ef41Sopenharmony_ci```
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ci### Configuration
871cb0ef41Sopenharmony_ci
881cb0ef41Sopenharmony_ci#### `registry`
891cb0ef41Sopenharmony_ci
901cb0ef41Sopenharmony_ci* Default: "https://registry.npmjs.org/"
911cb0ef41Sopenharmony_ci* Type: URL
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ciThe base URL of the npm registry.
941cb0ef41Sopenharmony_ci
951cb0ef41Sopenharmony_ci
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci#### `otp`
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ci* Default: null
1001cb0ef41Sopenharmony_ci* Type: null or String
1011cb0ef41Sopenharmony_ci
1021cb0ef41Sopenharmony_ciThis is a one-time password from a two-factor authenticator. It's needed
1031cb0ef41Sopenharmony_ciwhen publishing or changing package permissions with `npm access`.
1041cb0ef41Sopenharmony_ci
1051cb0ef41Sopenharmony_ciIf not set, and a registry response fails with a challenge for a one-time
1061cb0ef41Sopenharmony_cipassword, npm will prompt on the command line for one.
1071cb0ef41Sopenharmony_ci
1081cb0ef41Sopenharmony_ci
1091cb0ef41Sopenharmony_ci
1101cb0ef41Sopenharmony_ci### See Also
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci* ["Introducing Hooks" blog post](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm)
113