Use Case - Webhooks

Receiving notifications

Jungle can notify registered URLs about specific events. These notices are sent after some mutation or action happens with in Jungle. They are pushed via HTTPS to registered URLs for a specific event.

mutation InventoryWebhookSubscribe {
  webhookSubscribe(input: { url: "https://example.jungle/notices/inventory", event: InventorySetEvent })
}

Confirmation will look like this:

{
  "data": {
    "webhookSubscribe": true
  }
}

🤖 The provided url must use HTTP over TLS https://. Tools such as ngrok can provide a SSL tunnel to your local machine.

Events

The events available for subscription are described in schema via the WebhookEvent enum.

They are also documented in the following list of supported webhook events:

InventorySetEvent

Triggered whenever an inventory value changes at a location for a product.

The following will be the request body:

{
  "__typename": "InventorySetEvent",
  "occurredAt": "2020-07-21T04:53:19.904Z",
  "createdBy": "user|exampleId",
  "accountId": "demo"
  "locationId": "CFOWoyDm8vTX5HWgZRqR",
  "sku": "000SKU123",
  "quantityOnHand": 2,
  "quantityAllocated": 2,
  "quantityAvailableToPromise": 0
}

ClickAndCollectReadyEvent

Triggered whenever a click-and-collect fulfilment is ready for collection.

The following will be the request body:

{
  "__typename": "ClickAndCollectReadyEvent",
  "occurredAt": "2020-07-21T04:53:19.904Z",
  "createdBy": "user|oGuKa2PztCzvkkXbdCK2",
  "accountId": "example-8vTX5",
  "orderId": "8K53aW8OH0DXr7DhMdEm",
  "locationId": "CFOWoyDm8vTX5HWgZRqR",
  "fulfilmentCollectId": "7s1fWwKejKuHG5sHX0Jv"
}

OrderAllocatedEvent

Triggered whenever an order has been allocated

The following will be the request body:

{
  "__typename": "OrderAllocatedEvent",
  "occurredAt": "2020-07-21T04:53:19.904Z",
  "createdBy": "user|oGuKa2PztCzvkkXbdCK2",
  "accountId": "example-8vTX5",
  "orderId": "8K53aW8OH0DXr7DhMdEm"
}

FulfillmentCreatedEvent

Triggered whenever an fulfillment has been created

The following will be the request body:

{
  "__typename": "FulfillmentCreatedEvent",
  "allocationId": "ej2wJrn9SHiRTG9vmrGekXNnBnD:gCcAWHSr",
  "orderId": "dEqgZliXx9T8hWnxRqgE",
  "shipmentId": "accounts/test/shipments/vdP4VbJx8ZnEI9V5fpTS",
  "subject": "accounts/test/orders/pIMM2Ann6I3wQWhEUwPR/fulfilments/K8qmGdhBv9vTT5cnD0E8",
  "createdBy": "user|gDQuE2MuxSU3RipOcEJimm8fj43b",
  "createdAt": "2021-10-18T22:51:06.465Z"
}

ShipmentReady

Triggered whenever an shipment is ready

The following will be the request body:

{
  "__typename": "ShipmentReady",
  "subject": "accounts/test/shipments/GCmWUUxTTLoGX0adeKIB",
  "trackingNumber": "ACME000123",
  "serviceProviderName": "Acme Shipping Co",
  "packages": [
    {
      "id": "accounts/test/shipments/GCmWUUxTTLoGX0adeKIB#packages.0",
      "trackingNumber": "ACME0006661"
    }
  ],
  "serviceId": "External",
  "status": "Ready",
  "createdBy": "user|gDQuE2MuxSU3RipOcEJimm8fj43b",
  "createdAt": "2021-10-18T22:44:30.141Z"
}

Created

Modified

InventoryAssignment

Triggered when assigned inventory is modified in Jungle.

The following will be the request body:

{
  "__typename": "InventoryAssignment",
  "subjectTypename": "Allocation",
  "subject": "WPtanMXYq2iq5pS8lN8HYtRfJ9lyEsyiInm0:ADAVx4DG",
  "inventoryAssignmentSummary": [
    {
      "sku": "890052-B01",
      "quantityAllocated": 3,
      "quantityAssigned": 2
    },
    {
      "sku": "890112-LS",
      "quantityAllocated": 2,
      "quantityAssigned": 2
    }
  ],
  "attributes": [],
  "createdBy": "User|7R7zTPmbzTHK6dbssZKAfT9EsISj",
  "createdAt": "2023-06-08T05:03:15.974Z"
}

ShipmentTrackingUpdated

Triggered when Jungle receives updated tracking information for a Shipment (or one of its packages).

The following will be the request body:

{
  "occurredAt": "2023-09-05T07:37:31.037Z",
  "tracking": {
    "checkpoints": [
      {
        "locationString": "Timbuktu",
        "message": "Your shipment has arrived"
      }
    ]
  },
  "trackingNumber": "CPB6QHZ0242558",
  "subject": "accounts/test/shipments/qdfimAnqWHQp6sft5ZEe",
  "__typename": "ShipmentTrackingUpdated",
  "aid": "test",
  "createdBy": "jungle",
  "createdAt": "2023-09-05T07:37:31.037Z"
}

Unsubscribing

The stop receiving event notifications, unsubscribe the URL:

mutation {
  webhookUnsubscribe(input: { url: "https://example.jungle/notices/inventory" })
}

❗️When unsubscribing an url, all events registered to it will stop being sent.

Fill 1

Can't find what you're looking for?

Contact Us