Skip to main content
PATCH
/
api
/
church
/
joinchurch
/
:id
Join Church
curl --request PATCH \
  --url https://api.example.com/api/church/joinchurch/:id \
  --header 'Content-Type: application/json' \
  --data '
{
  "userId": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "data._id": "<string>",
    "data.name": "<string>",
    "data.address": "<string>",
    "data.supportcontact": {},
    "data.pastor": {}
  }
}

Authentication

This endpoint requires:
  • Valid JWT token in the Authorization header
  • Any authenticated user role (pastor or member)

Endpoint

PATCH /api/church/joinchurch/:id

Path Parameters

id
string
required
The MongoDB ObjectId of the church to join.

Request Body

userId
string
required
The MongoDB ObjectId of the user profile joining the church. This should match the authenticated user’s profile ID.

Response

success
boolean
Indicates whether the join operation was successful.
message
string
A descriptive message about the operation result.
data
object
The church object (excludes member list for privacy).
data._id
string
The unique MongoDB ObjectId of the church.
data.name
string
The name of the church.
data.address
string
The physical address of the church.
data.supportcontact
object
Contact information object containing phone, email, and optional website.
data.pastor
object
Pastor information object with name field.

Example Request

curl -X PATCH https://api.example.com/api/church/joinchurch/507f191e810c19729de860ea \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "507f1f77bcf86cd799439011"
  }'

Example Response

Success (200 OK)

{
  "success": true,
  "message": "You have successfully joined Grace Community Church",
  "data": {
    "_id": "507f191e810c19729de860ea",
    "name": "Grace Community Church",
    "address": "123 Main Street, Springfield, IL 62701",
    "supportcontact": {
      "phone": "+1-555-123-4567",
      "email": "[email protected]",
      "website": "https://gracechurch.org"
    },
    "pastor": {
      "name": "John Smith"
    }
  }
}

Already a Member (200 OK)

{
  "success": false,
  "message": "You are already a member of this church",
  "data": {
    "_id": "507f191e810c19729de860ea",
    "name": "Grace Community Church",
    "address": "123 Main Street, Springfield, IL 62701",
    "supportcontact": {
      "phone": "+1-555-123-4567",
      "email": "[email protected]"
    },
    "pastor": {
      "name": "John Smith"
    }
  }
}

Church Not Found (404 Not Found)

{
  "success": false,
  "message": "Unable to join church",
  "data": "Church with this Id does not exist"
}

Server Error (500 Internal Server Error)

{
  "success": false,
  "message": "Unable to join church",
  "data": "Error message details"
}

Notes

  • Users can join multiple churches
  • The endpoint checks if the user is already a member before adding them
  • If already a member, the response returns success: false with a 200 status code
  • The response excludes the full member list for privacy reasons
  • Both pastors and regular members can join churches using this endpoint

Build docs developers (and LLMs) love