What is the difference between API and webhook?
API's are request-based, meaning that they operate when requests come from 3rd party apps without knowing whether they get any dataset update as a response or not.
A Webhook is event-based, and receives calls through HTTP POSTs from external systems, and will run almost immediately, when a specific event occurs in the source app.
Webhooks in Americommerce:
Webhooks are a way to run code on an external server that integrates with events in AmeriCommerce. When the conditions are fulfilled, the AmeriCommerce will make a request out to a URL, and, depending on the webhook, wait for a response.
In the case of events that expect responses, the timeout is intentionally short (3 seconds), since any delay can potentially be disrupting to users of the store. It is highly recommended that your service return results as quickly as possible.
Navigate to Tools > Apps & Addons > Webhooks to find the following webhooks page:
Select the "New" button in the top-right hand corner of your screen to subscribe to a new webhook. Here you will find the following settings:
This is the type of event for which this webhook will be triggered. Webhook events with a name beginning with "Get" or "Validate" expect a response, all other types do not. All webhook events are sent via POST.
|URL||This is the URL to where the webhook event data will be POSTed. Must be a valid, absolute URL. Only one webhook per event type and destination URL may be configured.|
|Failure Type||This controls how the system will behave when a failure condition is encountered when sending a webhook event. Ignore means that any failure in sending the webhook will be ignored. Error means that any subsequent webhook subscriptions for the event will not be attempted. Fallback means that the system will attempt to send the event to the URL configured under the Fallback URL field for the webhook.|
Only relevant for event types beginning with "Get" or "Validate". This controls how long the system will cache responses for the hook from the external system.
|Fallback URL||Only relevant for webhooks with a Failure Type of Fallback. In such a case, this field must be specified and must be a valid, absolute URL.|
|Store||For webhooks that related to a specific store context (orders, customers, etc.), this determines which store's events and data will be sent for this subscription. Some data and events such as those for products, are not store specific.|
See Also: https://developers.cart.com