Overview
🔌 API Reference
🔌 REST API · v1

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.

🏦 Banks & MFIs 🔐 Bearer token auth 📊 JSON responses 🌍 Rwanda · Uganda · Kenya . Tanzania . Ethiopia . Other ⚡ <200ms response time

Endpoint quick reference

GET https://api.flockdash.com/api/v1/lender/score/{slug} Score summary
GET https://api.flockdash.com/api/v1/lender/score/{slug}/full Full detail (full scope)
GET https://api.flockdash.com/api/v1/lender/quota Quota & usage
GET https://flockdash.com/credit/shared/{token} Shared link (no API key)

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.

ℹ️
To request API access, email support@flockdash.com with your institution name, intended use case, and expected monthly call volume. We issue API keys within 2 business days.

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.

HTTP
Authorization: Bearer fos_your_api_key_here
⚠️
Keep your API key secret. Never expose it in client-side code, public repositories, or logs. If your key is compromised, contact support@flockdash.com immediately for revocation and re-issuance.

How authentication works

FlockDash uses a prefix + bcrypt hash scheme for secure key storage. When you send a request:

This means your key cannot be recovered if lost. Rotation issues a new key and immediately revokes the old one.

Base URL & Versioning

Productionhttps://api.flockdash.com/api/v1/lender
Sandboxhttps://sandbox.flockdash.com/api/v1/lender
Content-Typeapplication/json — all responses are JSON
API versionv1 — the version is in the URL path. Breaking changes will be released under v2 with at least 6 months deprecation notice.
💡
The shared score viewer (/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
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"
JavaScript (fetch)
// 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"
Python (requests)
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"
PHP (cURL)
$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.

GET /api/v1/lender/score/{slug} Score summary · 1 quota call

Path parameters

ParameterTypeDescription
slugrequiredstringThe 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

JSON — 200 OK
{
  "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

farm.slugUnique farm identifier. Use this as your primary reference key when storing results in your LOS.
score.overallComposite score 0–100. Weighted average of all five pillars.
score.gradeLetter grade: AAA AA A BBB BB B CCC D. See grade scale section.
score.recommendationMachine-readable decision hint: strong_approve approve conditional review decline. This is advisory — lending decisions remain with your institution.
pillars.*Sub-scores 0–100 for Production (30%), Financial (25%), Consistency (20%), Health (15%), Repayment (10%).
metadata.score_idUnique ULID for this score. Include in your loan file for audit trail purposes.
metadata.batches_analysedNumber of completed production batches used in the calculation. Scores based on fewer than 2 batches have a 15% confidence haircut applied.
metadata.months_of_dataMonths of farm records used. Scores with fewer than 3 months also receive the confidence haircut.

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.

GET /api/v1/lender/score/{slug}/full Full detail · full scope · 1 quota call
⚠️
This endpoint requires the 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)

production_detailPer-batch FCR, mortality %, gross margin, start period. Average FCR, mortality, and benchmark comparisons.
financial_detailTotal revenue, total COGS, gross profit, average margin %, revenue growth period-on-period, cost structure breakdown (feed %, chick %, drug %, labour %).
health_detailTotal health events, resolved count, open count, severe count, event resolution rate %.
flagsArray of human-readable risk flag strings (e.g. "FCR above poor threshold of 2.6"). Empty array if no flags.
strengthsArray of positive signal strings (e.g. "Excellent feed efficiency — FCR 1.7"). Empty array if none.
recommendationsArray of actionable improvement suggestions generated by the scoring model.

Example production_detail object

JSON
"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.

GET /api/v1/lender/quota Quota check · free (0 calls consumed)
JSON — 200 OK
{
  "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.

GET https://flockdash.com/credit/shared/{token} HTML report · no auth · no quota
ℹ️
This endpoint returns an HTML page, not JSON. It is designed to be opened in a browser, not called from your API client. Share tokens expire after 30 days or when the farmer revokes them. A 404 response means the link has expired.
ParameterTypeDescription
tokenrequiredstring (64 chars)The share token from the farmer's share link. Tokens are single-use per farmer per score. The farmer generates a new token each time via their FlockDash dashboard → Farm Health Score → Share tab.

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.

PillarWeightData usedRwandan 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
ℹ️
Data quality haircut: If a farm has fewer than 2 completed batches or fewer than 3 months of data, a 15% confidence reduction is applied to the composite score. The metadata.batches_analysed and metadata.months_of_data fields tell you when this applies.

Grade Scale

GradeScore rangeLabelRecommendationInterpretation
AAA≥ 92Exceptionalstrong_approveTier-1 farm. Excellent across all pillars.
AA85–91Very strongstrong_approveHigh-performance farm with minor gaps.
A75–84StrongapproveWell-managed. Loan approval appropriate.
BBB65–74AdequateapproveGood fundamentals. Standard terms appropriate.
BB55–64ModerateconditionalSome weaknesses. Conditional terms recommended.
B45–54WeakreviewElevated risk. Further due diligence required.
CCC35–44Very weakreviewSignificant concerns. Recommend decline or small pilot loan.
D0–34Default riskdeclineHigh default probability based on current data.
⚠️
The 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 statusConditionerror field
401No Authorization header sent"No API key provided. Send your key as a Bearer token."
401Key not found or bcrypt check fails"Invalid or revoked API key."
403Requesting /full without full scope"Your API key does not have full-report access."
404Farm slug not found or farm not active"Farm not found or not active."
404Farm has no score generated yet"No Farm Health Score generated for this farm yet." + message field with action guidance
429Monthly quota exhausted"Monthly quota exhausted." + quota, used, reset_date fields
200All good

Quota exhaustion error (429)

JSON — 429 Too Many Requests
{
  "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.

PackageCallsPrice (RWF)Per-call rate
Starter50 calls/monthRWF 40,000RWF 800/call
Standard Popular200 calls/monthRWF 140,000RWF 700/call
Professional Best value500 calls/monthRWF 300,000RWF 600/call
Enterprise1,000 calls/monthRWF 500,000RWF 500/call
💡
The 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:

Per-second limit10 requests/second per API key. Burst requests above this are queued for up to 2 seconds, then rejected with 429.
Per-minute limit120 requests/minute per API key.
Concurrent requestsUp to 5 concurrent requests per key. Use a request queue in your integration for batch lookups.

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.

scoreDefault scope. Access to GET /score/{slug} and GET /quota. Returns overall score, grade, recommendation, and five pillar sub-scores.
fullAll of score plus access to GET /score/{slug}/full. Returns production batch detail, financial breakdown, flags, strengths, and recommendations.

Changelog

v1.0 — May 2026Initial release. Score summary endpoint, full detail endpoint, quota endpoint, shared link viewer.

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

  1. At application intake: Ask the borrower for their FlockDash slug (visible in their FlockDash dashboard URL or Settings page).
  2. Check quota: Call GET /quota to confirm calls are available before the lookup.
  3. Fetch score: Call GET /score/{slug}. Store score.overall, score.grade, score.recommendation, and metadata.score_id in your LOS against the application record.
  4. Route the application: Use score.recommendation as a soft routing signal — strong_approve/approve to fast-track review, conditional/review to analyst queue, decline for automated rejection letter with appeal process.
  5. Loan officer view: For manual review cases, display the pillars breakdown. If you have full scope, surface the flags and recommendations arrays to help the analyst ask the right questions.
  6. Record keeping: Store metadata.score_id in 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

JavaScript (Node.js)
// 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.

⚠️
Webhooks are available on the Enterprise package (1,000 calls/month) and above. Contact support@flockdash.com to configure a webhook endpoint for your institution.

Webhook payload

When a farm in your monitored list generates a new score, FlockDash sends a POST request to your endpoint:

JSON — Webhook POST body
{
  "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.

Sandbox base URLhttps://sandbox.flockdash.com/api/v1/lender
AuthenticationUse the sandbox API key issued by FlockDash. It only works against the sandbox URL.
QuotaSandbox calls do not consume real quota. The sandbox quota resets daily.

Test farm slugs

SlugGradeRecommendationUse case
test-farm-aaaAAA (96)strong_approveHappy path — auto-approve flow
test-farm-aA (78)approveStandard approval flow
test-farm-bbBB (62)conditionalConditional approval flow
test-farm-bB (48)reviewManual review flow
test-farm-dD (22)declineDecline flow
test-farm-no-score404 — farm has no score yet
💡
Test all error conditions: 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.