To work with a webhook, you need to know a bit about the payload you’ll be receiving. Each event you receive a payload for will contain special headers that describe what the event is.
Example Headers
X-Request-Id: d535c62b-063e-4ace-90ce-f7b579d6c37c Content-Type: application/json; charset=UTF-8 User-Agent: Nexus/3.1.0-SNAPSHOT (PRO; Mac OS X; 10.11.1; x86_64; 1.8.0_60) X-Nexus-Webhook-Signature: 687f3719b87232cf1c11b3ef7ea10c49218b6df1 X-Nexus-Webhook-Id: rm:repository:asset X-Nexus-Webhook-Delivery: 7f4a6dde-5c68-4999-bcc0-a62f3fb8ae48
Of special importance are the following three headers:
Header | Description |
---|---|
| This is the HMAC digest of the body of the payload, if an optional secret key has been configured |
| This is a unique UUID identifying the event |
| This is the event type, e.g. |
A payload will be returned with each event type, an example of one for a repository asset webhook is shown below:
Example Payload
{ "timestamp" : "2016-11-10T23:57:49.664+0000", "nodeId" : "52905B51-085CCABB-CEBBEAAD-16795588-FC927D93", "initiator" : "admin/127.0.0.1", "repositoryName" : "npm-proxy", "action" : "CREATED", "asset" : { "id" : "31c950c8eeeab78336308177ae9c441c", "assetId" : "bnBtLXByb3h5OjMxYzk1MGM4ZWVlYWI3ODMzNjMwODE3N2FlOWM0NDFj", "format" : "npm", "name" : "concrete" } }
Events share common fields, described in detail below:
Header | Description |
---|---|
| A UUID that identifies which Nexus Repository Manager node the event originated from |
| The ISO 8601 representation of the time the event occurred |
| The userId or "anonymous" for system events |
Below, you will find examples of many Payloads that are returned, to help you get up and running with webhooks in Nexus Repository Manager.
This is an example payload returned when a user is created inside of Nexus Repository Manager:
Global Audit Payload
{ "nodeId":"7FFA7361-6ED33978-36997BD4-47095CC4-331356BE", "initiator":"admin/127.0.0.1", "audit":{ "domain":"security.user", "type":"created", "context":"testuser", "attributes":{ "id":"testuser", "name":"test user", "email":"test@test.com", "source":"default", "status":"active", "roles":"nx-admin, nx-anonymous" } } }
Audit Event Fields
Field | Description |
---|---|
| A string that identifies the domain where the event occurred |
| A string that identifies action type that occurred on the object |
| A string that identifies the object the event refers to |
| A list that describes the attributes on the object that the event occurred on |
This is an example payload returned when a PyPi proxy repository is created inside of Nexus Repository Manager:
Global Repository Payload
{ "timestamp":"2016-11-14T20:19:34.525+0000", "nodeId":"7FFA7361-6ED33978-36997BD4-47095CC4-331356BE", "initiator":"admin/127.0.0.1", "action":"CREATED", "repository":{ "format":"pypi", "name":"pypi-proxy", "type":"proxy" } }
Repository Event Fields
Field | Description |
---|---|
| A string that identifies the action performed on the repository |
| A string that identifies the repository format type |
| A string that identifies the repositories name |
| A string that identifies the type of repository |
This is an example payload returned when an asset is created inside of Nexus Repository Manager:
Repository Asset Payload
{ "timestamp" : "2016-11-10T23:57:49.664+0000", "nodeId" : "52905B51-085CCABB-CEBBEAAD-16795588-FC927D93", "initiator" : "admin/127.0.0.1", "repositoryName" : "npm-proxy", "action" : "CREATED", "asset" : { "id" : "31c950c8eeeab78336308177ae9c441c", "assetId" : "bnBtLXByb3h5OjMxYzk1MGM4ZWVlYWI3ODMzNjMwODE3N2FlOWM0NDFj", "format" : "npm", "name" : "concrete" } }
Repository Asset Event Fields
Field | Description |
---|---|
| A string that identifies the repository where the event occurred |
| A string that identifies the action performed on the asset |
| A UUID that identifies the assets ID (to be used with Groovy scripting) |
| A UUID that identifies the assets ID (to be used with REST API) |
| A string that identifies the repository format type |
| A string that identifies the asset name |
This is an example payload returned when a component is created inside of Nexus Repository Manager:
Repository Component Payload
{ "timestamp":"2016-11-14T19:32:13.515+0000", "nodeId":"7FFA7361-6ED33978-36997BD4-47095CC4-331356BE", "initiator":"anonymous/127.0.0.1", "repositoryName":"npm-proxy", "action":"CREATED", "component":{ "id":"08909bf0c86cf6c9600aade89e1c5e25", "componentId":"bnBtLXByb3h5OjA4OTA5YmYwYzg2Y2Y2Yzk2MDBhYWRlODllMWM1ZTI1", "format":"npm", "name":"angular2", "group":"types", "version":"0.0.2" } }
Repository Component Event Fields
Field | Description |
---|---|
| A string that identifies the repository where the event occurred |
| A string that identifies the action performed on the component |
| A UUID that identifies the assets ID (to be used with Groovy scripting) |
| A UUID that identifies the assets ID (to be used with REST API) |
| A string that identifies the repository format type |
| A string that identifies the component name |
| A string that identifies the component group |
| A string that identifies the component version |