API Documentation

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>

Endpoints

Users

List All Users

Example:

curl -X GET "https://saraka.co.tz/api/users" -H "Authorization: Bearer your_token"

Create a User

{
    "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

Example:

curl -X GET "https://saraka.co.tz/api/users/1" -H "Authorization: Bearer your_token"

Update a User

{
    "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

Example:

curl -X DELETE "https://saraka.co.tz/api/users/1" -H "Authorization: Bearer your_token"

Services

List All Services

Example:

curl -X GET "https://saraka.co.tz/api/services" -H "Authorization: Bearer your_token"

Create a Service

{
    "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

Example:

curl -X GET "https://saraka.co.tz/api/services/1" -H "Authorization: Bearer your_token"

Update a Service

{
    "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

Example:

curl -X DELETE "https://saraka.co.tz/api/services/1" -H "Authorization: Bearer your_token"

Facilities

List All Facilities

Example:

curl -X GET "https://saraka.co.tz/api/facilities" -H "Authorization: Bearer your_token"

Create a Facility

{
    "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

{
    "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

Example:

curl -X DELETE "https://saraka.co.tz/api/facilities/1" -H "Authorization: Bearer your_token"

Organizations

List All Organizations

Example:

curl -X GET "https://saraka.co.tz/api/organizations" -H "Authorization: Bearer your_token"

Create an Organization

{
    "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

Example:

curl -X GET "https://saraka.co.tz/api/organizations/1" -H "Authorization: Bearer your_token"

Update an Organization

{
    "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

Example:

curl -X DELETE "https://saraka.co.tz/api/organizations/1" -H "Authorization: Bearer your_token"

Offered Services

List All Offered Services

Example:

curl -X GET "https://saraka.co.tz/api/offered-services" -H "Authorization: Bearer your_token"

Create an Offered Service

{
    "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

Example:



curl -X GET "https://saraka.co.tz/api/offered-services/1" -H "Authorization: Bearer your_token"

Update an Offered Service

{
    "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

Example:

curl -X DELETE "https://saraka.co.tz/api/offered-services/1" -H "Authorization: Bearer your_token"

Coverages

List All Coverages

Example:

curl -X GET "https://saraka.co.tz/api/coverages" -H "Authorization: Bearer your_token"

Create a Coverage

{
    "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

Example:

curl -X GET "https://saraka.co.tz/api/coverages/1" -H "Authorization: Bearer your_token"

Update a Coverage

{
    "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

Example:

curl -X DELETE "https://saraka.co.tz/api/coverages/1" -H "Authorization: Bearer your_token"

Beneficiaries

List All Beneficiaries

Example:

curl -X GET "https://saraka.co.tz/api/beneficiaries" -H "Authorization: Bearer your_token"

Create a Beneficiary

{
    "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

Example:

curl -X GET "https://saraka.co.tz/api/beneficiaries/1" -H "Authorization: Bearer your_token"

Update a Beneficiary

{
    "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

Example:

curl -X DELETE "https://saraka.co.tz/api/beneficiaries/1" -H "Authorization: Bearer your_token"

Clients

List All Clients

Example:

curl -X GET "https://saraka.co.tz/api/clients" -H "Authorization: Bearer your_token"

Create a Client

{
    "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

Example:

curl -X GET "https://saraka.co.tz/api/clients/1" -H

Referrals Endpoint Documentation

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>

Endpoints

Referrals

List All Referrals

Example:

curl -X GET "https://saraka.co.tz/api/referrals" -H "Authorization: Bearer your_token"

Create a Referral

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

Example:

curl -X GET "https://saraka.co.tz/api/referrals/1" -H "Authorization: Bearer your_token"

Update a Referral

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

Example:

curl -X DELETE "https://saraka.co.tz/api/referrals/1" -H "Authorization: Bearer your_token"

Database Table Structure for Referrals

Referrals Table

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

Authentication Endpoints

Base URL All endpoints are prefixed with:

https://saraka.co.tz/api/

Endpoints

Authentication

Login

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

Example:

curl -X POST "https://saraka.co.tz/api/auth/logout" -H "Authorization: Bearer your_token"

Response Example:

{
    "message": "Successfully logged out"
}