Using PostPopUp’s API
Introduction: The PostPopup API allows for easy creation of popups and for updating the triggeredAt date/time for any PopUp. This guide will help you get started with the API and understand its key features.
Steps:
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` };
- Obtain API Key:
Common API Endpoints:
- Create a New Popup:
- Endpoint:
POST
https://api.postpopup.com/api/popups/create
- Example:
const createPopup = async () => { const response = await fetch('https://api.postpopup.com/api/popups/create', { method: 'POST', headers, body: JSON.stringify({ domainId: 'your-domain-id', message: 'Your popup message', iconUrl: 'https://example.com/icon.png', expiresAt: '2024-08-11T23:59:59Z',
triggeredAt:
'2024-08-11T23:59:59Z'
source: 'My Website' }) }); const data = await response.json(); console.log(data); };
- Endpoint:
- Create a New Popup:
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.