API Documentation
This documentation provides comprehensive information about the Search and Rescue Droid API endpoints, including authentication, user management, and access control features.
Base URL
All API endpoints are prefixed with:
Currently running in localhost environment
Authentication
The API uses JWT (JSON Web Tokens) for authentication. After signing
in, you'll receive a token that must be included in the
Authorization header of subsequent requests as
Bearer {token}.
Register a new user account. After registration, an OTP will be sent to the provided email address for verification. The OTP is valid for 10 minutes.
Request Body
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| username | string | Yes | Unique username for the account |
| string | Yes | Valid email address for verification | |
| password | string | Yes | Password (minimum 6 characters) |
| role | array[string] | No | User roles: admin, user, common. Default: common |
Response
Authenticate a user and receive a JWT token for authorization. Email must be verified before login is allowed.
Request Body
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| username | string | Yes | Registered username |
| password | string | Yes | User password |
Response
Refresh the JWT access token using a valid refresh token. This is useful for maintaining user sessions without requiring them to log in again.
Verify a user's email address using the OTP sent during registration. OTP is valid for 10 minutes.
Request URL
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Email address to verify | |
| otp | string | Yes | 6-digit OTP code sent to email |
Response
Resend a new OTP to the user's email address. Useful when the original OTP has expired or was not received.
Request URL
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Email address to resend OTP to |
Response
Initiate password reset process by sending an OTP to the user's email address. The OTP is valid for 10 minutes.
Request URL
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Email address for password reset |
Response
Reset user password using the OTP received from the forgot password process.
Request Body
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | Email address of the user | |
| otpCode | string | Yes | 6-digit OTP code received via email |
| newPassword | string | Yes | New password for the account |
Response
Missions
These endpoints manage search and rescue mission operations. All mission endpoints require
JWT authentication in the Authorization header as Bearer {token}.
Mission operations include creating, retrieving, updating, and deleting mission records with the following details:
- spotName: Location name where the incident occurred
- noOfPersons: Number of persons involved in the incident
- contractTeamName: Name of the rescue team assigned
- healthStatus: Condition of the victims (e.g., Critical, Stable)
- timeOfEvent: Timestamp of when the incident occurred (ISO 8601 format)
- location: Geographic coordinates of the incident
Retrieve all mission records. Requires ADMIN or USER role.
Headers
Response
Create a new mission record. Requires ADMIN or USER role. All fields are required and validated.
Headers
Request Body
Response
Update an existing mission record. Requires ADMIN or USER role. Must include the mission ID in the request body.
Headers
Request Body
Response
Permanently delete a mission record. Requires ADMIN role.
Headers
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | MongoDB ObjectId of the mission to delete |
Example Request
Response
Test Endpoints
These endpoints demonstrate role-based access control and require
appropriate JWT tokens in the Authorization header as
Bearer {token}.
Accessible to all users, no authentication required. This endpoint can be used to test basic API connectivity.
Response
Requires USER or ADMIN role. This endpoint tests user-level authorization.
Headers
Response
Requires ADMIN role. This endpoint tests admin-level authorization.
Headers
Response
Requires COMMON, USER, or ADMIN role. This endpoint tests basic authenticated access.
Headers
Response
Common Error Responses
HTTP Status Codes
| Status Code | Meaning | Description |
|---|---|---|
| 200 | OK | Request successful |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | Invalid request parameters |
| 401 | Unauthorized | Authentication required or failed |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource not found |
| 500 | Internal Server Error | Server error occurred |