{"openapi":"3.1.0","info":{"title":"Contango Partner API","description":"\n    External API for partner access to Contango data using OAuth2 authentication.\n    \n    ## Authentication\n    \n    This API uses OAuth2 Client Credentials flow for authentication:\n    \n    1. Obtain an access token from `/oauth/token` with your client credentials\n    2. Include the token in the `Authorization` header: `Bearer <token>`\n    3. Tokens expire after 15 minutes (900 seconds)\n\n    Every request, including the one to `/oauth/token`, must send a `User-Agent`\n    header that names your application, for example\n    `User-Agent: YourCompany-Integration/1.0`. Our firewall may refuse a request\n    without one with `403 Forbidden` before it reaches the API, so that response\n    has a plain HTML body rather than JSON. Most HTTP libraries send one by default;\n    some server clients (.NET's `HttpClient`, for one) do not unless you set it.\n    \n    ## Permissions\n    \n    Access is controlled at the customer and resource level. Partners are granted\n    specific permissions (read, write, delete, execute) for specific customers\n    and API endpoints.\n    \n    ## Rate Limiting\n\n    Rate limits may apply to prevent abuse. Contact support if you need higher limits.\n\n    ## Embedding the farmer marketing plan\n\n    You can embed the interactive farmer marketing plan in your own application\n    with a single script tag and a short-lived token. See the dedicated\n    [embed integration guide](/docs/embed) for the full two-call token flow,\n    the loader API, and staging hostnames.\n\n    ## Farm plan data\n\n    Farmers' anticipated production, percent sold and usual delivery location are\n    available as data. See the [farm plan guide](/docs/farm-plans).\n    ","contact":{"name":"Contango API Support","email":"api-support@contango.live"},"license":{"name":"Proprietary"},"version":"1.0.0"},"paths":{"/oauth/token":{"post":{"tags":["Authentication"],"summary":"OAuth2 Token Endpoint","description":"Obtain an access token using Client Credentials grant type. Accepts both form data (RFC 6749) and JSON body.","operationId":"token_endpoint_oauth_token_post","requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"$ref":"#/components/schemas/Body_token_endpoint_oauth_token_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenResponse"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/oauth/health":{"get":{"tags":["Authentication"],"summary":"Health Check","description":"Check if the authentication service is operational","operationId":"health_check_oauth_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/customers":{"get":{"tags":["Customers"],"summary":"List Accessible Customers","description":"Lists all customers the authenticated partner has access to, with their resources","operationId":"list_customers_api_v1_customers_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomersResponse"}}}}},"security":[{"HTTPBearer":[]}]}},"/api/v1/farmer_analytics/{customer_id}":{"get":{"tags":["Farmer Analytics"],"summary":"Farmer Analytics including Best Bid and Margin","description":"Retrieve farmer analytics data for a specific customer","operationId":"get_farmer_analytics_api_v1_farmer_analytics__customer_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"customer_id","in":"path","required":true,"schema":{"type":"string","description":"Customer external API ID (UUID)","title":"Customer Id"},"description":"Customer external API ID (UUID)"},{"name":"crop","in":"query","required":true,"schema":{"type":"string","description":"Crop name (e.g., 'corn', 'soybeans')","title":"Crop"},"description":"Crop name (e.g., 'corn', 'soybeans')"},{"name":"Accept-Encoding","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Accept-Encoding"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmerAnalyticsResponse"}}}},"401":{"description":"Invalid or expired token"},"403":{"description":"Insufficient permissions"},"404":{"description":"Customer or data not found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/embed/token":{"post":{"tags":["Embed"],"summary":"Generate an embed JWT for a single farmer","description":"Exchange a partner JWT (obtained from POST /oauth/token) for a farmer-scoped, short-lived embed JWT. The embed JWT is what the third-party page passes to the widget iframe.","operationId":"generate_embed_token_api_v1_embed_token_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmbedTokenRequest"},"examples":{"default":{"summary":"Editable page (the default)","description":"Omit requested_scopes and you get farm_plan:read plus farm_plan:write wherever your partner account is granted write for this customer, falling back to read-only where it is not. This is the common case and needs no scope field at all.","value":{"customer_id":"1f8e0c5a-0b2a-4f3e-9b6d-2c7e9a1d4f55","farmer_erp_id":"P139329"}},"read_write":{"summary":"Editable page, scopes named explicitly","description":"Same result as the default for a write-granted partner, but stated outright. farm_plan:write does NOT imply farm_plan:read, and the page is read on initial load, so name both. Unlike the default, an explicit scope you were not granted is a 403 rather than a downgrade.","value":{"customer_id":"1f8e0c5a-0b2a-4f3e-9b6d-2c7e9a1d4f55","farmer_erp_id":"P139329","requested_scopes":["farm_plan:read","farm_plan:write"]}},"read_only":{"summary":"Read-only page","description":"Pass farm_plan:read on its own to pin a read-only embed. Omitting requested_scopes no longer does this — it now grants write where you are entitled to it.","value":{"customer_id":"1f8e0c5a-0b2a-4f3e-9b6d-2c7e9a1d4f55","farmer_erp_id":"P139329","requested_scopes":["farm_plan:read"]}}}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmbedTokenResponse"}}}},"400":{"description":"Unknown scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Invalid partner token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Farmer not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"farmer_erp_id matches more than one farmer for this customer. A data fault on our side; retrying will not clear it. Report the farmer_erp_id to Contango support.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/api/v1/locations":{"get":{"tags":["Market Data"],"summary":"List Available Locations","description":"Returns all grain elevator locations available through this API. Each record includes the internal `location_id` used by `/current_bids`. Currently restricted to Indiana locations.","operationId":"list_locations_api_v1_locations_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LocationsResponse"}}}},"401":{"description":"Invalid or expired token"},"403":{"description":"Partner not granted 'bids' read access"},"429":{"description":"Rate limit exceeded"}},"security":[{"HTTPBearer":[]}]}},"/api/v1/current_bids":{"get":{"tags":["Market Data"],"summary":"Get Current Bids","description":"Returns the most recently collected web bids for a given crop and set of locations. Only `source='web'` bids are returned. Currently restricted to Indiana locations.\n\nProvide either `location_ids` **or** (`lat` + `lon` + `radius_km`) — not both. Optionally filter by `delivery_period_start`/`delivery_period_end` **or** `futures_contract_symbol`.","operationId":"get_current_bids_api_v1_current_bids_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"crop","in":"query","required":true,"schema":{"type":"string","description":"Crop name (e.g. 'corn', 'soybeans')","title":"Crop"},"description":"Crop name (e.g. 'corn', 'soybeans')"},{"name":"location_ids","in":"query","required":false,"schema":{"anyOf":[{"type":"array","items":{"type":"integer"}},{"type":"null"}],"description":"Internal location IDs from /locations. Mutually exclusive with lat/lon/radius_km.","title":"Location Ids"},"description":"Internal location IDs from /locations. Mutually exclusive with lat/lon/radius_km."},{"name":"lat","in":"query","required":false,"schema":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"Center latitude for radius search.","title":"Lat"},"description":"Center latitude for radius search."},{"name":"lon","in":"query","required":false,"schema":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"Center longitude for radius search.","title":"Lon"},"description":"Center longitude for radius search."},{"name":"radius_km","in":"query","required":false,"schema":{"anyOf":[{"type":"number"},{"type":"null"}],"description":"Search radius in kilometers. Requires lat and lon.","title":"Radius Km"},"description":"Search radius in kilometers. Requires lat and lon."},{"name":"delivery_period_start","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"description":"Include bids whose delivery period starts on or after this date.","title":"Delivery Period Start"},"description":"Include bids whose delivery period starts on or after this date."},{"name":"delivery_period_end","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"description":"Include bids whose delivery period ends on or before this date.","title":"Delivery Period End"},"description":"Include bids whose delivery period ends on or before this date."},{"name":"futures_contract_symbol","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Filter by futures contract month, e.g. 'ZCZ25'. Mutually exclusive with delivery period.","title":"Futures Contract Symbol"},"description":"Filter by futures contract month, e.g. 'ZCZ25'. Mutually exclusive with delivery period."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BidsResponse"}}}},"400":{"description":"Invalid request parameters"},"401":{"description":"Invalid or expired token"},"403":{"description":"Partner not granted 'bids' read access"},"429":{"description":"Rate limit exceeded"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/saved_searches/{customer_id}":{"get":{"tags":["Saved Searches"],"summary":"List Saved Searches","description":"Returns the customer's shared saved farmer searches, with the current number of matching farmers for the requested crop.\n\nCounts are precomputed and refreshed hourly, so `count_computed_at` tells you how fresh a number is. A search that has not been counted yet returns `count: null`. Counts include only farmers with an ERP id, matching what the farmer-selection endpoint returns.","operationId":"list_saved_searches_api_v1_saved_searches__customer_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"customer_id","in":"path","required":true,"schema":{"type":"string","description":"Customer external API ID (UUID)","title":"Customer Id"},"description":"Customer external API ID (UUID)"},{"name":"crop","in":"query","required":true,"schema":{"type":"string","description":"Crop name (e.g. 'corn', 'soybeans')","title":"Crop"},"description":"Crop name (e.g. 'corn', 'soybeans')"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedSearchListResponse"}}}},"401":{"description":"Invalid or expired token"},"403":{"description":"Partner not granted 'saved_search' read access for this customer"},"404":{"description":"Customer not found"},"429":{"description":"Rate limit exceeded"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/saved_searches/{customer_id}/{saved_search_id}/farmers":{"post":{"tags":["Saved Searches"],"summary":"Select Farmers From a Saved Search","description":"Starts a job that resolves one page of the farmers matching a saved search, and returns a `job_id` to poll.\n\nEach request computes a single page: submit again with the next `page` to continue. Poll the job status endpoint until `status` is `done` or `error`. Results include only farmers with an ERP id, and `total` counts those same farmers across all pages.","operationId":"select_farmers_api_v1_saved_searches__customer_id___saved_search_id__farmers_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"customer_id","in":"path","required":true,"schema":{"type":"string","description":"Customer external API ID (UUID)","title":"Customer Id"},"description":"Customer external API ID (UUID)"},{"name":"saved_search_id","in":"path","required":true,"schema":{"type":"integer","description":"Saved search identifier from the list endpoint","title":"Saved Search Id"},"description":"Saved search identifier from the list endpoint"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SelectFarmersRequest"}}}},"responses":{"202":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobSubmittedResponse"}}}},"401":{"description":"Invalid or expired token"},"403":{"description":"Partner not granted 'saved_search' read access for this customer"},"404":{"description":"Customer or saved search not found"},"429":{"description":"Rate limit exceeded, or too many jobs already running"},"503":{"description":"Saved-search API temporarily unavailable"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/saved_searches/{customer_id}/jobs/{job_id}":{"get":{"tags":["Saved Searches"],"summary":"Get Farmer Selection Job Status","description":"Returns the status of a farmer-selection job.\n\nWhile the job is running, `status` is `pending` — poll again after a short delay. When it finishes, `status` is `done` and the farmers, `total`, and page details are included. Polling a finished job repeatedly is safe and returns the same result until it expires (24 hours). `status: error` is terminal — resubmit the request.","operationId":"get_selection_job_api_v1_saved_searches__customer_id__jobs__job_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"customer_id","in":"path","required":true,"schema":{"type":"string","description":"Customer external API ID (UUID)","title":"Customer Id"},"description":"Customer external API ID (UUID)"},{"name":"job_id","in":"path","required":true,"schema":{"type":"string","description":"Job identifier returned by the selection endpoint","title":"Job Id"},"description":"Job identifier returned by the selection endpoint"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobStatusResponse"}}}},"401":{"description":"Invalid or expired token"},"403":{"description":"Partner not granted 'saved_search' read access for this customer"},"404":{"description":"Job not found, expired, or not owned by this partner"},"429":{"description":"Rate limit exceeded"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/farm_plans/{customer_id}":{"get":{"tags":["Farm Plans"],"summary":"List Farm Plans","description":"Returns the customer's farmers with their usual delivery location and their farm plan per crop and harvest year: acres, yield, anticipated production, percent sold, remaining bushels, break-even and target price.\n\nFilter to one farmer with `erp_id`, and to one crop or harvest year with `crop` / `harvest_year`. Without `harvest_year`, last, this and next harvest year are returned. Results are paged by farmer and include only farmers with an ERP id.","operationId":"list_farm_plans_api_v1_farm_plans__customer_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"customer_id","in":"path","required":true,"schema":{"type":"string","description":"Customer external API ID (UUID)","title":"Customer Id"},"description":"Customer external API ID (UUID)"},{"name":"erp_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","minLength":1,"maxLength":100},{"type":"null"}],"description":"Only this farmer (their ERP id)","title":"Erp Id"},"description":"Only this farmer (their ERP id)"},{"name":"crop","in":"query","required":false,"schema":{"anyOf":[{"type":"string","minLength":1,"maxLength":50},{"type":"null"}],"description":"Only this crop, e.g. 'corn' (any case)","title":"Crop"},"description":"Only this crop, e.g. 'corn' (any case)"},{"name":"harvest_year","in":"query","required":false,"schema":{"anyOf":[{"type":"integer"},{"type":"null"}],"description":"Only this harvest year: last, this or next year","title":"Harvest Year"},"description":"Only this harvest year: last, this or next year"},{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"description":"1-indexed page number","default":1,"title":"Page"},"description":"1-indexed page number"},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":2000,"minimum":1,"description":"Farmers per page (max 2000)","default":500,"title":"Page Size"},"description":"Farmers per page (max 2000)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FarmPlansResponse"}}}},"401":{"description":"Invalid or expired token"},"403":{"description":"Partner not granted 'farm_plan_details' read access for this customer"},"404":{"description":"Customer not found"},"422":{"description":"Invalid filter, e.g. a harvest year outside the supported window"},"429":{"description":"Rate limit exceeded"},"503":{"description":"Farm plan API temporarily unavailable"}}}},"/":{"get":{"tags":["Health"],"summary":"Root endpoint","description":"Basic health check and API information","operationId":"root__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/health":{"get":{"tags":["Health"],"summary":"Health check","description":"Detailed health check for monitoring","operationId":"health_check_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"BidRecord":{"properties":{"bid_id":{"type":"integer","title":"Bid Id","description":"Internal bid record ID"},"location_id":{"type":"integer","title":"Location Id","description":"Internal Contango location ID"},"location_name":{"type":"string","title":"Location Name","description":"Location name"},"company":{"type":"string","title":"Company","description":"Company name"},"crop":{"type":"string","title":"Crop","description":"Crop name (e.g. Corn, Soybeans)"},"basis":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Basis","description":"Basis in $/bu; null unless price_type is 'basis'"},"cash_price":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Cash Price","description":"Flat cash price in $/bu; null for basis-priced bids"},"price_type":{"type":"string","title":"Price Type","description":"'basis' or 'cash'"},"futures_contract":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Futures Contract","description":"Futures contract symbol (e.g. ZCZ25)"},"delivery_start":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Delivery Start","description":"Delivery period start date"},"delivery_end":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Delivery End","description":"Delivery period end date"},"image_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Image Url","description":"Presigned URL of the bid screenshot image"},"collection_date":{"type":"string","title":"Collection Date","description":"ISO 8601 datetime when this price was FIRST observed at this location. It does not advance while the price stays the same -- use last_verified_at for freshness."},"last_verified_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Verified At","description":"ISO 8601 datetime when this price was last confirmed still posted. This is the freshness signal: it advances every time a scrape finds the price unchanged. Always populated; on a bid that has never been re-checked it equals collection_date."}},"type":"object","required":["bid_id","location_id","location_name","company","crop","price_type","collection_date"],"title":"BidRecord","description":"A single posted bid.\n\nExactly one of ``basis``/``cash_price`` carries a value; the other is\n``null`` (both keys are always present in the JSON -- see\n``_posted_price_fields``). ``futures_price`` is deliberately absent from\nthis contract: it is a transient futures-board value, not something the\nelevator posted, so it moves without any bid having changed."},"BidsResponse":{"properties":{"bids":{"items":{"$ref":"#/components/schemas/BidRecord"},"type":"array","title":"Bids"},"count":{"type":"integer","title":"Count"},"crop":{"type":"string","title":"Crop"},"filters_applied":{"additionalProperties":true,"type":"object","title":"Filters Applied"}},"type":"object","required":["bids","count","crop","filters_applied"],"title":"BidsResponse"},"Body_token_endpoint_oauth_token_post":{"properties":{"grant_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Grant Type"},"client_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Id"},"client_secret":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Secret"}},"type":"object","title":"Body_token_endpoint_oauth_token_post"},"CropPlan":{"properties":{"crop":{"type":"string","title":"Crop","description":"Crop name, e.g. 'Corn'"},"harvest_year":{"type":"integer","title":"Harvest Year","description":"Harvest year the plan is for"},"planted_acres":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Planted Acres","description":"Planted acres of this crop"},"total_acres":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Total Acres","description":"The farm's total acres for the harvest year"},"yield_per_acre":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Yield Per Acre","description":"Expected yield, bushels per acre"},"anticipated_production":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Anticipated Production","description":"Anticipated production in bushels: planted_acres x yield_per_acre"},"percent_sold":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Percent Sold","description":"Percent of anticipated production sold, to anyone (0-100). The farmer's own figure when one was entered, otherwise calculated from contracts."},"percent_sold_to_company":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Percent Sold To Company","description":"Percent of anticipated production sold to this customer, from contracts only (0-100)"},"remaining_on_farm":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Remaining On Farm","description":"Bushels still to market. The farmer's own figure when one was entered, otherwise anticipated production minus all contracted bushels."},"break_even_price":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Break Even Price","description":"Break-even price, dollars per bushel"},"target_price":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Target Price","description":"Target price, dollars per bushel"},"entered_fields":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Entered Fields","description":"Which inputs a person entered, from: acres, total_acres, yield, production_cost, target_price, remaining_on_farm. Anything not listed is a default (prior year, USDA county yield, a university budget). `[]` means nothing was entered; `null` means not yet known."},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated At","description":"When this plan's numbers were last recalculated"}},"type":"object","required":["crop","harvest_year"],"title":"CropPlan"},"CustomerAccess":{"properties":{"id":{"type":"string","title":"Id","description":"Customer external API ID (UUID)"},"name":{"type":"string","title":"Name","description":"Customer name"},"resources":{"items":{"$ref":"#/components/schemas/ResourceAccess"},"type":"array","title":"Resources","description":"Available resources and actions"}},"type":"object","required":["id","name","resources"],"title":"CustomerAccess","description":"Customer access information."},"CustomersResponse":{"properties":{"customers":{"items":{"$ref":"#/components/schemas/CustomerAccess"},"type":"array","title":"Customers","description":"List of accessible customers"}},"type":"object","required":["customers"],"title":"CustomersResponse","description":"Response for customers endpoint listing accessible customers.","example":{"customers":[{"id":"550e8400-e29b-41d4-a716-446655440000","name":"Indiana Grain Co","resources":[{"actions":["read"],"resource":"farmer_analytics"}]},{"id":"660e8400-e29b-41d4-a716-446655440001","name":"Middle River Coop","resources":[{"actions":["read"],"resource":"farmer_analytics"},{"actions":["read","write"],"resource":"position_analytics"}]}]}},"DeliveryLocation":{"properties":{"location_id":{"type":"integer","title":"Location Id","description":"Contango location id (the same id the Market Data API uses)"},"name":{"type":"string","title":"Name","description":"Location name"},"erp_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Erp Id","description":"The location's id in your ERP, when one is on file"},"recent_contracts":{"type":"integer","title":"Recent Contracts","description":"Contracts delivering here whose delivery period ended within the lookback window"},"recent_bushels":{"type":"number","title":"Recent Bushels","description":"Bushels on those recent contracts"},"total_contracts":{"type":"integer","title":"Total Contracts","description":"All contracts delivering here, any date"},"last_delivery_end":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Last Delivery End","description":"Latest delivery-period end among those contracts"}},"type":"object","required":["location_id","name","recent_contracts","recent_bushels","total_contracts"],"title":"DeliveryLocation"},"EmbedTokenRequest":{"properties":{"customer_id":{"type":"string","title":"Customer Id","description":"Company.external_api_id (UUID string)"},"farmer_erp_id":{"type":"string","title":"Farmer Erp Id","description":"Partner-facing farmer identifier (Farmer.erp_id)"},"requested_scopes":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Requested Scopes","description":"Subset of farm_plan:read, farm_plan:write. Omit to get write wherever you are granted it, read-only where you are not."}},"type":"object","required":["customer_id","farmer_erp_id"],"title":"EmbedTokenRequest","description":"Body for ``POST /api/v1/embed/token``.\n\n``requested_scopes`` is optional; when omitted we default to\n``farm_plan:read`` plus ``farm_plan:write`` for any partner granted write\non this customer, and to ``farm_plan:read`` alone where they are not — an\nomitted field never fails the mint. A partner that holds\n``farm_plan:write`` may still pin read-only by passing\n``[\"farm_plan:read\"]`` (useful for rendering read-only dashboards that\ndon't need write UI).\n\nNaming a scope explicitly is stricter than omitting the field: an explicit\nscope the partner was not granted is a ``403``, never a downgrade.","examples":[{"customer_id":"1f8e0c5a-0b2a-4f3e-9b6d-2c7e9a1d4f55","farmer_erp_id":"P139329","requested_scopes":["farm_plan:read","farm_plan:write"]}]},"EmbedTokenResponse":{"properties":{"access_token":{"type":"string","title":"Access Token","description":"Signed embed JWT (RS256)"},"token_type":{"type":"string","title":"Token Type","description":"Always 'Bearer'","default":"Bearer"},"expires_in":{"type":"integer","title":"Expires In","description":"Lifetime in seconds"},"scopes":{"items":{"type":"string"},"type":"array","title":"Scopes","description":"Scopes actually granted in this token"}},"type":"object","required":["access_token","expires_in","scopes"],"title":"EmbedTokenResponse","description":"Response shape for ``POST /api/v1/embed/token``.","examples":[{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...","expires_in":7200,"scopes":["farm_plan:read","farm_plan:write"],"token_type":"Bearer"}]},"ErrorResponse":{"properties":{"error":{"type":"string","title":"Error","description":"Error code"},"error_description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Description","description":"Human-readable error description"}},"type":"object","required":["error"],"title":"ErrorResponse","description":"Standard error response.","example":{"error":"invalid_client","error_description":"Invalid client credentials"}},"FarmPlansResponse":{"properties":{"farmers":{"items":{"$ref":"#/components/schemas/FarmerFarmPlan"},"type":"array","title":"Farmers"},"total":{"type":"integer","title":"Total","description":"Farmers matching the filters, across all pages"},"page":{"type":"integer","title":"Page"},"page_size":{"type":"integer","title":"Page Size"},"harvest_years":{"items":{"type":"integer"},"type":"array","title":"Harvest Years","description":"Harvest years included in crop_plans"},"crop":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Crop","description":"Crop filter, when one was given"},"usual_location_lookback_years":{"type":"integer","title":"Usual Location Lookback Years","description":"Years of deliveries that rank delivery_locations (older deliveries break ties)"}},"type":"object","required":["farmers","total","page","page_size","harvest_years","usual_location_lookback_years"],"title":"FarmPlansResponse"},"FarmerAnalyticsResponse":{"properties":{"farmers":{"items":{"$ref":"#/components/schemas/FarmerData"},"type":"array","title":"Farmers","description":"List of farmer analytics"},"metadata":{"additionalProperties":true,"type":"object","title":"Metadata","description":"Optional metadata about the response"}},"type":"object","required":["farmers"],"title":"FarmerAnalyticsResponse","description":"Response for farmer analytics endpoint.","example":{"farmers":[{"best_bid_table":[{"bid":0,"fob":-12.3,"freight":12.3,"location_name":"ADM, Columbus"}],"farmer_erp_id":"P139329","margin":8,"sale_likelihood":"medium","winning_bid":-12}],"metadata":{"crop":"corn","generated_datetime":"2025-10-01T00:00:00Z"}}},"FarmerBid":{"properties":{"location_name":{"type":"string","title":"Location Name","description":"Location name"},"freight":{"type":"number","title":"Freight","description":"Freight cost in cents/bu"},"bid":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Bid","description":"Bid price in cents/bu"},"futures_symbol":{"type":"string","title":"Futures Symbol","description":"Futures contract symbol (e.g., 'ZCZ24' for Dec 2024 Corn)"},"fob":{"type":"number","title":"Fob","description":"FOB (freight-adjusted price) in cents/bu"}},"type":"object","required":["location_name","freight","bid","futures_symbol","fob"],"title":"FarmerBid","description":"Individual bid information for a farmer."},"FarmerData":{"properties":{"farmer_erp_id":{"type":"string","title":"Farmer Erp Id","description":"Farmer ERP ID"},"winning_bid":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Winning Bid","description":"Winning bid in cents (not dollars)"},"winning_bid_location":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Winning Bid Location","description":"Location name of the winning bid"},"winning_bid_futures_symbol":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Winning Bid Futures Symbol","description":"Futures contract symbol for the winning bid (e.g., 'ZCZ24' for Dec 2024 Corn)"},"margin":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Margin","description":"Margin in cents (not dollars)"},"freight":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Freight","description":"Freight cost for the winning bid in cents/bu"},"sale_likelihood":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sale Likelihood","description":"Sale likelihood: low/medium/high"},"market_share":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Market Share","description":"Market share estimate as decimal (0-1)"},"best_bid_table":{"items":{"$ref":"#/components/schemas/FarmerBid"},"type":"array","title":"Best Bid Table","description":"Bids sorted by FOB value (first element is winning bid)"}},"type":"object","required":["farmer_erp_id"],"title":"FarmerData","description":"Farmer analytics data."},"FarmerFarmPlan":{"properties":{"erp_id":{"type":"string","title":"Erp Id","description":"Farmer's ERP id"},"name":{"type":"string","title":"Name","description":"Farmer name"},"erp_id_ambiguous":{"type":"boolean","title":"Erp Id Ambiguous","description":"True when more than one farmer record carries this ERP id; each is returned separately"},"usual_location":{"anyOf":[{"$ref":"#/components/schemas/DeliveryLocation"},{"type":"null"}],"description":"The location this farmer usually delivers to (the first of delivery_locations)"},"delivery_locations":{"items":{"$ref":"#/components/schemas/DeliveryLocation"},"type":"array","title":"Delivery Locations","description":"Every one of the customer's locations this farmer has delivered to, most used first"},"crop_plans":{"items":{"$ref":"#/components/schemas/CropPlan"},"type":"array","title":"Crop Plans","description":"One entry per crop and harvest year"}},"type":"object","required":["erp_id","name","erp_id_ambiguous","delivery_locations","crop_plans"],"title":"FarmerFarmPlan"},"FarmerRecord":{"properties":{"erp_id":{"type":"string","title":"Erp Id","description":"Farmer's ERP id (system-of-record id from your ERP)"},"name":{"type":"string","title":"Name","description":"Farmer name"}},"type":"object","required":["erp_id","name"],"title":"FarmerRecord"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"JobStatusResponse":{"properties":{"status":{"type":"string","title":"Status","description":"'pending', 'done', or 'error'"},"farmers":{"anyOf":[{"items":{"$ref":"#/components/schemas/FarmerRecord"},"type":"array"},{"type":"null"}],"title":"Farmers"},"total":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total","description":"Total matching farmers across all pages"},"page":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Page"},"page_size":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Page Size"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error","description":"Error code when status is 'error'"}},"type":"object","required":["status"],"title":"JobStatusResponse"},"JobSubmittedResponse":{"properties":{"status":{"type":"string","title":"Status","description":"Always 'pending' — poll the job for the result","default":"pending"},"job_id":{"type":"string","title":"Job Id","description":"Opaque job identifier; pass to the job status endpoint"}},"type":"object","required":["job_id"],"title":"JobSubmittedResponse"},"LocationRecord":{"properties":{"location_id":{"type":"integer","title":"Location Id","description":"Internal Contango location ID"},"name":{"type":"string","title":"Name","description":"Location name"},"company":{"type":"string","title":"Company","description":"Company name"},"lat":{"type":"string","title":"Lat","description":"Latitude"},"lon":{"type":"string","title":"Lon","description":"Longitude"},"state":{"type":"string","title":"State","description":"US state code (e.g. 'IN')"}},"type":"object","required":["location_id","name","company","lat","lon","state"],"title":"LocationRecord"},"LocationsResponse":{"properties":{"locations":{"items":{"$ref":"#/components/schemas/LocationRecord"},"type":"array","title":"Locations"},"count":{"type":"integer","title":"Count"}},"type":"object","required":["locations","count"],"title":"LocationsResponse"},"ResourceAccess":{"properties":{"resource":{"type":"string","title":"Resource","description":"Resource name (e.g., 'farmer_analytics')"},"actions":{"items":{"type":"string"},"type":"array","title":"Actions","description":"Allowed actions (e.g., ['read', 'write'])"}},"type":"object","required":["resource","actions"],"title":"ResourceAccess","description":"Resource access information."},"SavedSearchListResponse":{"properties":{"saved_searches":{"items":{"$ref":"#/components/schemas/SavedSearchRecord"},"type":"array","title":"Saved Searches"},"count":{"type":"integer","title":"Count","description":"Number of saved searches returned"},"crop":{"type":"string","title":"Crop"}},"type":"object","required":["saved_searches","count","crop"],"title":"SavedSearchListResponse"},"SavedSearchRecord":{"properties":{"saved_search_id":{"type":"integer","title":"Saved Search Id","description":"Saved search identifier, used to select farmers"},"name":{"type":"string","title":"Name","description":"Saved search name as shown in Contango"},"count":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Count","description":"Farmers with an ERP id matching this search for the requested crop. `null` when no count has been computed yet for this search and crop."},"count_computed_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Count Computed At","description":"ISO 8601 timestamp of when `count` was computed; `null` when `count` is null."}},"type":"object","required":["saved_search_id","name"],"title":"SavedSearchRecord"},"SelectFarmersRequest":{"properties":{"crop":{"type":"string","title":"Crop","description":"Crop name, e.g. 'corn' or 'soybeans'"},"page":{"type":"integer","minimum":1.0,"title":"Page","description":"1-indexed page number","default":1},"page_size":{"type":"integer","maximum":2000.0,"minimum":1.0,"title":"Page Size","description":"Rows per page (max 2000)","default":500}},"type":"object","required":["crop"],"title":"SelectFarmersRequest"},"TokenResponse":{"properties":{"access_token":{"type":"string","title":"Access Token","description":"JWT access token"},"token_type":{"type":"string","title":"Token Type","description":"Token type (always 'Bearer')","default":"Bearer"},"expires_in":{"type":"integer","title":"Expires In","description":"Token expiration time in seconds"},"scope":{"type":"string","title":"Scope","description":"Granted scopes"}},"type":"object","required":["access_token","expires_in","scope"],"title":"TokenResponse","description":"OAuth2 token response.","example":{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...","expires_in":900,"scope":"api:read","token_type":"Bearer"}},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}}}