โ† Back to Documentation Home
Whirlcrypt Logo

API Documentation

Complete API reference for secure file sharing with RFC 8188 encryption

๐Ÿ”— Overview

Base URL:

http://localhost:3001/api  # Development
https://your-domain.com/api  # Production

Authentication:

๐Ÿ“ค Upload Endpoints

POST /upload

Upload an encrypted file with metadata. Rate limited to 10 uploads per 15 minutes per IP.

Request Body (multipart/form-data):

  • file - The encrypted file to upload
  • key - 32-character hex-encoded encryption key
  • salt - 32-character hex-encoded salt
  • retentionHours - Optional retention period (default: 24, max: 168)

Response (201):

{
  "id": "uuid-string",
  "downloadUrl": "/api/download/uuid-string",
  "expiresAt": "2025-09-13T10:00:00.000Z"
}

Error Responses:

  • 400 - Bad request (missing file, invalid params)
  • 413 - File too large (>100MB default)
  • 429 - Rate limit exceeded
  • 500 - Upload failed

๐Ÿ“ฅ Download Endpoints

GET /download/{id}

Download and decrypt a file using the provided encryption key.

Headers:

x-encryption-key: 32-character-hex-key

Alternative Query Parameter:

GET /download/{id}?key=hex-encoded-key

Response (200):

  • Content-Type: Original file MIME type
  • Content-Disposition: attachment; filename="original-name.ext"
  • Body: Binary file data (decrypted)

GET /download/{id}/info

Get file metadata without downloading the actual file.

Response (200):

{
  "filename": "document.pdf",
  "size": 1048576,
  "contentType": "application/pdf",
  "uploadDate": "2025-09-12T10:00:00.000Z",
  "expiresAt": "2025-09-13T10:00:00.000Z",
  "downloadCount": 3
}

โš™๏ธ Admin Endpoints

GET /admin/stats

Retrieve current storage statistics and configuration.

Response (200):

{
  "totalFiles": 150,
  "totalSize": 524288000,
  "expiredFiles": 12,
  "config": {
    "maxFileSize": 104857600,
    "defaultRetentionHours": 24,
    "maxRetentionHours": 168,
    "allowedExtensions": null
  }
}

POST /admin/cleanup

Manually trigger cleanup of expired files.

Response (200):

{
  "message": "Cleaned up 12 expired files",
  "cleanedCount": 12
}

GET /admin/config

Get current server configuration.

PUT /admin/config

Update server configuration (runtime only).

Request Body:

{
  "defaultRetentionHours": 48,
  "maxRetentionHours": 336,
  "maxFileSize": 209715200
}

๐Ÿฅ Health Check

GET /health

Check service status and version.

Response (200):

{
  "status": "ok",
  "timestamp": "2025-09-12T10:00:00.000Z",
  "version": "1.0.0"
}

๐Ÿ“Š Rate Limits

Endpoint Limit Window
POST /upload 10 requests 15 minutes
All other endpoints 100 requests 15 minutes
Download endpoints No limit -

๐Ÿ› Error Handling

All error responses follow this format:

{
  "error": "Human-readable error message"
}

Common HTTP Status Codes:

๐Ÿš€ Getting Started

Ready to start using the Whirlcrypt API? Check out: