{
  "openapi": "3.1.0",
  "info": {
    "title": "MassGain Market Data API",
    "version": "1.0.0",
    "description": "Read-only access to published MassGain potato-market data. The sandbox trial includes 100 actions for 15 days. Successful data calls use one action. Verification, usage, empty results, errors, and idempotent replays use zero actions.",
    "contact": {
      "url": "https://massgain.world/contact"
    }
  },
  "externalDocs": {
    "url": "https://massgain.world/developers/api"
  },
  "servers": [
    {
      "url": "https://massgain.world/developers/api/v1",
      "description": "Sandbox"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/verify": {
      "get": {
        "operationId": "verifyKey",
        "summary": "Verify the sandbox key",
        "parameters": [],
        "responses": {
          "200": {
            "$ref": "#/components/responses/VerificationResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Read the trial balance",
        "parameters": [],
        "responses": {
          "200": {
            "$ref": "#/components/responses/UsageOnlyResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/datasets": {
      "get": {
        "operationId": "listDatasets",
        "summary": "List available market datasets",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/DatasetCatalogResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/datasets/{id}": {
      "get": {
        "operationId": "inspectDataset",
        "summary": "Inspect dataset fields and source",
        "description": "Use query.<parameter> to scope a dataset using the parameters returned by /datasets.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Dataset identifier from /datasets.",
            "schema": {
              "type": "string",
              "example": "us_shipments"
            }
          },
          {
            "name": "path",
            "in": "query",
            "description": "Field path from dataset inspection.",
            "schema": {
              "type": "string",
              "maxLength": 160
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/DatasetInspectionResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/datasets/{id}/observations": {
      "get": {
        "operationId": "listObservations",
        "summary": "Read bounded dataset observations",
        "description": "Use query.<parameter> to scope the source and filter.<field> for exact row matches. Follow data.next_offset when present. For example, GET /datasets/us_shipments/observations?limit=3. A scalar field path returns data.value. Array and object field paths return data.rows. If data.upstream_sample_limited is true, the source supplied a bounded sample.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Dataset identifier from /datasets.",
            "schema": {
              "type": "string",
              "example": "us_shipments"
            }
          },
          {
            "name": "path",
            "in": "query",
            "description": "Field path from dataset inspection.",
            "schema": {
              "type": "string",
              "maxLength": 160
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive from bound in the dataset's date, month, or year format.",
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}(?:-\\d{2}(?:-\\d{2})?)?$"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive to bound in the dataset's date, month, or year format.",
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}(?:-\\d{2}(?:-\\d{2})?)?$"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Offset from the prior response.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 40
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/DatasetObservationsResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/signals": {
      "get": {
        "operationId": "getSignals",
        "summary": "Read UCUI, MPI, and MSR",
        "parameters": [
          {
            "name": "signal",
            "in": "query",
            "description": "Signal family.",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "ucui",
                "mpi",
                "msr"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive from bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive to bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 40
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/SignalsResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/intelligence/current": {
      "get": {
        "operationId": "getIntelligence",
        "summary": "Read recent signals and published market intelligence",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/CurrentIntelligenceResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/publications": {
      "get": {
        "operationId": "searchPublications",
        "summary": "Search published articles and guides",
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "description": "Publication type.",
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "article",
                "knowledge"
              ]
            }
          },
          {
            "name": "query",
            "in": "query",
            "description": "Search terms.",
            "schema": {
              "type": "string",
              "maxLength": 160
            }
          },
          {
            "name": "before",
            "in": "query",
            "description": "Article archive cursor returned as next_before.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Offset from the prior response.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 40
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/PublicationSearchResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/publication": {
      "get": {
        "operationId": "getPublication",
        "summary": "Read a published article or guide",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "description": "Canonical URL from /publications.",
            "schema": {
              "type": "string",
              "format": "uri",
              "maxLength": 280
            },
            "required": true
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Offset from the prior response.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 200000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of characters to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 12000
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/PublicationResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/legacy/fapp": {
      "get": {
        "operationId": "getFapp",
        "summary": "Read FAPP references",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive from bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive to bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Offset from the prior response.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 40
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/LegacyFeedResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/legacy/eex": {
      "get": {
        "operationId": "getEex",
        "summary": "Read EEX historical references",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive from bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive to bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Offset from the prior response.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 40
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/LegacyFeedResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    },
    "/legacy/ucui": {
      "get": {
        "operationId": "getUcui",
        "summary": "Read UCUI snapshots",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive from bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive to bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Offset from the prior response.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 40
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/UcuiFeedResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        },
        "description": "Try GET /legacy/ucui?limit=1 for one published daily crop uncertainty snapshot."
      }
    },
    "/legacy/ucui-log": {
      "get": {
        "operationId": "getUcuiLog",
        "summary": "Read UCUI event history",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Inclusive from bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Inclusive to bound in YYYY-MM-DD.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Offset from the prior response.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of records to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 40
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/LegacyFeedResponse"
          },
          "400": {
            "$ref": "#/components/responses/Http400"
          },
          "401": {
            "$ref": "#/components/responses/Http401"
          },
          "404": {
            "$ref": "#/components/responses/Http404"
          },
          "405": {
            "$ref": "#/components/responses/Http405"
          },
          "409": {
            "$ref": "#/components/responses/Http409"
          },
          "422": {
            "$ref": "#/components/responses/Http422"
          },
          "429": {
            "$ref": "#/components/responses/Http429"
          },
          "503": {
            "$ref": "#/components/responses/Http503"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "MassGain sandbox API key"
      }
    },
    "schemas": {
      "Usage": {
        "type": "object",
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "used": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "remaining": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "trial_ends_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "limit",
          "used",
          "remaining",
          "trial_ends_at"
        ]
      },
      "Result": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "no_observations"
            ]
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "charged": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1
          },
          "replayed": {
            "type": "boolean"
          },
          "request_id": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "status",
          "data",
          "usage",
          "charged",
          "request_id"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "request_id": {
            "type": "string",
            "format": "uuid"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "error",
          "request_id"
        ]
      },
      "Verification": {
        "type": "object",
        "properties": {
          "mode": {
            "const": "sandbox"
          },
          "scope": {
            "const": "api:read"
          }
        },
        "required": [
          "mode",
          "scope"
        ]
      },
      "DatasetEntry": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "default_field_path": {
            "type": "string"
          },
          "query_parameters": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "href": {
            "type": "string"
          },
          "observations_url": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "default_field_path",
          "query_parameters",
          "href",
          "observations_url"
        ]
      },
      "DatasetCatalog": {
        "type": "object",
        "properties": {
          "datasets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DatasetEntry"
            }
          }
        },
        "required": [
          "datasets"
        ]
      },
      "FieldShape": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "count": {
            "type": "integer",
            "minimum": 0
          },
          "row_fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "keys": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "type"
        ]
      },
      "DatasetInspection": {
        "type": "object",
        "properties": {
          "dataset": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "root_fields": {
            "$ref": "#/components/schemas/FieldShape"
          },
          "shape": {
            "$ref": "#/components/schemas/FieldShape"
          }
        },
        "required": [
          "dataset",
          "path",
          "metadata",
          "root_fields",
          "shape"
        ]
      },
      "DatasetObservations": {
        "type": "object",
        "properties": {
          "dataset": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "rows": {
            "type": "array",
            "items": {
              "description": "A source record. Its shape depends on the dataset and selected field path."
            }
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "next_offset": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "value": {
            "description": "Scalar value if the selected path is scalar."
          },
          "matching_rows": {
            "type": "integer",
            "minimum": 0
          },
          "latest_matching_period": {
            "type": "string"
          },
          "latest_matching_observation": {
            "type": "object",
            "additionalProperties": true
          },
          "upstream_total": {
            "type": "integer",
            "minimum": 0
          },
          "upstream_sample_limited": {
            "type": "boolean"
          }
        },
        "required": [
          "dataset",
          "path",
          "metadata"
        ]
      },
      "LegacyFeed": {
        "type": "object",
        "properties": {
          "feed": {
            "type": "string",
            "enum": [
              "fapp",
              "eex",
              "ucui",
              "ucui-log"
            ]
          },
          "source": {
            "type": "string",
            "format": "uri"
          },
          "basis": {
            "type": "string"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "next_offset": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          }
        },
        "required": [
          "feed",
          "source",
          "basis",
          "rows",
          "offset",
          "next_offset"
        ]
      },
      "Signals": {
        "type": "object",
        "properties": {
          "checked_at": {
            "type": "string",
            "format": "date-time"
          },
          "signals": {
            "type": "object",
            "properties": {
              "ucui": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string"
                  },
                  "source_data_url": {
                    "type": "string"
                  },
                  "evidence_type": {
                    "type": "string"
                  },
                  "unit": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "observations": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              },
              "mpi": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string"
                  },
                  "source_data_url": {
                    "type": "string"
                  },
                  "evidence_type": {
                    "type": "string"
                  },
                  "unit": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "observations": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              },
              "msr": {
                "type": "object",
                "properties": {
                  "source": {
                    "type": "string"
                  },
                  "source_data_url": {
                    "type": "string"
                  },
                  "evidence_type": {
                    "type": "string"
                  },
                  "unit": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "observations": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          }
        },
        "required": [
          "checked_at",
          "signals"
        ]
      },
      "CurrentIntelligence": {
        "type": "object",
        "properties": {
          "intel": {
            "type": "object",
            "properties": {
              "source": {
                "type": "string"
              },
              "checked_at": {
                "type": "string"
              },
              "sources": {
                "type": "object",
                "properties": {
                  "articles": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "ucui": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          },
          "signals": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Signals"
              },
              {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "required": [
          "intel",
          "signals"
        ]
      },
      "PublicationSearch": {
        "type": "object",
        "properties": {
          "publications": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "summary": {
                  "type": "string"
                }
              },
              "required": [
                "title",
                "url"
              ]
            }
          },
          "matching_on_page": {
            "type": "integer",
            "minimum": 0
          },
          "next_offset": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "next_before": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "partial": {
            "type": "boolean"
          },
          "source": {
            "type": "string",
            "format": "uri"
          },
          "scope": {
            "type": "string"
          }
        },
        "required": [
          "publications",
          "matching_on_page",
          "next_offset",
          "next_before"
        ]
      },
      "Publication": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "kind": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "content": {
            "type": "string"
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "next_offset": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "evidence_type": {
            "type": "string"
          }
        },
        "required": [
          "url"
        ]
      }
    },
    "responses": {
      "Http400": {
        "description": "Invalid parameters.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Http401": {
        "description": "Invalid, replaced, or expired sandbox key.",
        "headers": {
          "WWW-Authenticate": {
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "invalid_sandbox_key",
                "message": "Use the current key for an active API sandbox trial."
              },
              "request_id": "123e4567-e89b-42d3-a456-426614174000"
            }
          }
        }
      },
      "Http404": {
        "description": "Unknown path or dataset.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Http405": {
        "description": "Method not allowed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Http409": {
        "description": "Idempotency key was already bound to another request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Http422": {
        "description": "Response exceeds the size limit.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Http429": {
        "description": "Sandbox quota exhausted or request throttled. Retry-After applies to throttling.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 60
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Http503": {
        "description": "Source or service temporarily unavailable.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "VerificationResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Verification"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "UsageOnlyResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "maxProperties": 0
                    }
                  }
                }
              ]
            },
            "examples": {
              "example": {
                "value": {
                  "status": "ok",
                  "data": {},
                  "usage": {
                    "limit": 100,
                    "used": 0,
                    "remaining": 100,
                    "trial_ends_at": "2026-12-12T00:00:00.000Z"
                  },
                  "charged": 0,
                  "request_id": "123e4567-e89b-42d3-a456-426614174000"
                }
              }
            }
          }
        }
      },
      "DatasetCatalogResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DatasetCatalog"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "DatasetInspectionResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DatasetInspection"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "DatasetObservationsResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/DatasetObservations"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "SignalsResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Signals"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "CurrentIntelligenceResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CurrentIntelligence"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "PublicationSearchResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PublicationSearch"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "PublicationResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Publication"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "LegacyFeedResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/LegacyFeed"
                    }
                  }
                }
              ]
            }
          }
        }
      },
      "UcuiFeedResponse": {
        "description": "Successful or empty result. Check charged and usage.",
        "headers": {
          "X-Request-Id": {
            "schema": {
              "type": "string"
            }
          },
          "X-MassGain-Limit": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Remaining": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          },
          "X-MassGain-Charged": {
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 1
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Result"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/LegacyFeed"
                    }
                  }
                }
              ]
            },
            "examples": {
              "example": {
                "value": {
                  "status": "ok",
                  "data": {
                    "feed": "ucui",
                    "source": "https://massgain.world/api/ucui.json",
                    "basis": "Published crop uncertainty snapshot. It is not a price, yield, or production observation.",
                    "rows": [
                      {
                        "date": "2026-11-26",
                        "ucui_level": "NORMAL",
                        "ruleset_version": "1.1.0",
                        "notes": null
                      }
                    ],
                    "offset": 0,
                    "next_offset": 1
                  },
                  "usage": {
                    "limit": 100,
                    "used": 1,
                    "remaining": 99,
                    "trial_ends_at": "2026-12-12T00:00:00.000Z"
                  },
                  "charged": 1,
                  "request_id": "123e4567-e89b-42d3-a456-426614174000"
                }
              }
            }
          }
        }
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "description": "Replay the response from the same successful request without charging another action.",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,100}$"
        }
      }
    }
  }
}
