You can use webhook subscriptions to receive notifications about particular events in Anvyl. After you've subscribed to a webhook, you can let your application immediately respond to specific events instead of having to make API calls periodically to check their status. For example, you can rely on webhooks to trigger an action in your app when a new Part is created or Purchase Order is drafted.

Creating a webhook subscription

You can configure a new webhook subscription by making an HTTP POST request to the Webhook endpoint.

The request should contain a name, target_url, and comma-delimited set of events that to your application would like to subscribe to.

An example request looks like the following:

POST /webhooks
 
"webhook": {
  name: "My application",
  target_url: "https://example.com/anvyl_event_listener",
  events: "PartCreated, OrderShipped"
}

List of supported webhook events

Event

Description

PartCreated

Triggered whenever a new part is created.

PartUpdated

Triggered whenever attributes of an existing part are updated.

PartSupplierCreated

Triggered whenever supplier information is linked to an existing part.

PartSupplierUpdated

Triggered whenever part-linked supplier information is updated.

OrderCreated

Triggered whenever a new order is created.

OrderUpdated

Triggered whenever attributes of an existing order are updated.

OrderCanceled

Triggered whenever an order is canceled.

OrderShipped

Triggered whenever an order is marked as shipped.

OrderDelivered

Triggered whenever an order is marked as delivered.

OrderOrItemsUpdated

Triggered whenever details of an order or line item is updated.

OrderScheduleUpdated

Triggered whenever the milestone schedule of an order is updated.

PurchaseOrderCreated

Triggered whenever a new PO is issued.

PurchaseOrderAccepted

Triggered whenever a PO is accepted.

PurchaseOrderAcceptedNewShipDate

Triggered whenever a PO is accepted with a new estimated ship date.

PurchaseOrderRejected

Triggered whenever a new PO is rejected.

DirectorySupplierCreated

Triggered whenever a new supplier contact is created.

DirectorySupplierUpdated

Triggered whenever attributes of existing suppliers are updated.

DirectoryPersonCreated

Triggered whenever a new supplier contact is added.

DirectoryPersonUpdated

Triggered whenever an existing supplier contact is updated.

Common properties of a webhook response

Every webhook response will contain the following common properties

Key

Type

Description

event_id

String

The unique identifier for the event.

event_name

String

The name of the event trigger. E.g. PartCreated

timestamp

String

The ISO8601 DateTime formatted string when the event occurred. E.g.

data

Object

Unique information about the event.

team_id

Integer

Team ID

Data payload of a webhook response

The data portion of the webhook payload contains the following common properties as well as contextual data unique to the event.

Key

Type

Description

id

Integer

The ID of the entity that the event is tied to. E.g. if the event is PartCreated, this is the Part ID.

subject_id

Integer

The user ID associated with the event trigger.

context

Object

Set of dynamic name/value pairs of the resource properties that have either been touched or updated as a result of the event.

The following is an example of a webhook payload when a supplier contact has been updated:

{
  "event_id": "d55d143c-1666-4808-aac7-540935521118",
  "event_name": "DirectorySupplierUpdated",
  "timestamp": "2020-06-11T00:07:27.000000+00:00",
  "data": {
    "id": 1519,
    "subject_id": 1427,
    "context": [
      {
       "name": "saved_changes",
       "value": {
         "name": [
           "Abernathy, Keebler, and Donnelly",
           "Abernathy, Keebler, Darth, and Donnelly"
          ],
          "updated_at": [
           "2020-06-11T00:02:35.193Z",
           "2020-06-11T00:07:27.552Z"
          ]
        }
      },
      {
       "name": "name",
       "value": "Abernathy, Keebler, Darth, and Donnelly"
      },
      {
       "name": "address_line1",
       "value": "18267 Davis Hills"
      },
      {
       "name": "phone",
       "value": "(587) 043-3503"
      },
      {
       "name": "notes",
       "value": "<CONFIDENTIAL_NOTES>"
      },
      {
       "name": "team_id",
       "value": 245
      },
      {
       "name": "created_at",
       "value": "2020-05-08 19:48:41 UTC"
      },
      {
       "name": "updated_at",
       "value": "2020-06-11 00:07:27 UTC"
      }
    ]
  },
  "team_id": 245
}