1---
2title: npm-hook
3section: 1
4description: Manage registry hooks
5---
6
7### Synopsis
8
9```bash
10npm hook add <pkg> <url> <secret> [--type=<type>]
11npm hook ls [pkg]
12npm hook rm <id>
13npm hook update <id> <url> <secret>
14```
15
16Note: This command is unaware of workspaces.
17
18### Description
19
20Allows you to manage [npm
21hooks](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm),
22including adding, removing, listing, and updating.
23
24Hooks allow you to configure URL endpoints that will be notified whenever a
25change happens to any of the supported entity types. Three different types
26of entities can be watched by hooks: packages, owners, and scopes.
27
28To create a package hook, simply reference the package name.
29
30To create an owner hook, prefix the owner name with `~` (as in,
31`~youruser`).
32
33To create a scope hook, prefix the scope name with `@` (as in,
34`@yourscope`).
35
36The hook `id` used by `update` and `rm` are the IDs listed in `npm hook ls`
37for that particular hook.
38
39The shared secret will be sent along to the URL endpoint so you can verify
40the request came from your own configured hook.
41
42### Example
43
44Add a hook to watch a package for changes:
45
46```bash
47$ npm hook add lodash https://example.com/ my-shared-secret
48```
49
50Add a hook to watch packages belonging to the user `substack`:
51
52```bash
53$ npm hook add ~substack https://example.com/ my-shared-secret
54```
55
56Add a hook to watch packages in the scope `@npm`
57
58```bash
59$ npm hook add @npm https://example.com/ my-shared-secret
60```
61
62List all your active hooks:
63
64```bash
65$ npm hook ls
66```
67
68List your active hooks for the `lodash` package:
69
70```bash
71$ npm hook ls lodash
72```
73
74Update an existing hook's url:
75
76```bash
77$ npm hook update id-deadbeef https://my-new-website.here/
78```
79
80Remove a hook:
81
82```bash
83$ npm hook rm id-deadbeef
84```
85
86### Configuration
87
88#### `registry`
89
90* Default: "https://registry.npmjs.org/"
91* Type: URL
92
93The base URL of the npm registry.
94
95
96
97#### `otp`
98
99* Default: null
100* Type: null or String
101
102This is a one-time password from a two-factor authenticator. It's needed
103when publishing or changing package permissions with `npm access`.
104
105If not set, and a registry response fails with a challenge for a one-time
106password, npm will prompt on the command line for one.
107
108
109
110### See Also
111
112* ["Introducing Hooks" blog post](https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm)
113