Set Expiry & Access Controls

3 min

Before you start

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

Use cases

Pro tips


← Back to all how-tos