Updating a PopUp's triggeredAt Date/Time with the API
Introduction: The PostPopup API allows for easy creation of popups and for updating the triggeredAt
date/time for any popup, this allow you to show fresh and relevant content to your users. This guide will help you understand how to update the triggeredAt
timestamp via a simple API call and leverage this feature in applications that support webhooks, such as Shopify.
Steps:
1. API Authentication:
Obtain API Key:
- Log in to your PostPopup account.
- On the dashboard, you will find your API key at the bottom of the page.
Authenticate Requests:
- Include your API key in the headers of your API requests as a Bearer token.
- Example:
const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer YOUR_API_KEY` };
Update the triggeredAt Date/Time:
- Endpoint:
POST https://api.postpopup.com/api/popups/{id}/trigger
- This endpoint does not require a request body. Simply call the API URL to update the
triggeredAt
timestamp to the current date and time. - Example:
const updateTriggeredAt = async (popupId) => { const response = await fetch(`https://api.postpopup.com/api/popups/${popupId}/trigger`, { method: 'POST', headers }); };
3. Using Webhooks with PostPopup: Integrate the PostPopup API with Webhooks to automate the updating of the triggeredAt
timestamp based on events in your applications. For example, you can configure a webhook in Shopify to call the PostPopup API whenever an order is made, thus updating the triggeredAt
timestamp for a specific popup.
Example Use Case: Shopify Integration:
Create a webhook in Shopify:
- Go to your Shopify admin panel.
- Navigate to "Settings" > "Notifications".
- Create a new webhook and set the event to "Order Creation".
- Set the webhook URL to
https://api.postpopup.com/api/popups/{id}/update-triggeredAt
.
API Call:
- When an order is created in Shopify, the webhook will trigger, calling the PostPopup API and updating the
triggeredAt
timestamp for the specified popup.
- When an order is created in Shopify, the webhook will trigger, calling the PostPopup API and updating the
Conclusion: Utilizing the PostPopup API provides greater flexibility and control over your popup campaigns. Integrating the API into your workflow allows you to create popups based on events in your platform and update the triggeredAt
timestamp dynamically using webhooks. This ensures your popups are always relevant and timely, enhancing user engagement and experience.