Webhooks are currently only available to apps and cannot be configured by merchants for their own accounts.
Configure webhook sending
The first step to receiving webhooks is configuring your webhook URL. Once setup, you will then be able to specify the topics to which you’d like to subscribe.- In the Partner Portal, go to Apps.
- Click on the name of the app you want to define a new activity type for.
- Navigate to the Webhooks page for your app.
- Click + Create webhook.
- Enter the webhook details and click Create.
Webhook topics
Webhook topics allow an app to subscribe to specific events that occur in Smile. Below is a list of webhook topics that an app can subscribe to.| Topic | Description |
|---|---|
ping | This topic is used during webhook creation to verify that your webhook endpoint is functioning properly. The data portion of this webhook is an empty object. |
customer/updated | Occurs when a customer is updated (including when a customer is first created). |
Webhook bodies
Webhook bodies (payloads) are in JSON format and have a consistent structure across all topics. They contain the following parameters.| Parameter | Description |
|---|---|
account_id | The ID of the Smile account on which the event occurred. |
data | The specific data pertaining to the webhook topic. For example, the data in a customer/updated webhook will contain a customerobject. |
topic | The webhook topic. Topics contain two components: a subject and a verb separated by a slash (e.g. customer/updated). |
JSON
Customer webhooks
For webhook topics with a “customer” subject (e.g.customer/updated), the data attribute in the webhook body will contain the following parameters.
| Parameter | Description |
|---|---|
customer | An object representing the customer that was updated. See the customer object for the attributes that are included. |
JSON
Verifying webhook signatures
In order to verify that a webhook contains legitimate data, Smile signs the contents of each webhook with asha256 HMAC. Webhooks are signed using the app’s client secret (found in the app’s settings in the Partner Portal), and the following headers must be used to verify the signature of a webhook.
| Header | Description |
|---|---|
Smile-Signature | The HMAC generated by Smile. An app will attempt to compute this signature in order to verify that the webhook is legitimate. |
Smile-Timestamp | The number of seconds since the Unix epoch (UTC). This value is used to prevent replay attacks. |
- Concatenate the
Smile-Timestamp, followed by a period (.), followed by the webhook request body. - Generate a
sha256HMAC using the computed string and the app’s client secret. - Compare the computed HMAC to the value of the
Smile-Signatureheader. - Verify that the timestamp is within 5 minutes of the current time.
Ruby
Responses & retries
A webhook will be considered successfully delivered if the endpoint responds with a2xx HTTP status code within 5 seconds. During periods of high traffic (such as sale seasons or other shopping-focused times of year), apps may receive a high volume of webhooks, so asynchronous webhook processing is highly recommended.
If a response is not received within the allowed time period or a non-200 status code is observed, the webhook send will be considered to have failed.
If a webhook fails to send for any reason, Smile will try to send the webhook again later using an exponential backoff algorithm. If the webhook cannot be sent successfully within a 24 hour period, the webhook will be disabled across all accounts with the app installed.
Permissions
Every webhook topic has corresponding OAuth permissions which determine if a webhook can be sent for a given account. For example, in order to receivecustomer/updated webhooks, the app must be granted the customer:read permission.
It is important to understand that app permissions are granted on a per-account basis. This means that an app is not guaranteed to have the same scope on all of the Smile accounts that it is installed on. As a result, an app will only receive webhooks for the subset of Smile accounts that have granted it the required permissions.
Once a webhook is created via the Partner Portal and at least one user has authorized the app with one of the required permissions, the app will start to receive webhooks.