Webhooks

Updated on 04th June 2022 in Notifications

Webhooks are a great way to notify your (or 3rd party) applications when an event occurs, such as a new order being created, or a customer being updated. 

Some common examples of webhook use cases are:

  1. Update your own database, or sync the data with your CRM when an order is created in Shoprocket
  2. Get notified when a product is created or updated; then sync your Shoprocket catalogue with your local database
  3. Add or remove email addresses from your mailing list when they subscribe or unsubscribe via Shoprocket

To set up a webhook, head to 'Developer' in the 'Settings' section of your Shoprocket dashboard and then:

  1. Click on "Add Webhook" and then select which event(s) you want to be notified of from the "Select Events" dropdown.
  2. Next, enter the URL that you would like the webhook payload sent to (this must be an absolute URL, such as https://mysite.com/webhooks)
  3. Click on "Save Webhook"
  4. In the next page, you'll see a summary of your webhook, including the status, the events it is sending, and the secret key.

The secret key can be used in your receiver to verify that a request to your callback URL is a valid request from Shoprocket.

We currently support the following webhook events:

  1. order.created - fired when an order is created
  2. order.updated - fired when an order is updated 
  3. order.deleted - fired when an order is deleted
  4. customer.created - fired when a customer is created
  5. customer.updated - fired when a customer is updated
  6. customer.deleted - fired when a customer is deleted

You can also click on "Send test data" in the top-right menu, where you can choose which event to test. We will then send a test webhook event to your endpoint with dummy data, which you can then verify your end. We will also verify the webhook response and display the output in the modal.

{
  "data": {
    "id": "716",
    "order_id": "#186",
    "raw_order_id": 186,
    "is_unread": "1",
    "store_id": "5",
    "customer_id": "568",
    "user_name": "John Doe",
    "email": "[email protected]",
    "user_contact_number": "XXXXXXXXXX",
    "automatic_discount": null,
    "subtotal": "12.00",
    "shipping_name": "Standard Shipping",
    "shipping_amount": "9.95",
    "tax_amount": "0.00",
    "discount_name": null,
    "discount_amount": "0.00",
    "total_amount": "21.95",
    "currency_paid_in": "USD",
    "currency_paid_in_symbol": "$",
    "payment_transaction_id": "716",
    "payment_method_id": "252",
    "payment_method_name": "Cash on delivery",
    "raw_payment_method_name": "manual",
    "billing_address": "#258, St. Louis, NYC, USA",
    "shipping_address": "#258, St. Louis, NYC, USA",
    "order_notes": null,
    "store_environment": "test",
    "payment_payload": {
      "amount": "21.95",
      "currency": "USD",
      "customerId": null,
      "livemode": "test",
      "receipt_url": null,
      "billing": {
        "address": {
          "city": "NYC",
          "country": "USA",
          "line1": "#258",
          "postal_code": "XXXX",
          "state": "NY"
        },
        "email": "[email protected]",
        "name": "John Doe",
        "phone": "XXXXXXXXXX"
      },
      "shipping": {
        "address": {
          "city": "NYC",
          "country": "USA",
          "line1": "#258",
          "postal_code": "XXXX",
          "state": "NY"
        },
        "email": "[email protected]",
        "name": "John Doe",
        "phone": "XXXXXXXXXX"
      },
      "payment_method": {
        "type": "manual"
      }
    },
    "fulfillment_status": 1,
    "fulfillment_status_raw": "awaiting_processing",
    "is_draft": "0",
    "invoice_number": "183",
    "invoice_link": "cdn.shoprocket.io/users/5/orders/716/183.pdf",
    "source_url": "http://shoprocket-widget:8080/",
    "customer_tax_id": null,
    "status": "1",
    "status_raw": "payment_pending",
    "v1_ref": null,
    "review_email_at": null,
    "cart_session": "sr_live_pk_cc6ff81f22ccb52ed7f6de0f07341",
    "deleted_at": null,
    "created_at": "2022-05-23 14:37:24",
    "updated_at": null,
    "order_items": [
      {
        "id": "20860",
        "order_id": "716",
        "item_id": "9386",
        "item_name": "prodo",
        "item_sku": null,
        "item_sku_id": null,
        "item_sku_attachment": null,
        "item_options": null,
        "item_image": "https://img.shoprocket.io/cdn-cgi/image/fit=cover,quality=75,f=auto,w=600,h=600/0/rg3hifr1-vase2.jpg",
        "unit_price": "12.00",
        "quantity": "1",
        "weight": "0.00",
        "discount_name": null,
        "discount_amount": null,
        "item_license_key": null,
        "item_source_url": "http://shoprocket-widget:8080/#!/prodo",
        "status": "1",
        "reviewed_at": null,
        "deleted_at": null,
        "created_at": "2022-05-23 20:07:22",
        "updated_at": null,
        "status_raw": "active"
      }
    ]
  },
  "type": "order.created",
  "webhook_environment": "test"
}

We suggest using https://webhook.site to quickly test webhooks with instant visual feedback on the payload.


Can’t find what you’re looking for?

Chat with us πŸ‘‹

or contact us on [email protected]


as featured in