FlockDash Lender API
Integrate verified farm credit scores directly into your loan origination system. Access production performance, financial history, and creditworthiness assessments for smallholder farmers in East Africa — all derived from real, verified farm management records.
Endpoint quick reference
Overview
The FlockDash Lender API gives financial institutions programmatic access to the Farm Health Score — a verified creditworthiness rating derived from a farm's actual production and financial records. Unlike self-reported income figures, FlockDash scores are based on data entered daily by the farmer: feed consumption, weight records, mortality logs, sales orders, and health events.
Banks and MFIs in Rwanda, Uganda, and Kenya use this data to make faster, better-informed lending decisions for smallholder farmers who lack traditional credit history.
Authentication
All API requests must include your API key as a Bearer token in the Authorization header. API keys are issued by FlockDash Africa and are scoped to your institution.
Authorization: Bearer fos_your_api_key_here
How authentication works
FlockDash uses a prefix + bcrypt hash scheme for secure key storage. When you send a request:
- The server reads the first 8 characters of your key (the prefix) to pre-filter the database
- It then runs a
bcrypt verifyagainst the stored hash of the full key - The raw key is never stored — only the hash
This means your key cannot be recovered if lost. Rotation issues a new key and immediately revokes the old one.
Base URL & Versioning
application/json — all responses are JSON/credit/shared/{token}) is on the main domain (flockdash.com), not api.flockdash.com. It returns an HTML page, not JSON, and requires no API key.Quick Start (5 minutes)
Make your first API call in under 5 minutes using cURL or any HTTP client.
curl -X GET \ "https://api.flockdash.com/api/v1/lender/score/green-hills-farm" \ -H "Authorization: Bearer fos_your_api_key_here" \ -H "Accept: application/json"
// Node.js or browser (with CORS enabled) const response = await fetch( 'https://api.flockdash.com/api/v1/lender/score/green-hills-farm', { headers: { 'Authorization': 'Bearer fos_your_api_key_here', 'Accept': 'application/json', } } ); const data = await response.json(); console.log(data.score.grade); // "AA"
import requests API_KEY = "fos_your_api_key_here" FARM_SLUG = "green-hills-farm" response = requests.get( f"https://api.flockdash.com/api/v1/lender/score/{FARM_SLUG}", headers={ "Authorization": f"Bearer {API_KEY}", "Accept": "application/json", } ) data = response.json() print(data["score"]["grade"]) # "AA"
$apiKey = 'fos_your_api_key_here'; $farmSlug = 'green-hills-farm'; $url = "https://api.flockdash.com/api/v1/lender/score/{$farmSlug}"; $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "Authorization: Bearer {$apiKey}", "Accept: application/json", ], ]); $body = curl_exec($ch); curl_close($ch); $data = json_decode($body, true); echo $data['score']['grade']; // "AA"
GET /score/{slug} — Score Summary
Returns the latest Farm Health Score for a farm, identified by its unique slug. This is the most commonly used endpoint for loan assessment workflows. Consumes 1 quota call.
Path parameters
| Parameter | Type | Description |
|---|---|---|
| slugrequired | string | The farm's unique identifier on FlockDash. The farmer can find their slug in Settings → Farm Profile → Farm slug, or in the URL of their FlockDash dashboard (e.g. app.flockdash.com/green-hills-farm). |
Example response
{
"farm": {
"name": "Green Hills Farm Ltd",
"slug": "green-hills-farm",
"country": "Rwanda"
},
"score": {
"overall": 82,
"grade": "AA",
"grade_label": "Very strong",
"recommendation": "approve",
"recommendation_label": "Approve"
},
"pillars": {
"production": 88,
"financial": 79,
"consistency": 84,
"health": 91,
"repayment": 72
},
"metadata": {
"score_id": "01hx8kz...",
"generated_at": "2026-05-10T08:23:11+00:00",
"batches_analysed": 7,
"months_of_data": 14,
"data_from": "2025-03-01",
"data_to": "2026-05-10"
}
}Response fields
AAA AA A BBB BB B CCC D. See grade scale section.strong_approve approve conditional review decline. This is advisory — lending decisions remain with your institution.GET /score/{slug}/full — Full Score Detail
Returns the complete score with pillar-level detail, batch performance data, financial breakdown, risk flags, strengths, and improvement recommendations. Requires the full scope on your API key. Consumes 1 quota call.
full scope. If your key only has the default score scope, you will receive a 403 Forbidden error. Contact support@flockdash.com to enable this scope.Additional response fields (beyond summary)
Example production_detail object
"production_detail": { "avg_fcr": 1.87, "avg_mortality": 2.4, "fcr_score": 92, "mort_score": 88, "batch_count": 7, "fcr_benchmark": 1.9, "mort_benchmark": 3.0, "batches": [ { "code": "BATCH-2026-007", "species": "Chicken", "fcr": 1.82, "mortality_pct": 2.1, "margin_pct": 23.4, "start": "Feb 2026" } ] }
GET /quota — Quota Status
Returns your current API key's quota status. Does not consume a quota call. Use this before processing a batch of loan applications to confirm you have sufficient calls remaining.
{
"lender": "Bank of Kigali",
"monthly_quota": 500,
"calls_used": 127,
"calls_remaining": 373,
"reset_date": "2026-06-01"
}GET /credit/shared/{token} — Shared Score (No Auth)
Farmers can generate a time-limited share link from their FlockDash dashboard and send it to a loan officer. This endpoint serves the HTML report — it requires no API key, just the token from the URL. Does not consume quota.
Score Model — How Scores Are Calculated
The Farm Health Score is a weighted composite of five pillars, each drawing on a different dimension of farm management data recorded in FlockDash. No self-reported figures are used — all inputs come from daily operational records.
| Pillar | Weight | Data used | Rwandan benchmarks |
|---|---|---|---|
| Production | 30% | FCR (feed:weight ratio), mortality rate per batch | FCR ≤1.9 = excellent; ≥2.6 = poor. Mortality ≤3% = excellent; ≥8% = poor |
| Financial | 25% | Gross margin %, revenue growth period-over-period | Margin ≥20% = good; ≤5% = struggling. Revenue growth bonus/penalty ±15pts |
| Consistency | 20% | Coefficient of variation in margins and mortality; data density | Lower variance = higher score. Minimum 2 completed batches needed for reliable assessment |
| Health | 15% | Health event resolution rate, open events, severe events | 100% resolution = 100 pts. −5 pts per open event; −4 pts per severe event |
| Repayment | 10% | Ratio of paid to total sales orders | Paid rate 100% = 100 pts. Partial credit at 50% weight |
metadata.batches_analysed and metadata.months_of_data fields tell you when this applies.Grade Scale
| Grade | Score range | Label | Recommendation | Interpretation |
|---|---|---|---|---|
| AAA | ≥ 92 | Exceptional | strong_approve | Tier-1 farm. Excellent across all pillars. |
| AA | 85–91 | Very strong | strong_approve | High-performance farm with minor gaps. |
| A | 75–84 | Strong | approve | Well-managed. Loan approval appropriate. |
| BBB | 65–74 | Adequate | approve | Good fundamentals. Standard terms appropriate. |
| BB | 55–64 | Moderate | conditional | Some weaknesses. Conditional terms recommended. |
| B | 45–54 | Weak | review | Elevated risk. Further due diligence required. |
| CCC | 35–44 | Very weak | review | Significant concerns. Recommend decline or small pilot loan. |
| D | 0–34 | Default risk | decline | High default probability based on current data. |
recommendation field is advisory only. All lending decisions remain the sole responsibility of the financial institution. FlockDash Africa provides data, not credit decisions.Error Codes
All error responses follow the same JSON structure: { "error": "Human-readable message" }. Some errors include additional fields.
| HTTP status | Condition | error field |
|---|---|---|
| 401 | No Authorization header sent | "No API key provided. Send your key as a Bearer token." |
| 401 | Key not found or bcrypt check fails | "Invalid or revoked API key." |
| 403 | Requesting /full without full scope | "Your API key does not have full-report access." |
| 404 | Farm slug not found or farm not active | "Farm not found or not active." |
| 404 | Farm has no score generated yet | "No Farm Health Score generated for this farm yet." + message field with action guidance |
| 429 | Monthly quota exhausted | "Monthly quota exhausted." + quota, used, reset_date fields |
| 200 | All good | — |
Quota exhaustion error (429)
{
"error": "Monthly quota exhausted.",
"quota": 200,
"used": 200,
"reset_date": "2026-06-01"
}When you receive a 429, log the reset_date in your system. You can purchase a top-up via the Lender Portal or email support@flockdash.com.
Quota & Billing
API calls are priced per-call with monthly quotas. Your quota resets on the 1st of each calendar month (East Africa Time). Top-ups can be purchased at any time and are added immediately to your monthly quota.
| Package | Calls | Price (RWF) | Per-call rate |
|---|---|---|---|
| Starter | 50 calls/month | RWF 40,000 | RWF 800/call |
| Standard Popular | 200 calls/month | RWF 140,000 | RWF 700/call |
| Professional Best value | 500 calls/month | RWF 300,000 | RWF 600/call |
| Enterprise | 1,000 calls/month | RWF 500,000 | RWF 500/call |
GET /quota endpoint does not consume a call. Call it before processing a batch of loan applications to confirm you have enough headroom. Set up a cron alert in your LOS when calls_remaining drops below 20.Rate Limits
In addition to monthly quotas, the following per-second and per-minute limits apply:
Response headers include rate-limit context: X-RateLimit-Remaining, X-RateLimit-Reset. Implement exponential backoff with jitter when you receive a 429 rate-limit response.
API Key Scopes
Each API key is issued with one or more scopes that control access level. Contact support@flockdash.com to request additional scopes.
GET /score/{slug} and GET /quota. Returns overall score, grade, recommendation, and five pillar sub-scores.score plus access to GET /score/{slug}/full. Returns production batch detail, financial breakdown, flags, strengths, and recommendations.Changelog
LOS Integration Guide
This guide shows how to integrate FlockDash scores into a typical Loan Origination System (LOS) workflow. The goal is to pull the score automatically when a loan application is received and attach it to the borrower's file.
Recommended integration flow
- At application intake: Ask the borrower for their FlockDash slug (visible in their FlockDash dashboard URL or Settings page).
- Check quota: Call
GET /quotato confirm calls are available before the lookup. - Fetch score: Call
GET /score/{slug}. Storescore.overall,score.grade,score.recommendation, andmetadata.score_idin your LOS against the application record. - Route the application: Use
score.recommendationas a soft routing signal —strong_approve/approveto fast-track review,conditional/reviewto analyst queue,declinefor automated rejection letter with appeal process. - Loan officer view: For manual review cases, display the
pillarsbreakdown. If you havefullscope, surface theflagsandrecommendationsarrays to help the analyst ask the right questions. - Record keeping: Store
metadata.score_idin your loan file. This allows FlockDash support to pull the exact score snapshot used for your decision if ever needed for audit or dispute purposes.
Complete Node.js integration example
// flockdash-client.js — reusable FlockDash API client const BASE_URL = 'https://api.flockdash.com/api/v1/lender'; const API_KEY = process.env.FLOCKDASH_API_KEY; // store in env, never hardcode async function flockdashRequest(path) { const res = await fetch(`${BASE_URL}${path}`, { headers: { 'Authorization': `Bearer ${API_KEY}`, 'Accept': 'application/json', }, }); if (!res.ok) { const err = await res.json(); throw new Error(`FlockDash API ${res.status}: ${err.error}`); } return res.json(); } // Check quota before processing a batch async function checkQuota() { const q = await flockdashRequest('/quota'); if (q.calls_remaining < 5) { console.warn('⚠️ Low quota:', q.calls_remaining, 'calls remaining'); } return q; } // Fetch and attach score to a loan application async function attachScoreToApplication(application) { const { flockdashSlug, applicationId } = application; try { const data = await flockdashRequest(`/score/${flockdashSlug}`); return { applicationId, flockdashScoreId: data.metadata.score_id, overallScore: data.score.overall, grade: data.score.grade, recommendation: data.score.recommendation, batchesAnalysed: data.metadata.batches_analysed, monthsOfData: data.metadata.months_of_data, scoredAt: data.metadata.generated_at, pillars: data.pillars, // Routing signal autoApprove: ['strong_approve', 'approve'].includes(data.score.recommendation), requiresReview: ['conditional', 'review'].includes(data.score.recommendation), }; } catch (err) { // Score not available — flag for manual assessment return { applicationId, error: err.message, requiresManual: true }; } } module.exports = { checkQuota, attachScoreToApplication };
Webhook Setup
FlockDash can notify your system when a farm generates a new score — useful for proactively refreshing scores for farms you have existing loans with.
Webhook payload
When a farm in your monitored list generates a new score, FlockDash sends a POST request to your endpoint:
{
"event": "score.generated",
"farm_slug": "green-hills-farm",
"score_id": "01hx8kz...",
"grade": "AA",
"overall": 82,
"generated_at": "2026-05-10T08:23:11+00:00"
}Verify the authenticity of webhook calls by checking the X-FlockDash-Signature header (HMAC-SHA256 of the request body using your webhook secret).
Sandbox & Testing
A sandbox environment is available for integration testing. The sandbox is pre-populated with five test farms with different score profiles.
Test farm slugs
| Slug | Grade | Recommendation | Use case |
|---|---|---|---|
test-farm-aaa | AAA (96) | strong_approve | Happy path — auto-approve flow |
test-farm-a | A (78) | approve | Standard approval flow |
test-farm-bb | BB (62) | conditional | Conditional approval flow |
test-farm-b | B (48) | review | Manual review flow |
test-farm-d | D (22) | decline | Decline flow |
test-farm-no-score | — | — | 404 — farm has no score yet |
test-farm-no-score returns a 404. Use an invalid Bearer token to test 401 handling. Set your sandbox quota to 0 to test 429 quota-exhaustion handling.