REST /api/v1/attachments 6 endpoints
GET /api/v1/attachments/api/v1/attachments

List all attachments, optionally filtered by activity. Delegates to getAttachmentsForActivity() when activity_id is provided.

Public

Response Example

{
  "data": [
    {
      "id": "att_7f3a9c12",
      "activity_id": "act_4b2e1f89",
      "org_id": "org_abc123",
      "file_name": "session_notes.pdf",
      "file_size": 204800,
      "content_type": "application/pdf",
      "storage_path": "org_abc123/activities/act_4b2e1f89/session_notes.pdf",
      "uploaded_by": "usr_9d5c3a71",
      "created_at": "2026-03-15T09:12:34Z",
      "updated_at": "2026-03-15T09:12:34Z"
    },
    {
      "id": "att_2c8d4e77",
      "activity_id": "act_4b2e1f89",
      "org_id": "org_abc123",
      "file_name": "progress_photo.jpg",
      "file_size": 1572864,
      "content_type": "image/jpeg",
      "storage_path": "org_abc123/activities/act_4b2e1f89/progress_photo.jpg",
      "uploaded_by": "usr_9d5c3a71",
      "created_at": "2026-03-18T11:45:00Z",
      "updated_at": "2026-03-18T11:45:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 2
  }
}
GET /api/v1/attachments/api/v1/attachments/:id

Get a single attachment record by ID.

Public

Response Example

{
  "id": "att_7f3a9c12",
  "activity_id": "act_4b2e1f89",
  "org_id": "org_abc123",
  "file_name": "session_notes.pdf",
  "file_size": 204800,
  "content_type": "application/pdf",
  "storage_path": "org_abc123/activities/act_4b2e1f89/session_notes.pdf",
  "uploaded_by": "usr_9d5c3a71",
  "created_at": "2026-03-15T09:12:34Z",
  "updated_at": "2026-03-15T09:12:34Z"
}
POST /api/v1/attachments/api/v1/attachments

Upload a new file attachment for an activity. Calls uploadAttachment(activityId, orgId, file). Content-Type must be multipart/form-data.

Public

Request Example

{
  "activity_id": "act_4b2e1f89",
  "org_id": "org_abc123",
  "file": "<binary — multipart field named 'file', e.g. progress_report.docx, 51200 bytes>"
}

Response Example

{
  "id": "att_8e2b4d56",
  "activity_id": "act_4b2e1f89",
  "org_id": "org_abc123",
  "file_name": "progress_report.docx",
  "file_size": 51200,
  "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  "storage_path": "org_abc123/activities/act_4b2e1f89/progress_report.docx",
  "uploaded_by": "usr_9d5c3a71",
  "created_at": "2026-03-26T14:23:45Z",
  "updated_at": "2026-03-26T14:23:45Z"
}
PUT /api/v1/attachments/api/v1/attachments/:id

Update attachment metadata such as file_name. Does not re-upload the binary.

Public

Request Example

{
  "file_name": "session_notes_final.pdf"
}

Response Example

{
  "id": "att_7f3a9c12",
  "activity_id": "act_4b2e1f89",
  "org_id": "org_abc123",
  "file_name": "session_notes_final.pdf",
  "file_size": 204800,
  "content_type": "application/pdf",
  "storage_path": "org_abc123/activities/act_4b2e1f89/session_notes.pdf",
  "uploaded_by": "usr_9d5c3a71",
  "created_at": "2026-03-15T09:12:34Z",
  "updated_at": "2026-03-26T15:01:12Z"
}
DELETE /api/v1/attachments/api/v1/attachments/:id

Delete an attachment by ID. Calls deleteAttachment(attachmentId), removes from storage and database.

Public

Response Example

{
  "success": true,
  "deleted_id": "att_7f3a9c12"
}
POST /api/v1/attachments/api/v1/attachments/validate

Pre-flight file validation before upload. Calls validateFile(file). Returns allowed types and size limits.

Public

Request Example

{
  "file_name": "scan.heic",
  "file_size": 18874368,
  "content_type": "image/heic"
}

Response Example

{
  "valid": false,
  "errors": [
    "Unsupported file type: image/heic. Allowed: application/pdf, image/jpeg, image/png, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document",
    "File size 18874368 bytes exceeds maximum of 10485760 bytes (10 MB)"
  ],
  "allowed_content_types": [
    "application/pdf",
    "image/jpeg",
    "image/png",
    "application/msword",
    "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
  ],
  "max_file_size_bytes": 10485760
}

Additional Metadata

{
  "contract_summary": {
    "total_contracts": 410,
    "total_endpoints": 2416,
    "api_styles_used": [
      "rest"
    ]
  },
  "generated_at": "2026-03-26T06:55:53.316Z"
}