Introduction
Welcome to the Church Management System API v2. This RESTful API provides comprehensive access to church management features including member management, contributions, events, and new M-Pesa payment integration.
Base URL & Headers
All API requests should be made to the following base URL:
https://apidev.royexsolutions.co.ke/api/v1
Required Headers
All requests must include the following headers:
| Header | Value | Required For |
|---|---|---|
Content-Type |
application/json |
POST, PUT, PATCH requests |
Accept |
application/json |
All requests |
Authorization |
Bearer YOUR_AUTH_TOKEN |
Protected endpoints |
Authentication
Most endpoints require JWT (JSON Web Token) authentication. Obtain your token by logging in through the authentication endpoints.
Getting an Authentication Token
First, register or login to get your authentication token:
Register a new user account
{
"name": "John Doe",
"email": "john@example.com",
"phone": "254712345678",
"password": "password123",
"password_confirmation": "password123",
"church_id": 1
}
{
"success": true,
"message": "User registered successfully",
"data": {
"user": {
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"phone": "254712345678",
"church_id": 1
},
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
},
"timestamp": "2026-02-10T12:34:56Z"
}
Authenticate user and receive JWT token
{
"email": "john@example.com",
"password": "password123"
}
{
"success": true,
"message": "Login successful",
"data": {
"user": {
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"phone": "254712345678",
"church_id": 1
},
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
},
"timestamp": "2026-02-10T12:34:56Z"
}
Public Endpoints
Endpoints accessible without authentication.
Church Information
Get list of active churches for registration
{
"success": true,
"data": [
{
"id": 1,
"name": "Nairobi Central SDA Church",
"location": "Nairobi, Kenya",
"phone": "254712345678",
"email": "info@nairobi-sda.org",
"status": "active"
},
{
"id": 2,
"name": "Mombasa Coastal SDA Church",
"location": "Mombasa, Kenya",
"phone": "254712345679",
"email": "info@mombasa-sda.org",
"status": "active"
}
],
"timestamp": "2026-02-10T12:34:56Z"
}
M-Pesa Callbacks (Safaricom)
M-Pesa validation callback (called by Safaricom)
{
"TransactionType": "Pay Bill",
"TransID": "RI7046YUR7I",
"TransTime": "20240115123456",
"TransAmount": "100.00",
"BusinessShortCode": "174379",
"BillRefNumber": "TITHE001",
"InvoiceNumber": "",
"OrgAccountBalance": "",
"ThirdPartyTransID": "",
"MSISDN": "254712345678",
"FirstName": "John"
}
{
"ResultCode": 0,
"ResultDesc": "Accepted"
}
M-Pesa confirmation callback (called by Safaricom)
{
"TransactionType": "Pay Bill",
"TransID": "RI7046YUR7I",
"TransTime": "20240115123456",
"TransAmount": "100.00",
"BusinessShortCode": "174379",
"BillRefNumber": "TITHE001",
"InvoiceNumber": "",
"OrgAccountBalance": "100000.00",
"ThirdPartyTransID": "",
"MSISDN": "254712345678",
"FirstName": "John"
}
Authentication (Protected)
Endpoints that require authentication token in the Authorization header.
User Profile
Get current authenticated user profile
Update user profile information
{
"name": "John Updated",
"email": "john.updated@example.com",
"phone": "254712345679"
}
Change user password
{
"current_password": "oldpassword",
"password": "newpassword123",
"password_confirmation": "newpassword123"
}
Logout user (revoke token)
Dashboard
Dashboard-related endpoints for analytics and statistics.
Get main dashboard data
Get detailed dashboard statistics
Members Management
Manage church members with CRUD operations and statistics.
Member Operations
Get paginated list of members
Get members statistics
Get details of a specific member
Create a new member (Admin permission required)
{
"first_name": "Jane",
"last_name": "Smith",
"email": "jane@example.com",
"phone": "254712345680",
"gender": "female",
"date_of_birth": "1990-05-15",
"marital_status": "single",
"membership_status": "active"
}
Update member details (Admin permission required)
{
"first_name": "Jane Updated",
"last_name": "Smith",
"email": "jane.updated@example.com",
"membership_status": "active"
}
Delete a member (Admin permission required)
Contributions (Legacy)
Legacy contribution endpoints for backward compatibility.
Get current user's tithes and offerings (legacy endpoint)
Get summary of user's contributions (legacy endpoint)
Record a contribution (tithe or offering) - legacy endpoint
{
"type": "tithe",
"amount": 1000.50,
"date": "2026-02-10",
"payment_method": "mpesa",
"notes": "January tithe"
}
My Contributions (NEW - M-Pesa Integrated)
Enhanced contribution system with M-Pesa integration and SMS receipts.
Contribution Management
Get user's contributions with M-Pesa integration
Get detailed contribution summary
Create a new contribution with optional M-Pesa payment
{
"type": "tithe",
"amount": 1500.00,
"payment_method": "mpesa",
"phone_number": "254712345678",
"offering_type_id": 1,
"notes": "January tithe payment"
}
Get details of a specific contribution
Check M-Pesa payment status for a contribution
Download contribution receipt PDF
Send contribution receipt via SMS
M-Pesa STK Push callback endpoint (called by Safaricom)
{
"Body": {
"stkCallback": {
"MerchantRequestID": "29115-34620561-1",
"CheckoutRequestID": "ws_CO_220120241246123456",
"ResultCode": 0,
"ResultDesc": "The service request is processed successfully.",
"CallbackMetadata": {
"Item": [
{
"Name": "Amount",
"Value": 100
},
{
"Name": "MpesaReceiptNumber",
"Value": "RI7046YUR7I"
},
{
"Name": "Balance"
},
{
"Name": "TransactionDate",
"Value": 20240115123456
},
{
"Name": "PhoneNumber",
"Value": 254712345678
}
]
}
}
}
}
Member Transfers (NEW)
Manage member transfer requests between churches with approval workflow.
Member Transfer Requests
Get member's own transfer requests
Submit a member transfer request
{
"reason": "Relocating to Nairobi",
"destination_church_id": 2,
"transfer_date": "2024-02-01",
"notes": "Will be moving to Nairobi for work"
}
Cancel a transfer request (only if pending)
Leadership Approval
Get all transfer requests (Leadership permission required)
Get pending transfer requests (Leadership permission required)
Get details of a specific transfer request
Approve a transfer request (Leadership permission required)
{
"approval_notes": "Transfer approved by church board"
}
Reject a transfer request (Leadership permission required)
{
"rejection_reason": "Transfer cannot be approved at this time"
}
Mark transfer as completed (Admin permission required)
{
"completion_notes": "Transfer completed successfully"
}
Get transfer statistics (Admin permission required)
Finance Management
Financial management endpoints for tithes, offerings, and reports.
Tithe Management
Get all tithes (Treasurer/Admin permission required)
Record a tithe (Treasurer/Admin permission required)
{
"member_id": 1,
"amount": 1500.75,
"payment_date": "2026-02-10",
"payment_method": "cash",
"month": 1,
"year": 2024
}
Get giving summary for a specific member
Offering Management
Get all offerings
Create a new offering
{
"member_id": 1,
"offering_type_id": 1,
"amount": 500.00,
"offering_date": "2026-02-10",
"payment_method": "cash",
"notes": "Thanksgiving offering"
}
Initiate M-Pesa payment for offering
{
"member_id": 1,
"offering_type_id": 1,
"amount": 500.00,
"phone_number": "254712345678",
"description": "Special offering"
}
Get offering statistics
Get details of a specific offering
Get all offering types (Admin permission required)
Reports & Receipts
Get finance reports (Treasurer/Admin/Pastor permission required)
Get receipt details (Treasurer/Admin/Pastor permission required)
Events
Manage church events and registrations.
Get all events
Get events registered by current user
Get details of a specific event
Register for an event
Cancel event registration
Create a new event (Admin/Pastor permission required)
{
"title": "Youth Conference",
"description": "Annual youth conference",
"start_date": "2024-02-15",
"end_date": "2024-02-17",
"venue": "Church Hall",
"event_type": "conference"
}
Update an event (Admin/Pastor permission required)
{
"title": "Youth Conference Updated",
"description": "Updated annual youth conference",
"venue": "Main Sanctuary"
}
Delete an event (Admin/Pastor permission required)
Announcements
Manage church announcements.
Get all announcements
Get details of a specific announcement
Notifications
Manage user notifications.
Get user notifications
Mark a notification as read
Mark all notifications as read
Church Services
Manage church services and attendance.
Get church services
Record a church service
{
"service_type": "divine_service",
"service_date": "2024-01-14",
"start_time": "10:00",
"end_time": "12:30",
"preacher_name": "Pastor John",
"sermon_title": "The Power of Faith",
"attendance_count": 150,
"offering_amount": 12500.50
}
Families
Manage church families and their members.
Get all families
Create a new family
{
"family_name": "Smith Family",
"head_of_family_id": 1,
"address": "123 Main St, Nairobi",
"phone": "254712345678"
}
Get details of a specific family
M-Pesa Payments
Process payments through Safaricom M-Pesa with STK Push.
Initiate M-Pesa payment
{
"phone_number": "254712345678",
"amount": 500,
"account_reference": "TITHE-001",
"description": "January Tithe"
}
Get M-Pesa transaction history
Settings
System settings and configuration endpoints.
Get church information
Get application configuration
Response Format
All API responses follow a consistent JSON format:
{
"success": true,
"message": "Operation completed successfully",
"data": {
// Response data varies by endpoint
},
"timestamp": "2026-02-10T12:34:56Z"
}
Pagination
List endpoints return paginated responses:
{
"success": true,
"data": [
// Array of items
],
"meta": {
"current_page": 1,
"from": 1,
"last_page": 5,
"per_page": 20,
"to": 20,
"total": 95
},
"links": {
"first": "https://apidev.royexsolutions.co.ke/api/v1/members?page=1",
"last": "https://apidev.royexsolutions.co.ke/api/v1/members?page=5",
"prev": null,
"next": "https://apidev.royexsolutions.co.ke/api/v1/members?page=2"
},
"timestamp": "2026-02-10T12:34:56Z"
}
Rate Limits
API requests are limited to 1000 requests per hour per authenticated user. Rate limit information is included in response headers:
X-RateLimit-Limit: 1000 X-RateLimit-Remaining: 999 X-RateLimit-Reset: 1640995200
Retry-After header indicating when you can retry.
Error Codes
| Code | Status | Description |
|---|---|---|
200 |
OK | Request successful |
201 |
Created | Resource created successfully |
400 |
Bad Request | Invalid request parameters |
401 |
Unauthorized | Authentication required or invalid token |
403 |
Forbidden | Insufficient permissions |
404 |
Not Found | Resource not found |
422 |
Unprocessable Entity | Validation error |
429 |
Too Many Requests | Rate limit exceeded (1000 requests/hour) |
500 |
Internal Server Error | Server error |
{
"success": false,
"message": "Validation failed",
"errors": {
"email": ["The email field is required."],
"password": ["The password must be at least 8 characters."]
},
"timestamp": "2026-02-10T12:34:56Z"
}
Webhooks
Webhooks allow you to receive real-time notifications when events occur in your church management system.