Example Headers And Payloads

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.

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:

HeaderDescription
X-Webhook-SignatureThis is the HMAC digest of the body of the payload, if an optional secret key has been configured
X-Nexus-Webhook-DeliveryThis is a unique UUID identifying the event
X-Nexus-Webhook-Id
This is the event type, e.g. rm:repository:asset

A payload will be returned with each event type, an example of one for a repository asset webhook is shown below:

{
   "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:

HeaderDescription
nodeIdA UUID that identifies which Nexus Repository Manager node the event originated from
timestampThe ISO 8601 representation of the time the event occurred
initiatorThe 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.

Example Audit Payload

This is an example payload returned when a user is created inside of Nexus Repository Manager:

{
  "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

FieldDescription
audit:domainA string that identifies the domain where the event occurred
audit:typeA string that identifies action type that occurred on the object
audit:contextA string that identifies the object the event refers to
attributesA list that describes the attributes on the object that the event occurred on

Example Repository Payload

This is an example payload returned when a PyPi proxy repository is created inside of Nexus Repository Manager:

{
   "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

FieldDescription
actionA string that identifies the action performed on the repository

repository:format

A string that identifies the repository format type
repository:nameA string that identifies the repositories name
repository:typeA string that identifies the type of repository

Example Repository Asset Payload

This is an example payload returned when an asset is created inside of Nexus Repository Manager:

{
   "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

repositoryNameA string that identifies the repository where the event occurred
actionA string that identifies the action performed on the asset
asset:idA UUID that identifies the assets ID (to be used with Groovy scripting)
asset:assetId

A UUID that identifies the assets ID (to be used with REST API) NEW IN 3.17

asset:formatA string that identifies the repository format type
asset:nameA string that identifies the asset name

Example Repository Component Payload

This is an example payload returned when a component is created inside of Nexus Repository Manager:

{
   "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"
   }
}


Field

Description

repositoryNameA string that identifies the repository where the event occurred
actionA string that identifies the action performed on the component
component:idA UUID that identifies the assets ID (to be used with Groovy scripting)
component:componentId

A UUID that identifies the assets ID (to be used with REST API) NEW IN 3.17

component:formatA string that identifies the repository format type
component:nameA string that identifies the component name
component:groupA string that identifies the component group
component:versionA string that identifies the component version