Create a webhook. All of the following fields are required in the post body:
name | type | meaning |
---|---|---|
type |
string | type of object being watched; package , scope , or owner |
name |
string | name of package or organization/user scope to watch, e.g, package , @scope , @scope/package etc. |
endpoint |
uri | full uri of the endpoint to post the notification to |
secret |
string | a secret shared between the registry & you; used to sign the payload |
The registry responds with the full hook object created, including the ID it generated for the hook.
Example:
var opts = {
uri: 'https://registry.npmjs.org/-/npm/v1/hooks/hook/',
json: {
type: 'scope',
name: '@npmcorp',
endpoint: 'https://example.com/webhook',
secret: 'this is certainly very secret'
}
};
Request.post(opts, function(err, res, body)
{
console.log('just created hook with id=' + body.id);
});
Update the hook with the given id. The endpoint
and secret
fields are required in the body. Responds with the hook object if a matching hook was found & updated.
Example:
var opts = {
uri: 'https://registry.npmjs.org/-/npm/v1/hooks/hook/abcdefgh',
json: {
endpoint: 'https://example.com/webhook',
secret: 'that secret turned out to be not very secret'
}
};
Request.put(opts, function(err, res, body)
{
console.log('just updated hook with id=' + body.id);
});
Remove the hook with the given id. Responds with the hook object if a matching hook was found & removed.
List all hooks currently set up for the authed user. Response body is a JSON object:
{
objects: []
}
objects
is an array of hook objects.
You may pass filtering arguments by query string:
package
: filter by package name; regexp patterns are not parsedlimit
: return at most N hooksoffset
: start at the Nth hook (use with limit for pagination)
Fetch the hook object for the single named hook.