{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/freeport-gg/json-schema/freeport-gg-dispute-schema.json",
  "title": "Dispute",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/freeport-gg-api-openapi.json#/components/schemas/Dispute",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "A prefixed ULID"
    },
    "order_id": {
      "type": "string",
      "description": "A prefixed ULID"
    },
    "state": {
      "type": "string",
      "enum": [
        "open",
        "resolved",
        "withdrawn"
      ]
    },
    "reason_code": {
      "type": "string"
    },
    "detail": {
      "type": [
        "string",
        "null"
      ],
      "description": "What the person who opened it wrote."
    },
    "opened_by": {
      "type": "string",
      "enum": [
        "buyer",
        "seller"
      ]
    },
    "opened_at": {
      "type": "string",
      "format": "date-time"
    },
    "respondent": {
      "type": "string",
      "enum": [
        "buyer",
        "seller"
      ]
    },
    "respond_by": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the respondent's time to answer ends. A dispute nobody answered says so on the record the person deciding it reads."
    },
    "answered": {
      "type": "boolean",
      "description": "Whether the respondent has said anything or put a figure down. Derived from the record on every read."
    },
    "resolution": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "buyer_refunded",
        "seller_paid",
        "split"
      ]
    },
    "decided_via": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "operator",
        "seller_conceded",
        "buyer_released",
        "settlement",
        "bank"
      ],
      "description": "How it ended: a person at Freeport decided, the seller refunded in full, the buyer released the payment, the two sides agreed a settlement, or the buyer's bank took the payment back."
    },
    "resolution_note": {
      "type": [
        "string",
        "null"
      ],
      "description": "The reason given with the decision."
    },
    "buyer_refund": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^\\d+(\\.\\d+)?$",
      "description": "What went back to the buyer when the dispute ended: the whole total, nothing, or the share a split or settlement returned. Null while it is open."
    },
    "resolved_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "currency": {
      "type": "string",
      "minLength": 3,
      "maxLength": 3
    },
    "total": {
      "type": "string",
      "pattern": "^\\d+(\\.\\d+)?$",
      "description": "A decimal string in the row's currency. Never a float."
    },
    "statements": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A prefixed ULID"
          },
          "by": {
            "type": "string",
            "enum": [
              "buyer",
              "seller"
            ]
          },
          "body": {
            "type": "string"
          },
          "links": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Where the evidence is held: a clip or a screenshot on a known host. Shown as a link, never fetched or embedded."
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "by",
          "body",
          "links",
          "created_at"
        ],
        "additionalProperties": false
      }
    },
    "offers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DisputeOffer"
      }
    },
    "standing_offer": {
      "anyOf": [
        {
          "$ref": "#/$defs/DisputeOffer"
        },
        {
          "type": "null"
        }
      ],
      "description": "The offer on the table, or null. At most one is ever open."
    }
  },
  "required": [
    "id",
    "order_id",
    "state",
    "reason_code",
    "detail",
    "opened_by",
    "opened_at",
    "respondent",
    "respond_by",
    "answered",
    "resolution",
    "decided_via",
    "resolution_note",
    "buyer_refund",
    "resolved_at",
    "currency",
    "total",
    "statements",
    "offers",
    "standing_offer"
  ],
  "additionalProperties": false,
  "$defs": {
    "DisputeOffer": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "A prefixed ULID"
        },
        "by": {
          "type": "string",
          "enum": [
            "buyer",
            "seller"
          ]
        },
        "buyer_refund": {
          "type": "string",
          "pattern": "^\\d+(\\.\\d+)?$",
          "description": "What goes back to the buyer. The seller keeps the rest of the order total, less fees."
        },
        "note": {
          "type": [
            "string",
            "null"
          ]
        },
        "state": {
          "type": "string",
          "enum": [
            "open",
            "accepted",
            "declined",
            "withdrawn",
            "superseded",
            "void"
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "decided_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "by",
        "buyer_refund",
        "note",
        "state",
        "created_at",
        "decided_at"
      ],
      "additionalProperties": false
    }
  }
}