Event subscription is a powerful method allowed via the API. This lets you create a specific endpoint that receives targeted webhook events (as opposed to standard webhooks, which receive all events throughout the account).
Unlike webhooks, event subscriptions always receive JSON. Your endpoints will receive an HTTP POST containing the JSON blob in the body. You'll want to use your language's JSON decoder (in PHP, this is $event = json_decode(file_get_contents('php://input'), true);
) to parse this into an object so that you can use the event's details.
Important! You will only be able to create a target_url that begins with one of the URLs registered to your app. Similarly to redirect URLs for the OAuth process, you must include the beginning of your URL in your app's settings. Note that this does not apply for account-wide API keys.
For example, to receive events at https://mysite.com/webhook
, you must register at least https://mysite.com
within your app's URL settings or you will receive an error.
To create an event subscription, you will POST
a JSON blob to the subscribe endpoint: https://thrivecart.com/api/external/subscribe
You will need to include at least the event
key containing the event you want to receive, or *
to receive all available events, and the target_url
key containing the URL you want to receive these events.
You can choose to either subscribe to all possible events (this is equivalent to creating a webhook in the user's account), or you can receive specific events. See the links on the left to view the available filter parameters available for each event.
See the event list to the left to see more detailed info on how to subscribe to each event and how to use the trigger fields to only receive specific events.
{"event": "*", "target_url": "https://mysite.com/webhooks/catchall/"}
{"event": "order_refund", "target_url": "https://mysite.com/webhooks/123/", "trigger_fields": {"mode_int": 2, "refund": {"type": "upsell", "upsell_id": [1, 5, 18]}}}