{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.pairrail.com/schemas/pairrail-quote-v1.json",
  "title": "PairRail quote claims, v1",
  "description": "The JWS payload of a PairRail quote (header typ pairrail-quote+jws, alg EdDSA). A valid signature means PairRail signed exactly these facts. It is never a commitment: binding is always false. Spec: https://www.pairrail.com/docs/quotes",
  "type": "object",
  "required": ["iss", "sub", "iat", "quote"],
  "properties": {
    "iss": { "type": "string", "format": "uri", "description": "The PairRail origin that signed the quote." },
    "sub": { "type": "string", "description": "The quote id. Same as quote.id." },
    "iat": { "type": "integer", "description": "When this token was signed, in seconds since the epoch." },
    "exp": { "type": "integer", "description": "When the quote expires, in seconds since the epoch. An expired quote still verifies." },
    "quote": {
      "type": "object",
      "required": ["id", "status", "binding", "quoteMode", "seller", "catalogVersionId", "offerId", "calculation", "createdAt"],
      "properties": {
        "id": { "type": "string" },
        "status": {
          "type": "string",
          "description": "Status when the token was signed. Known values: indicative, approval-required, approved, rejected, revoked, expired, superseded, executing, executed. Treat unknown values as not approved.",
          "examples": ["indicative", "approval-required", "approved"]
        },
        "answerType": { "type": "string", "description": "The seller policy's answer: indicative or approval-required." },
        "binding": { "const": false },
        "quoteMode": { "const": "indicative" },
        "disclaimer": { "type": "string" },
        "seller": {
          "type": "object",
          "required": ["slug"],
          "properties": {
            "organizationId": { "type": ["string", "null"] },
            "slug": { "type": ["string", "null"], "description": "The sellerId used on /mcp?sellerId= and /v1/public/* URLs." },
            "name": { "type": ["string", "null"] }
          }
        },
        "catalogId": { "type": ["string", "null"] },
        "catalogVersionId": { "type": "string" },
        "catalogVersion": { "type": ["integer", "null"] },
        "policyVersionId": { "type": ["string", "null"] },
        "offerId": { "type": "string" },
        "input": {
          "type": ["object", "null"],
          "description": "What the buyer agent asked to price, after defaults.",
          "properties": {
            "seats": { "type": "integer" },
            "units": { "type": "number" },
            "commitmentMonths": { "type": "integer" },
            "requestedDiscountBps": { "type": "integer" }
          }
        },
        "calculation": {
          "type": ["object", "null"],
          "required": ["currency", "subtotal", "discount", "total"],
          "properties": {
            "offerId": { "type": "string" },
            "currency": { "type": "string", "description": "ISO 4217 code." },
            "commitmentMonths": { "type": "integer" },
            "requestedDiscountBps": { "type": "integer" },
            "subtotal": { "$ref": "#/$defs/amount" },
            "discount": { "$ref": "#/$defs/amount" },
            "total": { "$ref": "#/$defs/amount" },
            "taxTreatment": { "type": "string", "examples": ["exclusive"] },
            "lineItems": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "componentId": { "type": "string" },
                  "name": { "type": "string" },
                  "type": { "type": "string", "examples": ["flat", "seat", "usage"] },
                  "quantity": { "type": "number" },
                  "periodMultiplier": { "type": "number" },
                  "subtotal": { "$ref": "#/$defs/amount" }
                }
              }
            },
            "assumptions": { "type": "array", "items": { "type": "string" } }
          }
        },
        "buyerReference": { "type": ["string", "null"], "description": "The buyer's own reference, such as a PO number, as the agent sent it." },
        "createdAt": { "type": "string", "format": "date-time" },
        "expiresAt": { "type": ["string", "null"], "format": "date-time" }
      }
    }
  },
  "$defs": {
    "amount": {
      "type": "string",
      "pattern": "^-?[0-9]+(\\.[0-9]+)?$",
      "description": "A decimal amount in calculation.currency with that currency's minor digits (81.00 USD, 8100 JPY), as a string so no precision is lost."
    }
  }
}
