# GetSafeDocs API Documentation Welcome to the GetSafeDocs API! This documentation covers all available endpoints for secure document sharing, messaging, tracking, and more. --- ## Authentication ### Register - **Endpoint:** `POST /api/register.php` - **Body (JSON):** `{ "email": "user@example.com", "password": "yourpassword" }` - **Response:** `{ "success": true, "account_id": 123 }` or `{ "error": "..." }` ### Login - **Endpoint:** `POST /api/login.php` - **Body (JSON):** `{ "email": "user@example.com", "password": "yourpassword" }` - **Response:** `{ "success": true, "account_id": 123 }` or `{ "error": "..." }` ### Logout - **Endpoint:** `POST /api/logout.php` - **Response:** `{ "success": true, "message": "Logged out successfully" }` ### Refresh Session - **Endpoint:** `POST /api/refresh_token.php` - **Response:** `{ "success": true, "account_id": 123 }` or `{ "error": "Not authenticated" }` --- ## Messages ### Send Message - **Endpoint:** `POST /api/send_message.php` - **Content-Type:** `multipart/form-data` - **Fields:** - `recipient` (string, required) - `subject` (string, required) - `body` (string, required) - `attachments[]` (file, optional, multiple allowed) - **Response:** `{ "success": true, "message_id": 123 }` or `{ "error": "..." }` ### List Sent Messages - **Endpoint:** `GET /api/list_messages.php?limit=20&offset=0` - **Response:** ``` { "success": true, "messages": [ { "message_id": 123, "subject": "Subject", "created_at": "...", "status": "sent", "recipients": "..." } ], "total": 42, "limit": 20, "offset": 0 } ``` ### List Received Messages - **Endpoint:** `GET /api/list_received_messages.php?limit=20&offset=0` - **Response:** ``` { "success": true, "messages": [ { "message_id": 456, "subject": "Subject", "created_at": "...", "status": "sent", "sender_email": "..." } ], "total": 42, "limit": 20, "offset": 0 } ``` ### View Message Details - **Endpoint:** `GET /api/message_details.php?message_id=123` - **Response:** ``` { "success": true, "message": { "message_id": 123, "subject": "...", "body": "...", "created_at": "...", "status": "...", "sender_email": "...", "recipients": ["..."], "attachments": [ { "file_id": 789, "file_name": "..." } ] } } ``` ### Delete Message - **Endpoint:** `POST /api/delete_message.php` - **Body (JSON):** `{ "message_id": 123 }` - **Response:** `{ "success": true }` or `{ "error": "..." }` --- ## Attachments ### Download Attachment - **Endpoint:** `GET /api/download_attachment.php?file_id=789` - **Response:** File download (if authorized) or JSON error --- ## Tracking ### Message Tracking - **Endpoint:** `GET /api/message_tracking.php?message_id=123` - **Response:** ``` { "success": true, "message_id": 123, "subject": "...", "created_at": "...", "tracking": [ { "activity_type": "message_sent", "activity_timestamp": "...", "ip_address": "...", "user_agent": "...", "recipient_email": "..." } ] } ``` --- ## Replies ### Add Reply - **Endpoint:** `POST /api/add_reply.php` - **Body (JSON):** `{ "message_id": 123, "reply_text": "...", "parent_reply_id": 5 }` - **Response:** `{ "success": true, "reply_id": 42 }` or `{ "error": "..." }` ### List Replies - **Endpoint:** `GET /api/list_replies.php?message_id=123` - **Response:** ``` { "success": true, "replies": [ { "reply_id": 42, "message_id": 123, "recipient_id": 7, "reply_text": "...", "created_at": "...", "is_read": 0, "parent_reply_id": null, "is_sender_reply": 1, "viewed_at": null } ] } ``` ### Mark Reply as Read - **Endpoint:** `POST /api/mark_reply_read.php` - **Body (JSON):** `{ "reply_id": 42 }` - **Response:** `{ "success": true }` or `{ "success": true, "already_read": true }` --- ## Authentication & Authorization - All endpoints require the user to be authenticated (session-based, via login/register endpoints). - Only authorized users (sender or recipient) can access, modify, or delete messages, attachments, and replies. --- ## Error Handling - All errors are returned as JSON: `{ "error": "Error message" }` - HTTP status codes are set appropriately (400, 401, 403, 404, 405, 500) --- ## Example Usage - Use tools like Postman or curl to interact with the API. - For file uploads, use `multipart/form-data`. - For JSON requests, set `Content-Type: application/json`. --- For more information, contact support at [GetSafeDocs](mailto:support@getsafedocs.com).