Skip to main content

Overview

Password protection adds an extra layer of security to your shortened URLs. Users must enter the correct password before being redirected to the destination.

Use Cases

Private Content

Share confidential documents or internal resources

Exclusive Access

Provide VIP or early access to select users

Event Registration

Control access to event materials

Beta Testing

Limit access to beta features or products

Creating Password-Protected URLs

const response = await axios.post('https://snip.sa/api/urls', {
  originalUrl: 'https://example.com/private-content',
  customCode: 'private-doc',
  title: 'Confidential Document',
  password: 'SecurePass123!',
  description: 'Internal use only'
}, {
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your_api_key_here'
  }
});

Password Requirements

Passwords must meet these requirements:
  • Minimum 8 characters
  • At least one uppercase letter
  • At least one lowercase letter
  • At least one number
  • Special characters recommended

User Experience

When users visit a password-protected URL:
  1. They see a password prompt page
  2. Enter the password
  3. If correct, they’re redirected to the destination
  4. If incorrect, they see an error message

Updating Password

Change the password for an existing URL:
const response = await axios.put(
  'https://snip.sa/api/urls/507f1f77bcf86cd799439011',
  {
    password: 'NewSecurePass456!'
  },
  {
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': 'your_api_key_here'
    }
  }
);

Removing Password Protection

Set password to null to remove protection:
const response = await axios.put(
  'https://snip.sa/api/urls/507f1f77bcf86cd799439011',
  {
    password: null
  },
  {
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': 'your_api_key_here'
    }
  }
);

Combining with Other Features

Password + Expiration

{
  originalUrl: 'https://example.com/limited-offer',
  password: 'LimitedOffer2024',
  expiresAt: '2024-12-31T23:59:59Z',
  title: 'Limited Time Offer'
}

Password + Click Limit

{
  originalUrl: 'https://example.com/exclusive',
  password: 'VIP2024',
  restrictions: {
    maxClicks: 100
  },
  title: 'VIP Access - Limited to 100 users'
}

Password + Geographic Restrictions

{
  originalUrl: 'https://example.com/regional-content',
  password: 'Regional2024',
  restrictions: {
    allowedCountries: ['US', 'CA', 'GB']
  },
  title: 'Regional Content'
}

Best Practices

  • Avoid common words or patterns
  • Use a mix of characters
  • Consider using a password generator
  • Don’t reuse passwords across URLs
  • Share passwords through secure channels
  • Don’t include password in the same message as the link
  • Use encrypted messaging apps
  • Consider time-limited passwords
  • Change passwords periodically
  • Update passwords if compromised
  • Use expiration dates for time-sensitive content
  • Track click analytics
  • Monitor for unusual access patterns
  • Set up alerts for high traffic

Analytics for Protected URLs

Password-protected URLs still track analytics:
const analytics = await axios.get(
  'https://snip.sa/api/analytics/507f1f77bcf86cd799439011',
  {
    headers: { 'X-API-Key': 'your_api_key_here' }
  }
);

// Track successful password entries
console.log('Successful Access:', analytics.data.data.totalClicks);
Failed password attempts are not counted in click analytics, only successful accesses.

Example: Event Access System

class EventAccessManager {
  constructor(apiKey) {
    this.apiKey = apiKey;
  }

  async createEventAccess(eventName, eventUrl, attendeePassword) {
    const response = await axios.post('https://snip.sa/api/urls', {
      originalUrl: eventUrl,
      customCode: eventName.toLowerCase().replace(/\s+/g, '-'),
      title: `${eventName} - Attendee Access`,
      password: attendeePassword,
      expiresAt: this.getEventEndDate(),
      restrictions: {
        maxClicks: 500  // Max attendees
      },
      tags: ['event', 'private']
    }, {
      headers: {
        'Content-Type': 'application/json',
        'X-API-Key': this.apiKey
      }
    });

    return response.data;
  }

  getEventEndDate() {
    const date = new Date();
    date.setDate(date.getDate() + 7);  // Event lasts 7 days
    return date.toISOString();
  }
}

// Usage
const manager = new EventAccessManager('your_api_key');
const eventAccess = await manager.createEventAccess(
  'Annual Conference 2024',
  'https://example.com/conference-materials',
  'Conference2024!'
);