Skip to main content
POST
/
api
/
church
/
createdonation
/
:pastorId
Create Donation
curl --request POST \
  --url https://api.example.com/api/church/createdonation/:pastorId \
  --header 'Content-Type: application/json' \
  --data '
{
  "church": "<string>",
  "donationName": "<string>",
  "donationStatus": {},
  "startDate": "<string>",
  "endDate": "<string>",
  "donationDescription": "<string>",
  "bankDetails": {
    "bankDetails.accountName": "<string>",
    "bankDetails.accountNumber": "<string>",
    "bankDetails.bankName": "<string>"
  },
  "donationSupportContact": {
    "donationSupportContact.phone": "<string>",
    "donationSupportContact.email": "<string>"
  },
  "donationMetrics": {
    "donationMetrics.targetAmount": 123,
    "donationMetrics.minAmount": 123
  }
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "data._id": "<string>",
    "data.church": {},
    "data.donationName": "<string>",
    "data.donationStatus": {},
    "data.startDate": "<string>",
    "data.endDate": "<string>",
    "data.donationDescription": "<string>",
    "data.bankDetails": {},
    "data.donationSupportContact": {},
    "data.donationMetrics": {},
    "data.donators": [
      {}
    ],
    "data.createdAt": "<string>",
    "data.updatedAt": "<string>"
  }
}

Authentication

This endpoint requires:
  • Valid JWT token in Authorization header
  • User role must be pastor
  • Pastor must be the leader of the specified church

Endpoint

POST /api/church/createdonation/:pastorId

Path Parameters

pastorId
string
required
The unique identifier of the pastor creating the donation. Must match the authenticated user’s profile ID.

Request Body

church
string
required
The unique identifier (ObjectId) of the church for which the donation is being created.
donationName
string
required
The name of the donation campaign (e.g., “Building Fund”, “Mission Trip”).
donationStatus
enum
required
The initial status of the donation. Must be one of:
  • "on" - Donation is active and accepting contributions
  • "off" - Donation is paused
  • "completed" - Donation target has been reached
startDate
date
required
The date when the donation campaign starts. Must be in the future.
endDate
date
required
The date when the donation campaign ends. Must be after startDate and in the future.
donationDescription
string
required
A description of the donation purpose and goals.
bankDetails
object
required
Bank account information for the donation.
bankDetails.accountName
string
required
Name on the bank account.
bankDetails.accountNumber
string
required
Bank account number.
bankDetails.bankName
string
required
Name of the bank.
donationSupportContact
object
required
Contact information for donation support.
donationSupportContact.phone
string
required
Phone number for donation inquiries.
donationSupportContact.email
string
required
Email address for donation inquiries (must be valid email format).
donationMetrics
object
required
Financial metrics for the donation campaign.
donationMetrics.targetAmount
number
required
The fundraising goal amount.
donationMetrics.minAmount
number
required
The minimum donation amount allowed.

Response

success
boolean
Indicates if the donation was created successfully.
message
string
A human-readable message describing the result.
data
object
The created donation object.
data._id
string
Unique identifier for the donation.
data.church
object
Populated church object details.
data.donationName
string
Name of the donation campaign.
data.donationStatus
enum
Current status: “on”, “off”, or “completed”.
data.startDate
date
Campaign start date.
data.endDate
date
Campaign end date.
data.donationDescription
string
Description of the donation purpose.
data.bankDetails
object
Bank account information.
data.donationSupportContact
object
Contact information for support.
data.donationMetrics
object
Financial metrics including targetAmount, minAmount, and totalGotten (default: 0).
data.donators
array
Array of donators (empty at creation).
data.createdAt
date
Timestamp of creation.
data.updatedAt
date
Timestamp of last update.

Example Request

curl -X POST "https://api.example.com/api/church/createdonation/60d5ec49f1b2c72b8c8e4f1a" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "church": "60d5ec49f1b2c72b8c8e4f1b",
    "donationName": "Building Fund 2026",
    "donationStatus": "on",
    "startDate": "2026-04-01T00:00:00.000Z",
    "endDate": "2026-12-31T23:59:59.000Z",
    "donationDescription": "Fundraising for new church building construction",
    "bankDetails": {
      "accountName": "First Baptist Church",
      "accountNumber": "1234567890",
      "bankName": "Community Bank"
    },
    "donationSupportContact": {
      "phone": "+1-555-0123",
      "email": "[email protected]"
    },
    "donationMetrics": {
      "targetAmount": 500000,
      "minAmount": 10
    }
  }'

Example Response

{
  "success": true,
  "message": "Your Building Fund 2026 donation is now open",
  "data": {
    "_id": "60d5ec49f1b2c72b8c8e4f1c",
    "church": {
      "_id": "60d5ec49f1b2c72b8c8e4f1b",
      "name": "First Baptist Church",
      "pastor": "60d5ec49f1b2c72b8c8e4f1a"
    },
    "donationName": "Building Fund 2026",
    "donationStatus": "on",
    "startDate": "2026-04-01T00:00:00.000Z",
    "endDate": "2026-12-31T23:59:59.000Z",
    "donationDescription": "Fundraising for new church building construction",
    "bankDetails": {
      "accountName": "First Baptist Church",
      "accountNumber": "1234567890",
      "bankName": "Community Bank"
    },
    "donationSupportContact": {
      "phone": "+1-555-0123",
      "email": "[email protected]"
    },
    "donationMetrics": {
      "targetAmount": 500000,
      "minAmount": 10,
      "totalGotten": 0
    },
    "donators": [],
    "createdAt": "2026-03-07T10:30:00.000Z",
    "updatedAt": "2026-03-07T10:30:00.000Z"
  }
}

Error Responses

400 - Donation Already Exists

{
  "success": false,
  "message": "Unable to create donation",
  "data": "Donation with this name already exists in this church"
}

400 - Not Church Pastor

{
  "success": false,
  "message": "Unable to create donation",
  "data": "You are not the pastor of this church"
}

404 - Church Not Found

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

500 - Server Error

{
  "success": false,
  "message": "Unable to create a donation",
  "data": "Error message details"
}

Notes

  • Donation names must be unique within a church
  • The pastor creating the donation must be the leader of the specified church
  • Start and end dates must be in the future at the time of creation
  • The totalGotten field in donationMetrics is automatically initialized to 0
  • The church object is populated in the response with full details

Build docs developers (and LLMs) love