AgricVue Docs
Developer API

Integration Guide for Partners

Authenticate with API keys, subscribe to real-time webhook events, and build integrations that respond to farm activity as it happens.

Quick Start

Four steps to start receiving events from AgricVue.

  1. 1

    Create an API Key

    In the AgricVue dashboard go to Settings → API Keys. Create a key with the "webhooks" scope.

  2. 2

    Authenticate

    Include the key in every request as X-API-Key header.

  3. 3

    Create a Webhook Subscription

    POST to /api/v1/webhooks with your URL and the event types you want. Save the signing_secret returned in the response.

  4. 4

    Receive Events

    AgricVue will POST JSON payloads to your URL with HMAC-SHA256 signatures for verification.

Authentication

All API requests require an X-API-Key header.

curl -H "X-API-Key: agr_sk_your_key_here" \
     https://api.agricvue.com/api/v1/farms

Scopes

ScopeAccess
farmsCreate, read, update, delete farms
analysesTrigger and view suitability analyses
reportsGenerate and download reports
monitoringVegetation monitoring and disease detection
billingSubscription and payment management
credit-scoringCredit score computation and access
webhooksWebhook subscription management

Rate Limits: Default is 1,000 requests/hour per key. Contact us to increase limits for high-volume integrations.

Webhook Setup

Create a Subscription

curl -X POST https://api.agricvue.com/api/v1/webhooks \
  -H "X-API-Key: agr_sk_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-server.com/webhooks/agricvue",
    "event_types": ["farm.created", "monitoring.completed", "harvest.ready"],
    "description": "Production webhook"
  }'

Response includes a signing_secret shown only once. Store it securely for verifying incoming payloads.

Manage Subscriptions

MethodEndpointDescription
POST/api/v1/webhooksCreate subscription
GET/api/v1/webhooksList subscriptions
GET/api/v1/webhooks/{id}Get details + delivery logs
PATCH/api/v1/webhooks/{id}Update URL, events, or status
DELETE/api/v1/webhooks/{id}Delete subscription
POST/api/v1/webhooks/{id}/testSend test ping

Event Types Reference

Subscribe to one or more of these events.

farm.createdA new farm is registered
{
  "event": "farm.created",
  "event_id": "uuid",
  "timestamp": "2026-03-19T10:00:00Z",
  "data": {
    "farm_id": "uuid",
    "name": "Adekunle Rice Farm",
    "area_hectares": 12.5,
    "location": "Kebbi State",
    "country": "Nigeria"
  }
}
farm.updatedFarm details are modified
{
  "event": "farm.updated",
  "event_id": "uuid",
  "timestamp": "2026-03-19T10:00:00Z",
  "data": {
    "farm_id": "uuid",
    "name": "Adekunle Rice Farm",
    "changes": ["farm_name", "current_use"]
  }
}
monitoring.completedVegetation monitoring finishes for a farm
{
  "event": "monitoring.completed",
  "event_id": "uuid",
  "timestamp": "2026-03-19T10:00:00Z",
  "data": {
    "farm_id": "uuid",
    "result_id": "uuid",
    "ndvi": 0.72,
    "health_status": "healthy",
    "trend": "improving"
  }
}
harvest.readyHarvest readiness score >= 75%
{
  "event": "harvest.ready",
  "event_id": "uuid",
  "timestamp": "2026-03-19T10:00:00Z",
  "data": {
    "farm_id": "uuid",
    "score": 82,
    "crop": "rice",
    "estimated_date": "2026-04-15"
  }
}
disease.detectedDisease detection completes
{
  "event": "disease.detected",
  "event_id": "uuid",
  "timestamp": "2026-03-19T10:00:00Z",
  "data": {
    "farm_id": "uuid",
    "disease": "Rice Blast",
    "confidence": 0.94,
    "severity": "moderate"
  }
}
weather.advisoryDaily weather advisory generated
{
  "event": "weather.advisory",
  "event_id": "uuid",
  "timestamp": "2026-03-19T10:00:00Z",
  "data": {
    "farm_id": "uuid",
    "advisory_id": "uuid",
    "severity": "warning",
    "summary": "Heavy rainfall expected (45mm) in next 24h..."
  }
}
analysis.completedSuitability analysis finishes
{
  "event": "analysis.completed",
  "event_id": "uuid",
  "timestamp": "2026-03-19T10:00:00Z",
  "data": {
    "farm_id": "uuid",
    "analysis_id": "uuid",
    "score": 78.5,
    "class": "suitable"
  }
}
credit_score.updatedCredit score is computed for a farm
{
  "event": "credit_score.updated",
  "event_id": "uuid",
  "timestamp": "2026-03-19T10:00:00Z",
  "data": {
    "farm_id": "uuid",
    "score": 72,
    "risk_class": "good"
  }
}

Webhook Security

Every webhook delivery includes an X-AgricVue-Signature header containing an HMAC-SHA256 signature of the payload body. Always verify this before processing.

Headers Sent

HeaderValue
X-AgricVue-Signaturesha256=<hex_digest>
X-AgricVue-EventEvent type (e.g. farm.created)
X-AgricVue-DeliveryUnique delivery UUID (for idempotency)

Verification Examples

Python

import hmac, hashlib

def verify_webhook(payload_bytes: bytes, secret: str, signature_header: str) -> bool:
    expected = hmac.new(
        secret.encode("utf-8"), payload_bytes, hashlib.sha256
    ).hexdigest()
    received = signature_header.removeprefix("sha256=")
    return hmac.compare_digest(expected, received)

Node.js

const crypto = require("crypto");

function verifyWebhook(body, secret, signatureHeader) {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(body)
    .digest("hex");
  const received = signatureHeader.replace("sha256=", "");
  return crypto.timingSafeEqual(
    Buffer.from(expected), Buffer.from(received)
  );
}

Go

import (
    "crypto/hmac"
    "crypto/sha256"
    "encoding/hex"
    "strings"
)

func VerifyWebhook(body []byte, secret, sigHeader string) bool {
    mac := hmac.New(sha256.New, []byte(secret))
    mac.Write(body)
    expected := hex.EncodeToString(mac.Sum(nil))
    received := strings.TrimPrefix(sigHeader, "sha256=")
    return hmac.Equal([]byte(expected), []byte(received))
}

Delivery & Retries

1st attempt

Immediate

Sent as soon as the event fires

2nd attempt

+5 minutes

First retry after a failed delivery

3rd attempt

+30 minutes

Final retry attempt

  • Success:Any 2xx HTTP status code
  • Timeout:10 seconds per attempt
  • Payload limit:Response body is truncated to 2,000 characters in logs

Error Handling

The API returns standard HTTP status codes with JSON error bodies.

{
  "detail": "API key does not have the 'webhooks' scope"
}
StatusMeaning
400Invalid request body or parameters
401Missing or invalid API key
403API key lacks required scope
404Resource not found
422Validation error (e.g. invalid event types)
429Rate limit exceeded
500Internal server error

Testing

Use the test endpoint to send a ping event to your webhook URL without waiting for a real event to fire.

curl -X POST https://api.agricvue.com/api/v1/webhooks/{id}/test \
  -H "X-API-Key: agr_sk_your_key_here"

The test endpoint sends a synchronous request and returns the result immediately:

{
  "success": true,
  "status_code": 200,
  "error": null
}

Tip: Use webhook.site to get a temporary URL for testing during development.

Lender API

Lender Portfolio Monitoring

Continuous visibility into crop health across your entire loan book. Authenticated via X-API-Key (lender API keys, format: agr_live_...).

MethodEndpointDescription
GET/api/v1/lender/portfolio/summaryAggregated portfolio: avg score, risk distribution, farms needing attention
GET/api/v1/lender/portfolio/farmsAll farms with scores, deltas, health. Filterable by risk_class, score range
GET/api/v1/lender/portfolio/watchlistFarms below score floor or with critical health
GET/api/v1/lender/portfolio/alertsScore deterioration alerts with severity and context
GET/api/v1/lender/portfolio/analyticsRisk reduction proof: intervention rates, recovery, trajectory, insurance absorption
GET/api/v1/lender/portfolio/advisoriesAdvisory delivery metrics across portfolio
GET/api/v1/lender/portfolio/farms/{id}/timeline26-week score + NDVI + health sparkline data
GET/api/v1/lender/portfolio/farms/{id}/advisoriesAdvisory history for a single farm
GET/api/v1/lender/portfolio/settingsGet alert threshold configuration
POST/api/v1/lender/portfolio/settingsConfigure score floor, drop threshold, webhook URL, email recipients
Insurance API

Parametric Insurance Data API

Weekly crop stress indices, risk profiles, and automatic claim triggering for insurers. Authenticated via X-API-Key (insurer keys, format: agr_ins_...).

MethodEndpointDescription
GET/api/v1/insurance/data/farms/{id}/stress-indicesWeekly crop stress: NDVI, flood score, rainfall, temperature, disease
GET/api/v1/insurance/data/farms/{id}/risk-profileAggregated risk profile for underwriting
GET/api/v1/insurance/data/farms/{id}/triggersCheck parametric triggers against policy thresholds
POST/api/v1/insurance/data/policiesCreate insurance policy for a farm
GET/api/v1/insurance/data/policies/{id}/claimsList claims for a policy
GET/api/v1/insurance/claims/{id}Full claim detail with satellite evidence
GET/api/v1/insurance/claims/{id}/evidenceSatellite evidence package for a claim
POST/api/v1/insurance/claims/{id}/approveApprove claim with adjuster notes
POST/api/v1/insurance/claims/{id}/rejectReject claim with reason
POST/api/v1/insurance/claims/{id}/mark-paidMark approved claim as paid

Parametric Triggers

Claims auto-trigger when satellite data crosses these thresholds (configurable per policy):

TriggerDefault ThresholdData Source
DroughtNDVI < 0.2 for 3 consecutive weeksSentinel-2 / Sentinel-1 radar
FloodFlood score >= 0.55Sentinel-1 radar backscatter
Pest/DiseaseSeverity >= severeDisease detection AI
Excess RainRainfall >= 200mm in 7 daysOpen-Meteo / NASA POWER
Heat StressTemperature >= 40C for 3 daysOpen-Meteo weather data
Verification & Compliance

Farm Verification & Compliance Reports

Fraud detection scores, satellite-verified land use proof, and regulatory compliance exports.

MethodEndpointDescription
GET/api/v1/verification/farms/{id}/verificationFarm verification score + fraud flags + boundary history
GET/api/v1/verification/portfolio/verificationPortfolio-wide verification scores, filterable
POST/api/v1/compliance/reportsGenerate CBN, DFI impact, or land use verification report
GET/api/v1/compliance/reportsList generated compliance reports
GET/api/v1/compliance/reports/{id}/downloadDownload report CSV
GET/api/v1/verify/{certificate_number}Public certificate verification (no auth, for QR codes)

Verification Score Components

ComponentWeightWhat It Checks
Crop Presence30%Satellite-detected crop pixels vs registered boundary
Boundary Consistency20%Has boundary changed since registration?
Monitoring Continuity15%Regular satellite observations or suspicious gaps?
Data Quality15%Cloud cover, valid pixel percentage
Claim Consistency10%Do claims match satellite data?
Identity10%Farm age, management events, activity level

Fraud Flag Types

phantom_farm

Crop pixel fraction < 15% for 3+ monitoring cycles

boundary_changed

Boundary modified >20% from registration snapshot

claim_contradicts_satellite

Claim filed when certificate shows healthy crop

excessive_claims

More than 5 claims on same farm

suspicious_area

Area changed >50% from original

data_quality_insufficient

Claim triggers based on degraded satellite data

Compliance Report Types

cbn_portfolio

CBN Portfolio

Land use proof, loan performance, risk distribution, fraud summary. CSV export.

dfi_impact

DFI Impact

NDVI trends, predicted vs actual yield, insurance enrollment, claims paid.

land_use_verification

Land Use Verification

Per-farm satellite evidence: certificate, verification score, monitoring readings.

Farmer API

Community Alerts, Insurance & Certificates

Farmer-facing endpoints for disease alerts, insurance enrollment, and harvest certificates. Authenticated via JWT or tenant API key.

MethodEndpointDescription
GET/api/v1/community/farms/{id}/alertsDisease alerts within 75km of farm
POST/api/v1/community/alerts/{id}/confirmConfirm, dismiss, or mark 'not seen'
GET/api/v1/community/outbreaks/heatmapOutbreak clusters + GeoJSON for map
POST/api/v1/insurance/farms/{id}/enrollOne-tap insurance enrollment
GET/api/v1/insurance/farms/{id}/policiesList insurance policies
GET/api/v1/insurance/farms/{id}/claimsList insurance claims
POST/api/v1/farms/{id}/certificatesIssue a harvest certificate
GET/api/v1/farms/{id}/certificatesList certificates for a farm
POST/api/v1/farms/{id}/harvest-outcomesRecord actual post-harvest yield