Configuring Password Protection and Expiration
Confidential pitch decks, time-delimited flash sales, and embargoed announcements require restricted access without complex authentication walls. This guide configures edge-enforced password gates, ISO 8601 expiration timestamps, and click ceilings that automatically disable access at Cloudflare Anycast edge nodes.
Prerequisites
- Workspace permissions:
Owner,Admin, orMemberrole in your Shaf organization. - A destination URL requiring access controls or time bounds.
- A strong passphrase for password-gated deployments.
Implementation Recipe
Configure Password Protection
Protect your short link by supplying a passphrase during creation or updating an existing link:
curl -X POST "https://shaf.app/api/v1/links" \ -H "Authorization: Bearer $SHAF_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/embargoed-press-release", "slug": "confidential-q4", "domain": "shaf.is", "password": "SecurePassphrase2026!" }'- Open the Link Editor modal.
- Expand the Security & Access section.
- Toggle Password Protection to On.
- Enter your passphrase. Shaf hashes the password using SHA-256 before persisting to D1.
Set Expiration Timestamp & Click Limit
Apply automated decommission criteria:
curl -X PATCH "https://shaf.app/api/v1/links/lnk_01j8k9m4" \ -H "Authorization: Bearer $SHAF_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "expiresAt": "2026-12-31T23:59:59Z", "clickLimit": 1000, "expiredUrl": "https://example.com/promotion-ended" }'Parameter Type Behavior expiresAtstring(ISO 8601 UTC)Exact timestamp after which the link ceases resolving. clickLimitintegerMaximum successful redirects permitted before automatic deactivation. expiredUrlstringCustom fallback redirect for visitors attempting to access an expired link. Edge Gate Enforcement
When access criteria fail or expiration triggers:
- Password Protected: Shaf intercepts the redirect and returns an HTTP
200password challenge screen. Validating the passphrase sets an encrypted session cookie and resumes the redirect. - Expired: Shaf halts routing and returns HTTP
302toexpiredUrlor HTTP410 Gone.
- Password Protected: Shaf intercepts the redirect and returns an HTTP
Verification
Test edge gate evaluation using curl:
-
Probe a password-protected link without credentials:
curl -I "https://shaf.is/confidential-q4"Expected output:
HTTP/2 200 OK content-type: text/html; charset=utf-8 x-shaf-gate: password-required -
Submit the password challenge:
curl -i -X POST "https://shaf.is/confidential-q4" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "password=SecurePassphrase2026!"Expected output:
HTTP/2 308 Permanent Redirect location: https://example.com/embargoed-press-release set-cookie: shaf_pass_confidential-q4=...; Path=/; HttpOnly; Secure; SameSite=Lax
Common Gotchas
| Issue / Error | Root Cause | Solution |
|---|---|---|
| Forgotten passphrase | Passwords are saved as one-way SHA-256 hashes and cannot be retrieved. | Open link settings in the dashboard and assign a new passphrase. |
| Premature expiration | Timestamp provided in local timezone rather than UTC. | Ensure ISO 8601 strings terminate with Z (e.g. 2026-12-31T23:59:59Z). |
| Click quota consumed by bots | Search crawlers or social preview bots visited the link. | Shaf’s bot defense engine filters verified automated crawlers from the click tally automatically. |
| Visitor bypassed password gate | Browser cached 308 redirect from before password protection was toggled. | Clear browser cache or test in a Private / Incognito browser session. |