← Back to Home

API Documentation

Authenticated Lockers API

Access your own lockers with full content using API key authentication.

Endpoint

GET /api/v1/lockers

This endpoint returns all active lockers for the authenticated user with full content including destination URLs and display text.

Authentication

This endpoint requires API key authentication. Include your API key in the Authorization header:

Required Header
Authorization: Bearer sk_your_api_key_here

Generate your API key from the dashboard settings.

Parameters

ParameterTypeRequiredDescription
typestringNoFilter by unlock type: "redirect" or "text" (query parameter)

Request Example

curl -H "Authorization: Bearer sk_your_api_key" \
    https://socialunlocks.com/api/v1/lockers

curl -H "Authorization: Bearer sk_your_api_key" \
    https://socialunlocks.com/api/v1/lockers?type=redirect

curl -H "Authorization: Bearer sk_your_api_key" \
    https://socialunlocks.com/api/v1/lockers?type=text

Replace "sk_your_api_key" with your actual API key from the dashboard. Add ?type=redirect or ?type=text to filter by unlock type.

Response Schema

Success Response
{
  "lockers": [
    {
      "id": "uuid-string",
      "title": "Premium Content Access",
      "description": "Unlock premium content by completing tasks",
      "slug": "premium-content-access",
      "thumbnail": "https://example.com/image.jpg",
      "unlockType": "redirect",
      "destination": "https://example.com/premium-content",
      "content": null,
      "unlockCount": 42
    },
    {
      "id": "another-uuid",
      "title": "Display Text Locker",
      "description": "Shows important information",
      "slug": "display-text-locker",
      "thumbnail": "https://example.com/image2.jpg",
      "unlockType": "text",
      "destination": null,
      "content": "This is the important information to display",
      "unlockCount": 15
    }
  ]
}

Response Fields

FieldTypeDescription
idstringUnique identifier for the locker
titlestringTitle of the locker
descriptionstringDescription of the locker content
slugstringURL-friendly identifier
thumbnailstringURL to the locker thumbnail image
unlockTypestringType of unlock: "redirect" or "text"
destinationstring | nullRedirect URL (only for redirect type)
contentstring | nullDisplay text content (only for text type)
unlockCountnumberNumber of times this locker has been unlocked

Status Codes

200Success- Request completed successfully
401Unauthorized- Invalid or missing API key
500Internal Server Error- Server error occurred

Important Notes

  • Authentication required: API key must be included in Authorization header
  • Own lockers only: Returns only lockers created by the authenticated user
  • Full content: Includes destination URLs and display text (not available in public API)
  • Active lockers only: Returns only lockers with status "active"
  • Excludes key system: Does not return lockers with unlockType "key"
  • Ordered by date: Results are ordered by creation date (newest first)

Example Integration

JavaScript Example
async function getMyLockers(apiKey, type = null) {
  try {
    let url = '/api/v1/lockers';
    if (type) {
      url += `?type=${type}`;
    }
    const response = await fetch(url, {
      headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
      }
    });
    
    if (response.ok) {
      const data = await response.json();
      return data.lockers;
    } else {
      console.error('Failed to fetch lockers');
      return [];
    }
  } catch (error) {
    console.error('Error:', error);
    return [];
  }
}

Genarating API Keys

To use this endpoint, you need to generate an API key from your dashboard:

  1. Go to your dashboard settings
  2. Navigate to the "API" section
  3. Click "Generate API Key" if you don't have one
  4. Copy your API key (starts with "sk_")
  5. Use the key in the Authorization header as shown in the examples above