Authentication

All API calls require authentication via Firebase Auth. Include the user's ID token in the Authorization header:

Authorization: Bearer <firebase_id_token>

💡 Tip: Use Firebase Auth SDK to obtain ID tokens. Tokens expire after 1 hour and must be refreshed.

Base URL

All API endpoints are relative to:

https://us-central1-akeyo-website.cloudfunctions.net/api

Endpoints

POST /calculateCreditScore

Calculate a credit score for a farmer based on their data and group history.

Request Body

{
  "farmerId": "string"
}

Response

{
  "success": true,
  "farmer_id": "string",
  "credit_score": 750,
  "credit_tier": "A",
  "probability_of_default": 0.08,
  "max_loan_amount_ugx": 5000000,
  "risk_flags": ["no_national_id"],
  "positive_indicators": [
    "gps_coordinates_recorded",
    "excellent_group_repayment"
  ]
}
POST /getCreditScore

Retrieve the most recent credit score for a farmer.

Request Body

{
  "farmerId": "string"
}

Response

{
  "success": true,
  "data": {
    "farmer_id": "string",
    "credit_score": 750,
    "credit_tier": "A",
    "probability_of_default": 0.08,
    "max_loan_amount_ugx": 5000000,
    "last_assessed": "2026-06-01T10:30:00Z"
  }
}
POST /getAllFarmers

Retrieve all farmers in your organization.

Request Body

{
  "limit": 100,
  "offset": 0
}

Response

{
  "success": true,
  "data": [
    {
      "id": "string",
      "name": "John Doe",
      "phone": "256771234567",
      "district": "Kampala",
      "verified": true,
      "credit_score": 750,
      "credit_tier": "A"
    }
  ],
  "total": 150
}
POST /getFieldVerifications

Retrieve field verification tasks (for field agents).

Request Body

{
  "status": "pending",
  "limit": 50
}

Response

{
  "success": true,
  "data": [
    {
      "id": "string",
      "farmer_id": "string",
      "farmer_name": "John Doe",
      "status": "pending",
      "priority": "high",
      "assignedTo": "agent_uid",
      "created_at": "2026-06-01T10:30:00Z"
    }
  ]
}

Error Codes

The API returns standard error codes to help you handle failures gracefully:

Code Meaning
unauthenticated User is not authenticated. Please sign in.
permission-denied User does not have permission for this action.
invalid-argument Required field is missing or invalid.
not-found Requested resource was not found.
internal An internal error occurred. Please try again.

Rate Limits

API calls are rate-limited based on your subscription tier:

Standard

100 checks/month

Premium

500 checks/month

Custom

Unlimited

Support

For API support or to request higher rate limits, please contact us through our website.