Skip to main content

Upload Document

Upload a document file to an enrollment. Supports PDF and image files (PNG, JPG, JPEG).

Path Parameters

enrollment_id
uuid
required
Unique identifier of the enrollment

Form Data Parameters

file
file
required
The document file to upload. Supported formats:
  • PDF (.pdf)
  • PNG (.png)
  • JPEG (.jpg, .jpeg)
Maximum file size: 10 MB
document_type
string
required
Type of document being uploaded. Examples:
  • birth_certificate - Birth certificate
  • id_card - Identity card
  • health_certificate - Health/vaccination certificate
  • previous_grades - Academic records from previous school
  • photo - Student photo
  • Custom types are supported
document_version
string
Version identifier for the document (e.g., “1”, “2”, “2024”)

Response

message
string
Success message
document
object
The uploaded document object
enrollment_id
string
The enrollment ID (as string)

Upload Examples

curl -X POST "https://api.athena-erp.com/api/enrollments/a1b2c3d4-e5f6-7890-abcd-ef1234567890/documents" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -F "file=@/path/to/birth_certificate.pdf" \
  -F "document_type=birth_certificate" \
  -F "document_version=1"
{
  "message": "Documento subido",
  "document": {
    "id": "e5f6a7b8-c9d0-1234-efab-567890123456",
    "school_id": "550e8400-e29b-41d4-a716-446655440000",
    "enrollment_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "document_type": "birth_certificate",
    "status": "uploaded",
    "r2_object_key": "550e8400-e29b-41d4-a716-446655440000/students/b2c3d4e5-f6a7-8901-bcde-f12345678901/enrollments/a1b2c3d4-e5f6-7890-abcd-ef1234567890/birth_certificate.pdf",
    "file_name": "birth_certificate.pdf",
    "uploaded_at": "2024-01-16T09:15:00Z",
    "validated_at": null,
    "validated_by": null,
    "accepted_by_guardian_id": null,
    "document_version": "1",
    "metadata_json": {}
  },
  "enrollment_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Get Document Content

Retrieve the actual file content of a document. This is an authenticated proxy to the file storage.

Path Parameters

enrollment_id
uuid
required
Unique identifier of the enrollment

Query Parameters

document_type
string
required
Type of document to retrieve (e.g., “birth_certificate”, “id_card”)
mode
string
default:"inline"
How to serve the file:
  • inline - Display in browser (default)
  • download - Force download with Content-Disposition header

Response

Returns the raw file content with appropriate headers:
  • Content-Type: Based on file type (e.g., application/pdf, image/jpeg)
  • Content-Disposition: inline or attachment based on mode parameter
  • Cache-Control: no-store to prevent caching of sensitive documents
  • X-Content-Type-Options: nosniff for security
  • Content-Security-Policy: sandbox for additional security

Retrieval Examples

curl -X GET "https://api.athena-erp.com/api/enrollments/a1b2c3d4-e5f6-7890-abcd-ef1234567890/documents/content?document_type=birth_certificate&mode=inline" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
[Binary file content with appropriate Content-Type header]

Document Upload Behavior

  • If a document of the same document_type already exists for the enrollment, it will be replaced (updated)
  • The old file will be overwritten with the new upload
  • The uploaded_at timestamp will be updated to the current time
  • The status will be reset to "uploaded"
  • This allows for document corrections or updates without creating duplicates

File Validation

  • Allowed file types: PDF, PNG, JPG, JPEG
  • Maximum file size: 10 MB
  • PDF validation: Files with .pdf extension are validated to have correct PDF magic bytes
  • File names are sanitized and normalized for safe storage

Storage Structure

Documents are stored with the following path structure:
{school_id}/students/{student_id}/enrollments/{enrollment_id}/{document_type}.{ext}
This ensures:
  • Organized storage by school and student
  • Easy identification of document ownership
  • Automatic file replacement for same document types

Permissions Required

Upload Documents

  • write:enrollment
  • write:all

Retrieve Documents

  • read:enrollment
  • read:all

Build docs developers (and LLMs) love