Articles on: Developer Documentation

Webhooks

Webhooks are a powerful tool that enables you to keep track of the subscription events occurring in the Loop system.
This article details the use of Webhooks with Loop and how you can leverage the same for your store.

Contents of the article

- How can Webhooks help?
- How to respond to a Webhook?
- What are Webhook attributes/headers?
- Supported webhooks
- List Webhook topics
- How to subscribe/unsubscribe webhook?
- FAQs
- Need help?


How can webhooks help?

Webhooks help stay in sync with the activities that matter most to you and automate actions based on those events. By subscribing to webhooks, you can receive notifications about specific events and use the data payload from the event to trigger custom logic. Overall, webhooks provide a reliable and efficient way to integrate with the Loop system and streamline your workflow.


How to respond to a webhook?

In order to confirm the receipt of data through your webhook, it is important to send a response with a status code in the 200 range, indicating success. If the response falls outside this range, it will signal that the webhook was not received.

Our system has been designed to include a 5-second time-out period for all webhook requests. If a response is not received within this timeframe, the request is considered to have failed.

To ensure that webhook requests are properly processed, our system will automatically retry failed requests over the next 48 hours. However, if a request continues to fail during each retry attempt, our system will take appropriate action and delete the webhook request.

By implementing these measures, we aim to provide a reliable and efficient webhook service that minimizes any potential disruptions to our client's operations.


What are webhook attributes/headers?

Attributes and headers are two important components of a webhook payload. Attributes are key-value pairs that provide additional information about the event that triggered the webhook.

Following are the Webhook attributes for Loop.

AttributeDescription
idUnique numeric identifier for the webhook.
addressThe URI where the webhook should send the POST request when the event occurs.
topicThe event that will trigger the webhook.
versionThe version of the API used to populate the body of the webhook.



Headers, on the other hand, are pieces of information sent along with the payload to provide additional context or instructions for how the payload should be processed.

Following are the Webhook headers for Loop.

HeaderDescription
X-Loop-Webhook-IdThe unique id to identify duplicate entries
X-Loop-Webhook-Api-VersionAPI version of the payload/webhook
X-Loop-Webhook-TopicTopic of the webhook e.g., 'subscription/cancelled'
X-Loop-Webhook-Created-AtDate time string when the event was created (remains same in every retry)
X-Loop-Webhook-Delivery-AtDate time string when the webhook is being delivered (also can be referred to as the time when it was retried)
X-Loop-Webhook-Retry-CountNumber of retries/tries done



Supported webhooks


Webhook can be created in Loop for the following topics from object types - "Subscription", "Order", "Customer's Payment Method" and "Flows".

Subscription topics


TopicsTrigger Explanation
Subscription/createdThis event will be triggered when a subscription is created.
subscription/pausedThis event will be triggered when a subscription is paused.
subscription/updatedThis event will be triggered when a subscription is updated.
subscription/cancelledThis event will be triggered when a subscription is cancelled.
subscription/resumedThis event will be triggered when a subscription is resumed.
subscription/reactivatedThis event will be triggered when a subscription is reactivated.
subscription/delayedThis event will be triggered when a subscription is delayed.
subscription/rescheduledThis event will be triggered when a subscription is rescheduled.
subscription/expiredThis event will be triggered when a subscription is expired.



Order topics


TopicsTrigger Explanation
order/upcomingTriggered before processing an order.
order/processedTriggered when order is processed.
order/partiallyProcessedTriggered when order is partially processed due to low inventory levels.
order/outOfStockTriggered when order is out of stock.
order/skippedTriggered when customer skipped an order.
order/unskippedTriggered when customer un-skipped an order.
order/paymentFailedTriggered when customer payment on an order is failed.


Customer's Payment Method


TopicsTrigger Explanation
paymentMethod/updateRequestedTriggered when a customer request's payment method update request from Loop.
paymentMethod/updatedTriggered when customer's payment method is updated.
paymentMethod/expiringSoonTriggered when customer payment method is about to expire (3 days, 15 days, 30 days before payment method expiring).


Flows


TopicsTrigger Explanation
flow/completedTriggered when a flow is successfully completed.



List webhook topics


You can list your Webhook topics here

Sample response:

{
  "success": true,
  "message": "Fetched available topics",
  "data": [
    "subscription/created",
    "subscription/paused",
    "subscription/cancelled",
    "subscription/resumed",
    "subscription/reactivated",
    "subscription/expired"
  ]
}



How to subscribe / unsubscribe Webhook ?


How to subscribe to Webhooks?

You can subscribe to a webhook subscription by specifying both an address and a topic.



Sample response of Subscribe Webhook :
{
  "success": true,
  "message": "Successfully subscribed to the topic",
  "data": {
    "uuid": "533690245e3d47a683463304bf319136",
    "topic": "subscription/cancelled",
    "status": "ACTIVE",
    "version": "2022-10",
    "myshopifyDomain": "aug26-v2release.myshopify.com"
  }
}


How to unsubscribe from a Webhook?
You can unsubscribe from a webhook subscription using the Loop webhook subscription id.



Sample response of Unsubscribe Webhook :
{
  "success": true,
  "message": "Successfully unsubscribed from the topic",
  "data": {}
}



FAQs


Q: How will I know that incoming webhooks are sent from Loop?

A: Loop webhook headers will always begin with "X-Loop-Webhook-{{variable_name}}".


Q: Can I use regular HTTP for my webhooks connections?

A: No, you must use a secure HTTPS connection in order to connect to our webhooks.


Need help?


There is no need to worry. We are here to assist you. Please contact us at support@loopwork.co or feel free to reach out to us through the chat by clicking on the support beacon located at the bottom right corner.

Regards,

Loop Subscription Team 🙂

Updated on: 10/07/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!