Overview
Link expiration allows you to control how long links remain accessible. The Secure Link API supports two types of expiration: time-based (usingexpiresAt) and usage-based (using maxViews).
Time-Based Expiration
Set a specific date and time when the link should expire using theexpiresAt parameter.
Creating Links with Expiration
- URL Links
- File Uploads
Date Format Requirements
TheexpiresAt parameter accepts ISO 8601 format with timezone offset:
Always include the timezone offset (e.g.,
+00:00 for UTC, +05:30 for IST). This ensures consistent expiration regardless of server timezone.Valid Examples
Invalid Examples
Usage-Based Expiration
Limit how many times a link can be accessed using themaxViews parameter.
Creating Links with View Limits
View Count Behavior
Each successful access increments the view count:When
maxViews is reached, the link is automatically marked as expired. Future access attempts will receive a 410 Gone response.View Count Implementation
From the source code (ResolveLinkServiceImpl:78-82):Combining Expiration Methods
You can use both time-based and usage-based expiration together:- The date reaches June 30, 2026 at 23:59:59 UTC, OR
- The link is accessed 100 times
Expiration Validation
The API performs several checks when accessing a link:Validation Order
From ResolveLinkServiceImpl:71-85, checks occur in this order:- Revocation check - Has the link been manually revoked?
- Time expiration check - Has
expiresAtpassed? - View limit check - Has
maxViewsbeen reached? - Active status check - Is the link still active?
- Password check - Does the password match (if protected)?
Expired Link Response
When accessing an expired link:View Limit Reached Response
When the view limit has been exceeded:Both time expiration and view limit expiration return the same 410 Gone status. Check audit logs for specific expiration reasons.
Common Expiration Patterns
Short-Term Sharing (24 hours)
Campaign Links (end date)
Limited Distribution (view count)
Exclusive Access (both limits)
Automatic Expiration Process
The API includes a scheduled expiration service that automatically marks expired links:- Runs periodically (configured via cron expression)
- Finds all links where
expiresAt < currentTime - Marks them as expired in the database
- Prevents access to expired links
Best Practices
Set reasonable expiration times
Set reasonable expiration times
Consider your use case:
- Temporary shares: 1-7 days
- Event-based: End date of the event
- Sensitive data: Shortest possible duration
- General content: 30-90 days
Always set expiration for uploads
Always set expiration for uploads
File uploads consume storage. Always set an
expiresAt date to prevent indefinite storage consumption.Use maxViews for distribution control
Use maxViews for distribution control
When you need to limit how widely content is shared, use
maxViews rather than relying solely on time expiration.Combine with password protection
Combine with password protection
For sensitive content, use expiration AND password protection for defense in depth.
Monitor expiration patterns
Monitor expiration patterns
Track how often links expire due to time vs. view limits to optimize your expiration strategy.
Communicate expiration to users
Communicate expiration to users
Let users know when links will expire so they can plan accordingly.
Validation Errors
Future Date Validation
Positive Integer Validation
Next Steps
Revocation
Manually revoke links before they expire
Password Protection
Add password protection to expiring links
Creating Links
Learn all link creation options
Access Summary
Monitor link access and expiration patterns
