Receive Vendors Webhook Events

When a vendor is created or updated in the backend, you might want to update your application to synchronize with the newly created or updated vendor. For example, when a vendor's status is updated, you want to be notified so that you don't attempt in your application to send a purchase order to the vendor if its status has become INACTIVE. To get your application notified of vendor-created or vendor-updated events, you can use Square API webhooks.

Link to section

Overview

When a vendor is created or updated, a vendor.created or vendor.updated event is sent, respectively, through the Vendors API webhook to applications that have registered to receive the event notification. Your application can parse the received event data and act on the information following your application's business logic.

The following discussion presents a walkthrough to illustrate how to subscribe to the Vendors API webhook events for your application and how to parse the received event data in your application.

In particular, it covers the following tasks:

  • Configuring your application to receive the vendor.created or vendor.updated event through the Vendors API webhook.
  • Inspecting received vendor.created or vendor.updated event data.

To test receiving the webhook events, follow the instructions in Create Vendors for a Square Seller and Update Vendor Information to have the vendor.created and vendor.updated events fired, respectively.

Link to section

Subscribe to the Vendors API event notifications

To subscribe to the Vendors API event notifications, you must register your application with the Square API webhook through which Square sends notifications to the application. For more information, see Square Webhooks Overview.

To subscribe to vendor.created or vendor.updated event notifications, configure the webhook for your Square application as follows.

To configure a webhook

  1. In the Developer Dashboard, open the application to which you want to subscribe.

  2. In the left pane, choose Webhooks.

  3. At the top of the page, choose Sandbox or Production. Choose Sandbox for testing.

  4. Choose Add Endpoint, and then configure the endpoint:

    1. For Webhook Name, enter a name such as Vendors API Webhook.
    2. For URL, enter your notification URL. If you don't have a working URL yet, you can enter https://example.com as a placeholder. To use Webhook.site for testing, copy the Your unique URL on the website and paste it in the URL box.
    3. Optional. For API Version, choose a Square API version. By default, this is set to the same version as the application.
    4. For Events, choose vendor.created and vendor.updated. If you want to receive notifications about other events at the same webhook URL, choose them or configure another endpoint.
    5. Choose Save.

    Note

    In the production environment, ignore the Enable Webhooks setting on the Webhooks page. This setting applies to webhooks for deprecated Connect V1 APIs.

With the webhook configured, you can proceed to test the webhook workflow as follows.

Link to section

Inspect the vendor.created event

When a new vendor is created, using either the Square API or Seller Dashboard, an instance of the vendor.created event is sent to your application registered for the webhook event.

The following example shows a vendor.created webhook event received when a vendor is created:

Link to section

Inspect the vendor.updated event

When an existing vendor is updated, an instance of the vendor.updated event is sent to your application.

The following example shows a vendor.updated event received when the vendor's name is updated from A Vendor to Macro Brewing and a note of Preferred beer supplier is added to the vendor: