How-tos
Set Expiry & Access Controls
3 min
Before you start
- Your
OGLI_API_KEY
ready
- Know when you want the link to expire
1) Create a link with expiry date
# cURL - Link expires on New Year's Day 2025
curl -X POST https://api.ogli.sh/link \
-H "Authorization: Bearer $OGLI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"targetUrl": "https://yoursite.com/special-offer",
"title": "Limited Time Offer",
"description": "50% off - expires soon!",
"expiresAt": "2025-01-01T00:00:00Z"
}'
// Node.js - Link expires in 7 days
const expiryDate = new Date();
expiryDate.setDate(expiryDate.getDate() + 7);
const response = await fetch("https://api.ogli.sh/link", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.OGLI_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
targetUrl: "https://yoursite.com/campaign",
title: "Flash Sale",
description: "This week only!",
expiresAt: expiryDate.toISOString()
})
});
2) Temporarily disable a link
# Disable a link (can be re-enabled later)
curl -X PATCH https://api.ogli.sh/link/YOUR_LINK_ID \
-H "Authorization: Bearer $OGLI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"isActive": false
}'
// Re-enable the link
await fetch(`https://api.ogli.sh/link/${linkId}`, {
method: "PATCH",
headers: {
"Authorization": `Bearer ${process.env.OGLI_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
isActive: true
})
});
3) What happens when a link expires or is disabled
- Expired links: Show a "Link expired" message
- Disabled links: Show a "Link temporarily unavailable" message
- Social previews: Still work normally
- Analytics: Still track attempted visits
Use cases
- Limited offers: Auto-expire when sale ends
- Event registration: Close after event starts
- Content updates: Disable while updating landing page
- Security: Quickly disable if link is compromised
- A/B testing: Temporarily disable losing variants
Pro tips
- Set timezone: Use UTC (ends with Z) for consistency
- Soft launch: Create disabled, enable when ready
- Monitor expiry: Check dashboard before links expire
- Extend if needed: Update
expiresAt
to extend
← Back to all how-tos