Skip to main content

Users API

The Users API handles user profiles, authentication, verification, and preferences within the PRAYSAP platform.

Endpoints Overview

MethodEndpointDescription
POST/api/users/upsertCreate or update user profile
GET/api/users/{userId}Get user profile
DELETE/api/users/{userId}Delete user profile
POST/api/users/{userId}/verify-shahadaVerify Shahada declaration
PATCH/api/users/{userId}/privacyUpdate privacy settings
GET/api/users/{userId}/waitlistCheck waitlist status
POST/api/users/{userId}/waitlist/addAdd user to waitlist
GET/api/users/{userId}/prayers/joinedList joined prayers
GET/api/users/{userId}/prayers/hostedList hosted prayers
GET/api/users/{userId}/notificationsGet notification preferences
PUT/api/users/{userId}/notificationsUpdate notification preferences
GET/api/users/{userId}/profile-statusGet profile completion status

Create or Update User Profile

Create a new user profile or update an existing one.

Endpoint: POST /api/users/upsert

Authentication: Required

Request Body

{
"userId": "user123@example.com",
"fullname": "Ahmed Ibrahim",
"email": "user123@example.com",
"phonenumber": "+1234567890",
"bio": "Software developer and practicing Muslim",
"image": "https://example.com/profile.jpg",
"languages": ["English", "Arabic"],
"gender": "male",
"location": {
"type": "Point",
"coordinates": [77.5946, 12.9716],
"address": "Bangalore, India"
}
}

Request Parameters

FieldTypeRequiredDescription
userIdstringYesUnique user identifier
fullnamestringYesFull name of the user
emailstringYesValid email address
phonenumberstringNoPhone number with country code
biostringNoUser biography (max 500 characters)
imagestringNoProfile image URL
languagesarrayNoArray of supported languages
genderstringNoGender: "male", "female", "other"
locationobjectNoGeoJSON Point with address

Response

Status: 200 OK

{
"userId": "user123@example.com",
"fullname": "Ahmed Ibrahim",
"email": "user123@example.com",
"phonenumber": "+1234567890",
"bio": "Software developer and practicing Muslim",
"image": "https://example.com/profile.jpg",
"languages": ["English", "Arabic"],
"location": {
"current": {
"type": "Point",
"coordinates": [77.5946, 12.9716]
},
"address": "Bangalore, India",
"lastUpdated": "2025-09-14T22:42:05.778Z",
"accuracy": 10
},
"verified": false,
"privacy": {
"showEmail": false,
"showLocation": false,
"showStats": true,
"allowMessages": true,
"profileVisibility": "public"
},
"createdAt": "2025-09-14T22:42:05.778Z",
"updatedAt": "2025-09-14T22:42:05.778Z"
}

Status: 400 Bad Request

{
"error": {
"message": "Invalid input data",
"code": "VALIDATION_ERROR",
"details": {
"email": "Invalid email format",
"fullname": "Name is required"
}
}
}

Get User Profile

Retrieve a user profile by userId.

Endpoint: GET /api/users/{userId}

Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Response

Status: 200 OK

{
"userId": "user123@example.com",
"fullname": "Ahmed Ibrahim",
"email": "user123@example.com",
"phonenumber": "+1234567890",
"bio": "Software developer and practicing Muslim",
"image": "https://example.com/profile.jpg",
"languages": ["English", "Arabic"],
"location": {
"current": {
"type": "Point",
"coordinates": [77.5946, 12.9716]
},
"address": "Bangalore, India",
"lastUpdated": "2025-09-14T22:42:05.779Z",
"accuracy": 10
},
"verified": true,
"shahadaDate": "2025-09-10T10:30:00.000Z",
"privacy": {
"showEmail": false,
"showLocation": true,
"showStats": true,
"allowMessages": true,
"profileVisibility": "public"
},
"stats": {
"prayersHosted": 15,
"prayersAttended": 42,
"communityRating": 4.8
},
"badges": ["Verified", "Regular Host", "Community Helper"],
"createdAt": "2025-08-14T22:42:05.779Z",
"updatedAt": "2025-09-14T22:42:05.779Z"
}

Status: 404 Not Found

{
"error": {
"message": "User not found",
"code": "USER_NOT_FOUND"
}
}

Delete User Profile

Permanently delete a user profile and all associated data.

Endpoint: DELETE /api/users/{userId}

Authentication: Required (User must be the profile owner or admin)

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Response

Status: 200 OK

{
"message": "User profile deleted successfully",
"deletedAt": "2025-09-14T22:42:05.780Z"
}

Status: 404 Not Found

{
"error": {
"message": "User not found",
"code": "USER_NOT_FOUND"
}
}

Verify Shahada

Verify a user's Shahada declaration for community access.

Endpoint: POST /api/users/{userId}/verify-shahada

Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Request Body

{
"text": "I bear witness that there is no God but Allah, and I bear witness that Muhammad is the Messenger of Allah."
}
FieldTypeRequiredDescription
textstringYesShahada text in English or Arabic

Response

Status: 200 OK

{
"message": "Shahada verified successfully",
"verified": true,
"shahadaDate": "2025-09-14T22:42:05.780Z",
"level": "basic"
}

Status: 400 Bad Request

{
"error": {
"message": "Shahada text does not match required format",
"code": "SHAHADA_MISMATCH",
"details": {
"expectedFormat": "I bear witness that there is no God but Allah, and I bear witness that Muhammad is the Messenger of Allah."
}
}
}

Update Privacy Settings

Update user privacy and visibility preferences.

Endpoint: PATCH /api/users/{userId}/privacy

Authentication: Required (User must be profile owner)

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Request Body

{
"privacy": {
"showEmail": false,
"showLocation": true,
"showStats": true,
"allowMessages": true,
"profileVisibility": "public"
}
}

Privacy Options

SettingTypeDescription
showEmailbooleanDisplay email in profile
showLocationbooleanShow location information
showStatsbooleanDisplay prayer statistics
allowMessagesbooleanAllow direct messages
profileVisibilitystring"public", "friends", "private"

Response

Status: 200 OK

{
"message": "Privacy settings updated",
"privacy": {
"showEmail": false,
"showLocation": true,
"showStats": true,
"allowMessages": true,
"profileVisibility": "public"
},
"updatedAt": "2025-09-14T22:42:05.781Z"
}

Check Waitlist Status

Check if a user is on the platform waitlist.

Endpoint: GET /api/users/{userId}/waitlist

Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Response

Status: 200 OK

{
"onWaitlist": true,
"waitlistAt": "2025-09-14T22:42:05.782Z",
"position": 127,
"estimatedWaitTime": "2-3 weeks"
}

List Joined Prayers

Get prayers that the user has joined as an attendee.

Endpoint: GET /api/users/{userId}/prayers/joined

Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Results per page
sortstring"dateDesc"Sort: "dateAsc", "dateDesc", "newest", "oldest"

Response

Status: 200 OK

{
"items": [
{
"id": "prayer123",
"type": "Fajr",
"date": "2025-07-01T04:30:00.000Z",
"time": "04:30",
"location": {
"address": "123 Main St, Bangalore",
"geo": {
"type": "Point",
"coordinates": [77.5946, 12.9716]
}
},
"host": {
"userId": "host123",
"name": "Host Name",
"verified": true
},
"status": "attended",
"joinedAt": "2025-06-30T20:00:00.000Z",
"checkedInAt": "2025-07-01T04:25:00.000Z"
}
],
"total": 42,
"page": 1,
"limit": 20,
"hasNextPage": true
}

List Hosted Prayers

Get prayers that the user is hosting.

Endpoint: GET /api/users/{userId}/prayers/hosted

Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Results per page
sortstring"dateDesc"Sort: "dateAsc", "dateDesc", "newest", "oldest"

Response

Status: 200 OK

{
"items": [
{
"id": "prayer456",
"type": "Maghrib",
"date": "2025-07-02T19:15:00.000Z",
"time": "19:15",
"location": {
"address": "My Home, Bangalore",
"geo": {
"type": "Point",
"coordinates": [77.5946, 12.9716]
}
},
"attendees": [
{
"userId": "user789",
"name": "Attendee Name",
"status": "confirmed"
}
],
"capacity": 8,
"attendeesCount": 5,
"status": "scheduled",
"createdAt": "2025-07-01T10:00:00.000Z"
}
],
"total": 15,
"page": 1,
"limit": 20,
"hasNextPage": false
}

Get Notification Preferences

Retrieve user's notification settings and preferences.

Endpoint: GET /api/users/{userId}/notifications

Authentication: Required (User must be profile owner)

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Response

Status: 200 OK

{
"prayerReminders": true,
"statusUpdates": true,
"resourceUpdates": false,
"social": true,
"safety": true,
"marketing": false,
"badges": true,
"types": ["push", "email", "sms"],
"reminderMinutes": 15,
"pushEnabled": true,
"emailEnabled": true,
"smsEnabled": false,
"quietHours": {
"enabled": true,
"start": "22:00",
"end": "06:00"
}
}

Update Notification Preferences

Update user's notification settings and preferences.

Endpoint: PUT /api/users/{userId}/notifications

Authentication: Required (User must be profile owner)

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Request Body

{
"prayerReminders": true,
"statusUpdates": true,
"resourceUpdates": false,
"social": false,
"safety": true,
"marketing": false,
"badges": true,
"types": ["push", "email"],
"reminderMinutes": 10,
"pushEnabled": true,
"emailEnabled": true
}

Notification Types

SettingDescription
prayerRemindersNotifications before prayer times
statusUpdatesPrayer status changes and updates
resourceUpdatesChanges to prayer resources
socialComments, messages, and social interactions
safetySafety alerts and emergency notifications
marketingPromotional and marketing content
badgesAchievement and badge notifications

Response

Status: 200 OK

{
"message": "Notification preferences updated",
"preferences": {
"prayerReminders": true,
"statusUpdates": true,
"resourceUpdates": false,
"social": false,
"safety": true,
"marketing": false,
"badges": true,
"types": ["push", "email"],
"reminderMinutes": 10,
"pushEnabled": true,
"emailEnabled": true
},
"updatedAt": "2025-09-14T22:42:05.783Z"
}

Get Profile Status

Get user profile completion and verification status.

Endpoint: GET /api/users/{userId}/profile-status

Authentication: Required

Path Parameters

ParameterTypeRequiredDescription
userIdstringYesUser ID

Response

Status: 200 OK

{
"verified": true,
"onWaitlist": false,
"hasLocation": true,
"hasProfile": true,
"profileCompletion": 85,
"missingFields": ["bio"],
"verificationLevel": "basic",
"canHostPrayers": true,
"canJoinPrayers": true
}

Status Fields

FieldTypeDescription
verifiedbooleanShahada verification status
onWaitlistbooleanWhether user is on waitlist
hasLocationbooleanLocation information provided
hasProfilebooleanBasic profile completed
profileCompletionnumberProfile completion percentage
missingFieldsarrayList of incomplete profile fields
verificationLevelstringVerification level: "basic", "verified", "trusted"
canHostPrayersbooleanPermission to host prayers
canJoinPrayersbooleanPermission to join prayers

User Verification Levels

LevelRequirementsPermissions
UnverifiedAccount createdLimited prayer discovery
BasicShahada verifiedJoin prayers, basic features
VerifiedAdmin verificationHost prayers, full features
TrustedCommunity verificationModeration tools, leadership

Profile Privacy Levels

LevelVisibility
PublicVisible to all users
FriendsVisible to connected users only
PrivateVisible to user only