{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/peoplescourt-ai/json-schema/peoplescourt-ai-canonical-answer-input-schema.json",
  "title": "CanonicalAnswerInput",
  "description": "Canonical Answer body. Exactly one credential class applies per request, and each states its own required fields.",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/peoplescourt-ai-cases-and-participation-api-openapi.yml#/components/schemas/CanonicalAnswerInput",
  "anyOf": [
    {
      "$ref": "#/$defs/CanonicalSessionAnswerInput"
    },
    {
      "$ref": "#/$defs/CanonicalPartnerAnswerInput"
    },
    {
      "$ref": "#/$defs/CanonicalWalletAnswerInput"
    }
  ],
  "$defs": {
    "CanonicalAnswerFields": {
      "type": "object",
      "description": "Answer fields shared by every credential class. The three input schemas that compose this one state which of them each credential class must send.",
      "properties": {
        "agree": {
          "type": "boolean",
          "description": "Required for a session caller; the hosted operation refuses an Answer without it."
        },
        "principalKind": {
          "type": "string",
          "description": "Canonical vocabulary for the responding principal. The adapter maps it to the stored party type; do not also send type.",
          "enum": [
            "individual",
            "organization",
            "autonomous_agent"
          ]
        },
        "type": {
          "type": "string",
          "enum": [
            "human",
            "entity",
            "agent"
          ]
        },
        "name": {
          "type": "string"
        },
        "position": {
          "type": "string",
          "maxLength": 20000,
          "description": "Required for a bearer Answer."
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "counterclaim": {
          "$ref": "#/$defs/TypedMoneyCounterclaim"
        },
        "relief": {
          "description": "Legacy cases only; v1 cases return answer_relief_field_retired. Mixing relief and counterclaim returns answer_mixed_counterclaim_shapes.",
          "type": "string",
          "maxLength": 2000
        },
        "declaratoryRelief": {
          "type": "string",
          "maxLength": 4000
        },
        "orderRelief": {
          "type": "string",
          "maxLength": 4000
        },
        "hasPrincipal": {
          "type": "boolean"
        },
        "principalCompressedClockConsent": {
          "type": "boolean"
        },
        "protocolActor": {
          "type": "string",
          "description": "Required with protocolPrincipal and protocolSource for a membership-authorized bearer Answer."
        },
        "protocolPrincipal": {
          "type": "string"
        },
        "protocolSource": {
          "type": "string"
        },
        "inviteToken": {
          "type": "string",
          "description": "Wallet-invite Answer only; a membership-authorized Answer must omit it."
        },
        "walletAddress": {
          "type": "string"
        },
        "signature": {
          "type": "string"
        },
        "attest": {
          "type": "boolean"
        },
        "declarantName": {
          "type": "string"
        },
        "declarantCapacity": {
          "type": "string"
        },
        "executionLocation": {
          "type": "string"
        },
        "openingDraftDigest": {
          "type": "string"
        },
        "acceptanceStatementHash": {
          "type": "string"
        },
        "procedureTermsHash": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "Required for non-wallet acceptance of a new case: copy the exact case procedure termsHash."
        },
        "appealWaiverAccepted": {
          "type": "boolean",
          "description": "Optional separate acceptance of the claimant’s offered appeal waiver. False retains the human appeal for both parties. An omitted browser choice also retains it; wallet consent must sign the exact selected terms."
        }
      }
    },
    "CanonicalPartnerAnswerInput": {
      "allOf": [
        {
          "$ref": "#/$defs/CanonicalAnswerFields"
        }
      ],
      "required": [
        "position",
        "protocolActor",
        "protocolPrincipal",
        "protocolSource"
      ],
      "description": "Membership-authorized bearer Answer. The protocol provenance names the acting agent, its principal and the source that authorizes it; invite and wallet proof fields must be absent."
    },
    "CanonicalSessionAnswerInput": {
      "allOf": [
        {
          "$ref": "#/$defs/CanonicalAnswerFields"
        }
      ],
      "required": [
        "agree",
        "position",
        "attest",
        "declarantName",
        "declarantCapacity",
        "executionLocation"
      ],
      "description": "Account session Answer. The operation refuses an Answer without agreement to arbitrate and without the complete human declaration. A respondent who is not the case's verified contact also presents the invitation through inviteToken, and a case opened with pinned hosted terms presents the exact openingDraftDigest and acceptanceStatementHash from that invitation; both stay optional here because they depend on how the respondent was designated, not on the Answer itself. Membership proof, invitation use, consent and the Answer remain one atomic commit."
    },
    "CanonicalWalletAnswerInput": {
      "allOf": [
        {
          "$ref": "#/$defs/CanonicalAnswerFields"
        }
      ],
      "required": [
        "position",
        "inviteToken",
        "walletAddress",
        "signature"
      ],
      "description": "Wallet-invitation Answer. The signature is verified against the invitation; membership protocol fields must be absent."
    },
    "TypedMoneyCounterclaim": {
      "type": "object",
      "additionalProperties": false,
      "description": "An affirmative money request against the claimant on a case pinned to typed-counterclaim-v1. Omit for defense only. The case selects this shape; legacy cases retain relief or account amountUsd. No amount is inferred from the statement.",
      "required": [
        "statement"
      ],
      "properties": {
        "statement": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        "amount": {
          "description": "Optional positive amount exactly representable in safe integer micro-units. If present, currency must equal the case currency. No intake ceiling applies.",
          "anyOf": [
            {
              "type": "string",
              "pattern": "^(?:0|[1-9][0-9]*)(?:\\.[0-9]{1,6})?$"
            },
            {
              "type": "number",
              "exclusiveMinimum": 0
            }
          ]
        },
        "currency": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        }
      }
    }
  }
}