Base URL
All endpoints are prefixed with:
https://saraka.co.tz/api/
Authentication
All requests require a Bearer Token for authentication. Include the following header in each request:
Authorization: Bearer <your_token>
List All Users
/users
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/users" -H "Authorization: Bearer your_token"
Create a User
/users
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"affiliation_id": "UUID",
"attachment_id": "UUID",
"attachment_type": "string",
"name": "string",
"email": "string",
"phone": "string",
"bio": "text",
"address": "string",
"password": "string",
"status": "int"
}
Example:
curl -X POST "https://saraka.co.tz/api/users" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"affiliation_id":"11fd52d6-f8fc-11ee-ba86-014b797e0bbb", "attachment_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "attachment_type":"App\\Models\\Organization", "name":"Galvin Schwartz", "email":"kyvele@mailinator.com", "phone":"255717888822", "bio":null, "address":null, "password":"$2y$12$hF6htjSZYC87MlwTdsI06.4.dbWUeopmuNxRBZ/u7NcTLrZWbL63K", "status":1}'
Get a User
/users/{id}
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/users/1" -H "Authorization: Bearer your_token"
Update a User
/users/{id}
PUT
Authorization: Bearer <your_token>
Content-Type: application/json
{
"affiliation_id": "UUID",
"attachment_id": "UUID",
"attachment_type": "string",
"name": "string",
"email": "string",
"phone": "string",
"bio": "text",
"address": "string",
"password": "string",
"status": "int"
}
Example:
curl -X PUT "https://saraka.co.tz/api/users/1" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"affiliation_id":"11fd52d6-f8fc-11ee-ba86-014b797e0bbb", "attachment_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "attachment_type":"App\\Models\\Organization", "name":"Jane Doe", "email":"jane@example.com", "phone":"255717888823", "bio":null, "address":null, "password":"$2y$12$hF6htjSZYC87MlwTdsI06.4.dbWUeopmuNxRBZ/u7NcTLrZWbL63K", "status":1}'
Delete a User
/users/{id}
DELETE
Authorization: Bearer <your_token>
Example:
curl -X DELETE "https://saraka.co.tz/api/users/1" -H "Authorization: Bearer your_token"
List All Services
/services
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/services" -H "Authorization: Bearer your_token"
Create a Service
/services
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"name": "string",
"service_type_id": "integer",
"description": "string"
}
Example:
curl -X POST "https://saraka.co.tz/api/services" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"name":"Health Check", "service_type_id":1, "description":"Routine health checkup service"}'
Get a Service
/services/{id}
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/services/1" -H "Authorization: Bearer your_token"
Update a Service
/services/{id}
PUT
Authorization: Bearer <your_token>
Content-Type: application/json
{
"name": "string",
"service_type_id": "integer",
"description": "string"
}
Example:
curl -X PUT "https://saraka.co.tz/api/services/1" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"name":"Updated Service", "service_type_id":1, "description":"Updated description"}'
Delete a Service
/services/{id}
DELETE
Authorization: Bearer <your_token>
Example:
curl -X DELETE "https://saraka.co.tz/api/services/1" -H "Authorization: Bearer your_token"
List All Facilities
/facilities
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/facilities" -H "Authorization: Bearer your_token"
Create a Facility
/facilities
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"official_name": "string",
"common_name": "string",
"code": "string",
"type": "string",
"ownership_id": "integer",
"ward_id": "integer",
"address": "string",
"email": "string",
"phone": "string"
}
Example:
curl -X POST "https://saraka.co.tz/api/facilities" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"official_name":"General Hospital", "common_name":"Downtown Hospital", "code":"GH123", "type":"Regional", "ownership_id":1, "ward_id":51108, "address":"123 Main St", "email":"contact@hospital.com", "phone":"255 (123) 456-7890"}'
``
`
**Get a Facility**
- **Endpoint**: `/facilities/{id}`
- **Method**: `GET`
- **Description**: Retrieves a facility by ID.
- **Headers**:
- `Authorization: Bearer <your_token>`
- **Response**: JSON object of the facility.
**Example**:
```sh
curl -X GET "https://saraka.co.tz/api/facilities/1" -H "Authorization: Bearer your_token"
Update a Facility
/facilities/{id}
PUT
Authorization: Bearer <your_token>
Content-Type: application/json
{
"official_name": "string",
"common_name": "string",
"code": "string",
"type": "string",
"ownership_id": "integer",
"ward_id": "integer",
"address": "string",
"email": "string",
"phone": "string"
}
Example:
curl -X PUT "https://saraka.co.tz/api/facilities/1" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"official_name":"Updated Hospital", "common_name":"Updated Common Name", "code":"UH456", "type":"District", "ownership_id":2, "ward_id":51109, "address":"456 New St", "email":"updated@hospital.com", "phone":"255 (987) 654-3210"}'
Delete a Facility
/facilities/{id}
DELETE
Authorization: Bearer <your_token>
Example:
curl -X DELETE "https://saraka.co.tz/api/facilities/1" -H "Authorization: Bearer your_token"
List All Organizations
/organizations
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/organizations" -H "Authorization: Bearer your_token"
Create an Organization
/organizations
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"name": "string",
"ownership_id": "integer",
"ward_id": "integer",
"membership_id": "integer",
"village_street": "string",
"address": "string",
"responsible_person": "string",
"phone_number": "string",
"help_line": "string",
"working_days": "string",
"working_hours": "string",
"email": "string",
"website": "string",
"latitude": "string",
"longitude": "string",
"is_verified": "boolean",
"user_id": "UUID",
"is_active": "boolean"
}
Example:
curl -X POST "https://saraka.co.tz/api/organizations" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"name":"Health NGO", "ownership_id":2, "ward_id":51111, "membership_id":2, "village_street":"Makanyagio Street", "address":"1234 Iringa", "responsible_person":"Armando Hale", "phone_number":"255 (894) 554-5796", "help_line":"+1 (498) 836-2928", "working_days":"Monday - Friday", "working_hours":"24 Hrs", "email":"nysy@mailinator.com", "website":"https://www.xykib.cm", "latitude":"5242.36345", "longitude":"345.4245234", "is_verified":true, "user_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "is_active":true}'
Get an Organization
/organizations/{id}
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/organizations/1" -H "Authorization: Bearer your_token"
Update an Organization
/organizations/{id}
PUT
Authorization: Bearer <your_token>
Content-Type: application/json
{
"name": "string",
"ownership_id": "integer",
"ward_id": "integer",
"membership_id": "integer",
"village_street": "string",
"address": "string",
"responsible_person": "string",
"phone_number": "string",
"help_line": "string",
"working_days": "string",
"working_hours": "string",
"email": "string",
"website": "string",
"latitude": "string",
"longitude": "string",
"is_verified": "boolean",
"user_id": "UUID",
"is_active": "boolean"
}
Example:
curl -X PUT "https://saraka.co.tz/api/organizations/1" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"name":"Updated Organization", "ownership_id":2, "ward_id":51111, "membership_id":2, "village_street":"Updated Street", "address":"456 New Address", "responsible_person":"Updated Person", "phone_number":"255 (894) 554-5797", "help_line":"+1 (498) 836-2929", "working_days":"Monday - Friday", "working_hours":"24 Hrs", "email":"updated@mailinator.com", "website":"https://www.updated.com", "latitude":"5242.36346", "longitude":"345.4245235", "is_verified":true, "user_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "is_active":true}'
Delete an Organization
/organizations/{id}
DELETE
Authorization: Bearer <your_token>
Example:
curl -X DELETE "https://saraka.co.tz/api/organizations/1" -H "Authorization: Bearer your_token"
List All Offered Services
/offered-services
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/offered-services" -H "Authorization: Bearer your_token"
Create an Offered Service
/offered-services
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"organization_id": "UUID",
"service_type_id": "integer",
"service_name": "string",
"service_description": "string"
}
Example:
curl -X POST "https://saraka.co.tz/api/offered-services" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"organization_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "service_type_id":8, "service_name":"Colt Gilliam", "service_description":"Repudiandae dicta vo"}'
Get an Offered Service
/offered-services/{id}
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/offered-services/1" -H "Authorization: Bearer your_token"
Update an Offered Service
/offered-services/{id}
PUT
Authorization: Bearer <your_token>
Content-Type: application/json
{
"organization_id": "UUID",
"service_type_id": "integer",
"service_name": "string",
"service_description": "string"
}
Example:
curl -X PUT "https://saraka.co.tz/api/offered-services/1" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"organization_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "service_type_id":8, "service_name":"Updated Service", "service_description":"Updated description"}'
Delete an Offered Service
/offered-services/{id}
DELETE
Authorization: Bearer <your_token>
Example:
curl -X DELETE "https://saraka.co.tz/api/offered-services/1" -H "Authorization: Bearer your_token"
List All Coverages
/coverages
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/coverages" -H "Authorization: Bearer your_token"
Create a Coverage
/coverages
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"organization_id": "UUID",
"district_id": "integer"
}
Example:
curl -X POST "https://saraka.co.tz/api/coverages" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"organization_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "district_id":511}'
Get a Coverage
/coverages/{id}
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/coverages/1" -H "Authorization: Bearer your_token"
Update a Coverage
/coverages/{id}
PUT
Authorization: Bearer <your_token>
Content-Type: application/json
{
"organization_id": "UUID",
"district_id": "integer"
}
Example:
curl -X PUT "https://saraka.co.tz/api/coverages/1" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"organization_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "district_id":512}'
Delete a Coverage
/coverages/{id}
DELETE
Authorization: Bearer <your_token>
Example:
curl -X DELETE "https://saraka.co.tz/api/coverages/1" -H "Authorization: Bearer your_token"
List All Beneficiaries
/beneficiaries
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/beneficiaries" -H "Authorization: Bearer your_token"
Create a Beneficiary
/beneficiaries
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"organization_id": "UUID",
"name": "string"
}
Example:
curl -X POST "https://saraka.co.tz/api/beneficiaries" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"organization_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "name":"Julie Evans"}'
Get a Beneficiary
/beneficiaries/{id}
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/beneficiaries/1" -H "Authorization: Bearer your_token"
Update a Beneficiary
/beneficiaries/{id}
PUT
Authorization: Bearer <your_token>
Content-Type: application/json
{
"organization_id": "UUID",
"name": "string"
}
Example:
curl -X PUT "https://saraka.co.tz/api/beneficiaries/1" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"organization_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "name":"Updated Name"}'
Delete a Beneficiary
/beneficiaries/{id}
DELETE
Authorization: Bearer <your_token>
Example:
curl -X DELETE "https://saraka.co.tz/api/beneficiaries/1" -H "Authorization: Bearer your_token"
List All Clients
/clients
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/clients" -H "Authorization: Bearer your_token"
Create a Client
/clients
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"name": "string",
"beneficiary_id": "integer"
}
Example:
curl -X POST "https://saraka.co.tz/api/clients" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"name":"John Doe", "beneficiary_id":3}'
Get a Client
/clients/{id}
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/clients/1" -H
Base URL All endpoints are prefixed with:
https://saraka.co.tz/api/
Authentication All requests require a Bearer Token for authentication. Include the following header in each request:
Authorization: Bearer <your_token>
List All Referrals
/referrals
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/referrals" -H "Authorization: Bearer your_token"
Create a Referral
/referrals
POST
Authorization: Bearer <your_token>
Content-Type: application/json
{
"referrer_id": "UUID",
"client_id": "UUID",
"attachment_id": "UUID",
"attachment_type": "string",
"service_provided": "text"
}
Example:
curl -X POST "https://saraka.co.tz/api/referrals" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"referrer_id":"6ae599a4-4029-485d-bb63-80517d249dfe", "client_id":"4c8e8042-6ce9-8c2f-5901f790", "attachment_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "attachment_type":"App\\Models\\Organization", "service_provided":"Pediatric care provided to the child."}'
Get a Referral
/referrals/{id}
GET
Authorization: Bearer <your_token>
Example:
curl -X GET "https://saraka.co.tz/api/referrals/1" -H "Authorization: Bearer your_token"
Update a Referral
/referrals/{id}
PUT
Authorization: Bearer <your_token>
Content-Type: application/json
{
"referrer_id": "UUID",
"client_id": "UUID",
"attachment_id": "UUID",
"attachment_type": "string",
"service_provided": "text"
}
Example:
curl -X PUT "https://saraka.co.tz/api/referrals/1" -H "Authorization: Bearer your_token" -H "Content-Type: application/json" -d '{"referrer_id":"6ae599a4-4029-485d-bb63-80517d249dfe", "client_id":"4c8e8042-6ce9-8c2f-5901f790", "attachment_id":"a70c6484-6ce9-4c8e-8042-8c2f5901f790", "attachment_type":"App\\Models\\Organization", "service_provided":"Updated service provided to the child."}'
Delete a Referral
/referrals/{id}
DELETE
Authorization: Bearer <your_token>
Example:
curl -X DELETE "https://saraka.co.tz/api/referrals/1" -H "Authorization: Bearer your_token"
Field Name | Data Type | Description | Example |
---|---|---|---|
id | UUID | Primary key | 6ae599a4-4029-485d-bb63-80517d249dfe |
referrer_id | UUID | Foreign key to Users table | 6ae599a4-4029-485d-bb63-80517d249dfe |
client_id | UUID | Foreign key to Clients table | 4c8e8042-6ce9-8c2f-5901f790 |
attachment_id | UUID | ID of the associated attachment | a70c6484-6ce9-4c8e-8042-8c2f5901f790 |
attachment_type | string | Type of the associated attachment | App\Models\Organization |
service_provided | text | Description of the service provided | Pediatric care provided to the child. |
deleted_at | timestamp | Deletion timestamp (for soft deletes) | NULL |
created_at | timestamp | Record creation timestamp | 2024-07-14 12:34:56 |
updated_at | timestamp | Record update timestamp | 2024-07-14 12:34:56 |
Base URL All endpoints are prefixed with:
https://saraka.co.tz/api/
Login
/auth/login
POST
Content-Type: application/json
{
"email": "string",
"password": "string"
}
Example:
curl -X POST "https://saraka.co.tz/api/auth/login" -H "Content-Type: application/json" -d '{"email":"kimwalu@gmail.com", "password":"password"}'
Request Example:
{
"email": "kimwalu@gmail.com",
"password": "password"
}
Response Example:
{
"user": {
"id": "087174ea-f9ba-11ee-ba86-014b797e0bbb",
"affiliation_id": "6c7d4414-f8de-11ee-908a-7677f566206c",
"attachment_id": null,
"attachment_type": null,
"name": "King Mwalubandu",
"email": "kimwalu@gmail.com",
"phone": "255717599994",
"bio": "The bio bios",
"address": "2323 Kilimani Ave.",
"email_verified_at": null,
"status": 1,
"created_at": "2024-04-13T17:19:49.000000Z",
"updated_at": "2024-04-13T17:19:49.000000Z",
"affiliation": {
"id": "6c7d4414-f8de-11ee-908a-7677f566206c",
"name": "Christian Social Services Commission",
"slug": "CSSC",
"logo": null,
"deleted_at": null,
"created_at": "2024-04-12T15:07:48.000000Z",
"updated_at": "2024-04-12T15:07:48.000000Z"
},
"attachment": null
},
"access_token": "2d42f779-283c-47ce-8e3b-9052c80bdca4|VLd0srDFIZzWVs4RdYhjYEvdwDu4y6mvwWgRFRKo79274dd0",
"token_type": "Bearer"
}
Logout
/auth/logout
POST
Authorization: Bearer <your_token>
Example:
curl -X POST "https://saraka.co.tz/api/auth/logout" -H "Authorization: Bearer your_token"
Response Example:
{
"message": "Successfully logged out"
}