⏳ Time Capsule

API Reference

Complete API endpoints documentation

API Reference

Complete reference for all Time Capsule endpoints.

Authentication Endpoints

Register User

POST /register/

Form Data:

  • username - Unique username
  • email - User email address
  • password1 - Password
  • password2 - Password confirmation

Response: Redirects to login page on success


Login

POST /login/

Form Data:

  • username - Username
  • password - Password

Response: Redirects to dashboard on success

Uses Django's built-in authentication system


Capsule Endpoints

Dashboard

GET /dashboard/

Authentication: Required

Response: HTML page with all user's capsules

Data Returned:

  • List of capsules with status (Locked/Unlocked)
  • Creation dates
  • Unlock dates

Create Capsule

GET /capsule_create/
POST /capsule_create/

Authentication: Required

Form Data:

  • title - Capsule title (max 255 chars)
  • content - Text content
  • unlock_date - DateTime when capsule unlocks
  • email - Recipient email address
  • file - Image file (optional)

Response: Redirects to dashboard on success

Side Effects:

  • Creates Capsule record
  • Creates Recipient record
  • Uploads image (if provided)
  • Schedules email for unlock date

View Capsule Details

GET /capsule_detail/<id>/

Authentication: Required

Parameters:

  • id - Capsule ID

Response: HTML page with capsule details

Data Shown:

  • Title and content
  • Status (Locked/Unlocked)
  • Creation and unlock dates
  • Recipient email
  • Attached image (if any)

Users can only view their own capsules


Delete Capsule

POST /capsule_delete/<id>/

Authentication: Required

Parameters:

  • id - Capsule ID

Response: Redirects to dashboard

Side Effects:

  • Deletes capsule
  • Deletes associated images
  • Deletes recipient records

Email Endpoints

Send Email (Manual)

GET /send_email/<id>/

Authentication: Admin only

Parameters:

  • id - Capsule ID

Response: Redirects to capsule detail page

Side Effects:

  • Sends email to recipient immediately
  • Uses custom HTML template

This endpoint is for admin testing and manual sends


Test Email

GET /test-email/
POST /test-email/

Authentication: Admin only

Form Data:

  • email - Test recipient email

Response: Sends test email with sample capsule content


Database Models

Capsule

{
  "id": int,
  "user": ForeignKey(User),
  "title": str (max 255),
  "content": str,
  "created_at": datetime,
  "unlock_date": datetime
}

CapsuleImage

{
  "id": int,
  "capsule": ForeignKey(Capsule),
  "file": FileField
}

Recipient

{
  "id": int,
  "capsule": ForeignKey(Capsule),
  "email": str,
  "sent_at": datetime (nullable)
}

Status Codes

  • 200 - Success
  • 302 - Redirect (after successful form submission)
  • 403 - Forbidden (not authenticated or not owner)
  • 404 - Not found (capsule doesn't exist)

Error Handling

All forms include validation:

  • Required fields checked
  • Email format validated
  • Date/time format validated
  • File type restrictions for images

Errors are displayed using Django messages framework.